HTTP 202 Accepted acknowledges a request that is likely to succeed but has not yet been executed. It suits delayed, scheduled, or long-running processing, unlike 204 No Content for an immediately completed deletion or 201 Created for an already-created result. section 4.5.4 section 14.2.3
Monitoring a long-running simulation
A stress-test request may run for an hour, so POST /simulations can return 202 Accepted with the current status and Location: /simulations/12345. The consumer then polls GET /simulations/12345 until the status changes from IN_PROGRESS to DONE. Progress percentage, rate, estimated end time, or Retry-After can guide polling frequency. section 14.7.1
Choose 202 when processing timing is part of the API design:
- Use it for valid requests stored for later processing during planned unavailability, returning application status such as DELAYED and a processingDate. section 14.2.3
- Provide a way to retrieve status; polling works for long operations with predictable progress, while webhooks can avoid inefficient polling when feasible. section 14.7.1 section 14.9
