Aarunya AppsAarunya Apps
202
Accepted
Success

HTTP 202 Accepted — Async API Design & Background Jobs

The request has been accepted for processing, but processing has not been completed — and may not complete. Used for asynchronous operations where the work happens in the background (email sending, report generation, bulk operations).

When to Return 202

Use 202 when you accept a job and hand it off to a background queue. Return a job ID or status URL in the response body so the client can poll for completion.

HTTP Response Example

HTTP/1.1 202 Accepted
Content-Type: application/json

{"jobId": "job_abc123", "statusUrl": "/reports/status/job_abc123"}

Code Examples

Express.js
app.post('/reports/generate', async (req, res) => {
  const jobId = await queue.add('generate-report', req.body)
  res.status(202).json({
    jobId,
    statusUrl: `/reports/status/${jobId}`,
    message: 'Report generation started',
  })
})
Next.js App Router
// app/api/reports/route.ts
export async function POST(request: Request) {
  const body = await request.json()
  const jobId = await queue.enqueue('generate-report', body)
  return Response.json(
    { jobId, statusUrl: `/api/jobs/${jobId}` },
    { status: 202 }
  )
}

Related Status Codes

All HTTP status codes

Browse the complete HTTP status code reference.

All Status Codes

Frequently Asked Questions

What does HTTP 202 Accepted mean?

The request has been accepted for processing, but processing has not been completed — and may not complete. Used for asynchronous operations where the work happens in the background (email sending, report generation, bulk operations).

When should an API return 202?

Use 202 when you accept a job and hand it off to a background queue. Return a job ID or status URL in the response body so the client can poll for completion.