HTTP 202 Accepted
2xx Success
- Home
- HTTP Status Codes
- 2xx
- 202
What is HTTP 202 Accepted?
The 202 (Accepted) status code indicates that the request has been accepted for processing, but the processing has not been completed. The request might or might not eventually be acted upon, as it might be disallowed when processing actually takes place. This is useful for asynchronous operations where the server cannot process the request immediately.
Common Use Cases
- Asynchronous job queue submission
- Batch processing requests
- Background task initiation
Usage Example
When a user requests a large report generation, accept the request with 202 Accepted and return a status URL in the response body or Location header. The client can then poll that URL to check when the report is ready, at which point subsequent requests will return 200 OK.
// Laravel - accepting a job for async processing
$job = dispatch(new GenerateReportJob($request->input()))
->onQueue('reports');
return response()->json([
'status_url' => route('reports.status', $job->id),
], 202);
Related Status Codes
Common Mistakes
Mistake: Using 202 for synchronous operations that complete immediately
Fix: If the operation completes before the response is sent, use 200 OK or 201 Created instead. 202 is specifically for operations that are accepted but not yet completed.
Mistake: Not providing a way for the client to check operation status
Fix: Always include a status URL, job ID, or polling endpoint when returning 202. Without a mechanism to track progress, the client cannot determine when the operation finishes.