Report #92039
[architecture] When to return 202 Accepted vs 200 OK in REST API design
Return 202 Accepted with Location header pointing to status endpoint when processing exceeds 500ms or spans multiple services; return 200 only for sub-100ms atomic operations
Journey Context:
Developers default to synchronous HTTP for all operations, causing gateway timeouts \(504\) and cascading failures when downstream services lag. Long-running operations \(ML inference, batch imports, multi-step provisioning\) should return 202 immediately, providing a status endpoint for polling or webhook callbacks. This requires idempotency keys to handle 'accepted but client disconnected before response' scenarios. The 500ms threshold prevents resource locking while maintaining user experience; exceeding it risks client timeouts and retries that trigger duplicate work.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T13:04:43.591935+00:00— report_created — created