2xx SuccessRFC 9110
202Accepted
Request accepted but processing is not yet complete.
What it means
The request has been accepted for processing but the processing has not been completed. Used for async operations where the server queues the work and processes it later. The response should include a way to check the status of the operation.
When to use it
- ✓Queuing a background job (email sending, report generation)
- ✓Starting a long-running async operation
- ✓Batch processing requests
- ✓Webhook processing
Code Examples
Express — Queue a background job
javascript
app.post('/reports/generate', async (req, res) => {
const jobId = await queue.add('generate-report', req.body);
res.status(202).json({
message: 'Report generation started',
jobId,
statusUrl: `/reports/status/${jobId}`,
});
});