liveBook · Manning

HTTP 202 Accepted

As explained in The Design of Web APIs, Second Edition

202 Accepted is the HTTP status indicating that a request has been accepted for processing but the processing may not yet be complete.

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

How The Design of Web APIs, Second Edition covers it

How deep it goes
Explains selection against 201 and 204, then details status retrieval, progress metadata, polling, and Retry-After.
Examples
Uses deferred money transfers and hour-long stock-market stress tests as concrete asynchronous-processing scenarios.
What you can do after
Operate asynchronous API workflows by returning processing status and enabling later status checks.
How it connects
Connects 202 Accepted with Location, polling, Retry-After, 201 Created, 204 No Content, 503 Service Unavailable, and webhooks.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Design of Web APIs, Second Edition. The section links point to the parts of the book it draws on.