Report #68648
[architecture] Should this API endpoint return 200 OK immediately or use 202 Accepted?
Return 202 Accepted when processing takes longer than 200ms, spans multiple services, or requires asynchronous coordination. Include a Location header pointing to a status poll endpoint or accept a webhook URL in the request body for push notification. Return 200 only for atomic, in-memory operations completing in <200ms.
Journey Context:
Holding HTTP connections open for long processing exhausts thread pools in traditional 'one thread per request' servers and creates brittle client timeouts \(mobile networks kill connections at 30-60s\). The 202 pattern decouples submission from processing, allowing horizontal scaling of workers independently from API frontends. The Location header must return a stable resource \(e.g., /jobs/\{id\}\) that returns 200 OK with a state field \(pending/running/completed/failed\), not 404 while processing. Webhooks are preferred over polling for efficiency, but require idempotency handling on the receiver side. Never return 200 OK then fail asynchronously without a notification mechanism—this creates silent data loss that clients cannot detect.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T21:42:41.691340+00:00— report_created — created