HTTP 202 Accepted acknowledges a request that has been accepted for processing, even though the work may not be complete. Use it when execution is deferred or will take too long to finish before responding; acceptance is not a promise that the work has already succeeded. section 4.5.4 section 14.7.1
Choose the response to match what happens to the request:
- Return 202 Accepted when valid work will be processed later, such as during planned downtime. section 14.2.3
- Return 503 Service Unavailable with Retry-After when the service cannot accept the request and should tell the consumer when to retry. section 14.2.3
- For an instantaneous deletion, use 204 No Content when it is complete and returns no data; 202 would imply it has not yet been executed. section 4.5.4
Defer a bank transfer
During a banking holiday, accept a valid transfer request for later processing and return 202 Accepted with status DELAYED and a processingDate of January 2, rather than the usual 201 Created. This avoids an error response, but requires checks before execution and accepts the risk that the balance may be insufficient when the transfer runs. section 14.2.3
Track a long-running simulation
For a simulation that may take an hour, return 202 Accepted with its status and a Location header pointing to /simulations/12345. The consumer can poll that URL for IN_PROGRESS or DONE. Progress, estimated completion time, and Retry-After guidance can help the consumer decide when to poll again. section 14.7.1 section 14.7.1
