HTTP

Status Code

202 Accepted

The request was accepted for processing but not completed yet. Learn when to use 202 for asynchronous operations.

3 min read intermediate Try in Playground

What is 202 Accepted?

TL;DR: Server accepted your request for background processing but hasn’t finished yet. Check back later using the provided status URL.

A 202 Accepted status code means the server received your request and will process it, but hasn’t finished yet. Think of it like dropping off your car at a repair shop—the mechanic accepts your keys and says “we’ll work on it,” but the repair isn’t done immediately. You get a receipt and come back later to check the status.

This is perfect for long-running operations that would take too long to complete in a single HTTP request.

When Does This Happen?

You’ll see a 202 Accepted response in these common situations:

1. File Processing

POST /videos/upload with large video file
Server starts encoding in the background

2. Batch Operations

POST /users/bulk-import with CSV file
Server queues processing of thousands of records

3. Email Sending

POST /emails/send with newsletter to 10,000 subscribers
Server queues emails for gradual delivery

4. Report Generation

POST /reports/sales with complex parameters
Server starts generating large PDF report

5. Data Analysis

POST /analytics/process with large dataset
Server begins machine learning analysis

Example Responses

Video Upload Processing:

HTTP/1.1 202 Accepted
Content-Type: application/json
Location: /jobs/video-123

{
  "jobId": "video-123",
  "status": "processing",
  "message": "Video upload accepted for processing",
  "estimatedCompletion": "2026-01-18T12:15:00Z",
  "statusUrl": "/jobs/video-123/status"
}
```text

**Bulk Data Import:**

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

{
  "batchId": "import-456",
  "status": "queued",
  "totalRecords": 5000,
  "message": "Import job queued successfully",
  "checkStatusAt": "/imports/456/status"
}

Email Campaign:

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

{
  "campaignId": "newsletter-789",
  "status": "sending",
  "recipients": 10000,
  "sent": 0,
  "progressUrl": "/campaigns/789/progress"
}
```text

## Real-World Example

Imagine you're building a photo sharing app and someone uploads a large image that needs resizing:

**Request:**

```http
POST /photos HTTP/1.1
Host: photoapp.com
Content-Type: multipart/form-data

[large image file data]

Response:

HTTP/1.1 202 Accepted
Content-Type: application/json
Location: /jobs/photo-resize-abc123

{
  "jobId": "photo-resize-abc123",
  "status": "processing",
  "originalSize": "4032x3024",
  "targetSizes": ["1920x1440", "800x600", "200x150"],
  "estimatedCompletion": "2026-01-18T12:05:00Z",
  "statusEndpoint": "/jobs/photo-resize-abc123"
}
```javascript

## 202 vs Other Success Codes

| Code    | Meaning                    | When to Use                                    |
| ------- | -------------------------- | ---------------------------------------------- |
| **202** | Accepted, processing later | Long-running operations, async processing      |
| **200** | Success, completed now     | Immediate operations with results              |
| **201** | Created successfully       | Resource creation that completes immediately   |
| **204** | Success, no content        | Operations that complete with no response data |

## Status Checking Pattern

After receiving 202, clients typically check status:

**Initial Request:**

```http
POST /reports/generate
202 Accepted with jobId

Status Check:

GET /jobs/report-123
→ 200 OK with current status
```text

**Completion Check:**

```http
GET /jobs/report-123
→ 303 See Other, Location: /reports/final-report.pdf

Common Mistakes

❌ Using 202 for quick operations

POST /users/login  ← Fast operation
HTTP/1.1 202 Accepted  ← Should be 200 OK immediately
```text

**❌ Not providing status checking**

```http
HTTP/1.1 202 Accepted
{"message": "Processing"}  ← No way to check progress!

❌ Using 200 for slow operations

POST /videos/process  ← Takes 10 minutes
HTTP/1.1 200 OK  ← Client waits 10 minutes for response
```text

**✅ Correct usage**

```http
POST /videos/process
HTTP/1.1 202 Accepted
Location: /jobs/video-123

{
  "jobId": "video-123",
  "statusUrl": "/jobs/video-123"
}

Best Practices

Provide Job Tracking:

HTTP/1.1 202 Accepted
{
  "jobId": "unique-job-id",
  "statusUrl": "/jobs/unique-job-id",
  "estimatedDuration": "5 minutes"
}
```text

**Include Progress Information:**

```http
GET /jobs/unique-job-id
HTTP/1.1 200 OK

{
  "status": "processing",
  "progress": 65,
  "message": "Processing item 650 of 1000"
}

Handle Completion:

GET /jobs/unique-job-id
HTTP/1.1 303 See Other
Location: /results/final-output

Try It Yourself

Visit our request builder and start a long-running operation:

  1. Set method to POST
  2. Set path to /jobs/demo
  3. Add body with processing parameters
  4. Click Send request
  5. Watch the 202 response with job tracking info

Frequently Asked Questions

What does 202 Accepted mean?

A 202 response means the server accepted the request for processing but has not completed it yet. The request will be processed asynchronously, and the client should check back later for results.

What is the difference between 202 and 200?

200 means the request completed successfully. 202 means the request was accepted but processing is not finished. Use 202 for long-running operations that cannot complete immediately.

How do I check the status of a 202 request?

The 202 response typically includes a Location header or response body with a URL to poll for status. Alternatively, use webhooks to receive notifications when processing completes.

When should I use 202 vs 201?

Use 201 when a resource is created immediately. Use 202 when creation is queued for later processing. 201 means done now; 202 means will be done later.

Keep Learning