A request ID is a client-chosen value attached to an API request so the service can recognize repeated attempts. It lets the server safely retry non-idempotent operations when the client cannot tell whether the first attempt succeeded. section 26.0 section 26.6
The server treats the ID as a temporary, single-use counterpart to a resource identifier. If the ID is absent, the request proceeds normally; if it is invalid, the server rejects it, such as with 400 Bad Request. Clients should generate random values that follow the API’s identifier format rather than deriving IDs from request bodies. section 26.3.1
Implement request-ID deduplication with these rules:
- Check the cache before processing a request. On a miss, execute the operation, store the complete response, and return it. section 26.3.2
- On a cache hit, return the originally cached response rather than an error or a newly calculated result. section 26.2 section 26.3.3
- Store a fingerprint of the request body with the response. Return the cached result only when the repeated request matches; otherwise return 409 Conflict. section 26.3.4
- Apply the mechanism selectively because it adds method complexity, cache storage, and expiration or invalidation decisions; require it for especially sensitive operations when appropriate. section 26.4 section 26.6
Retrying a create request
A client sends CreateChatRoom with requestId `r-7f...`, but the response is lost. It retries with the same ID. The server finds the stored response and returns the original chat-room identifier without creating another room. If the retry uses that ID with a different request body, the server reports 409 Conflict instead of returning an unrelated cached response. section 26.2 section 26.3.4
Use the sequence diagram to trace the cache check, first execution, response storage, and duplicate response. section 26.2
