You've just clicked a button to run a complex report. Or maybe you've requested a video transcoding job. Instead of the page freezing for minutes, you immediately get a message: "Your request has been accepted for processing." A few minutes later, you get an email with a link to your finished report.
This smooth, asynchronous experience is a hallmark of well-designed modern software. And it's powered by a crucial, yet often misunderstood, HTTP status code: 202 Accepted
.
Unlike its cousin 200 OK
, which says "I'm done right now," or 201 Created
, which says "I made a new thing," the 202 Accepted
status code is all about managing expectations. It's the server's way of saying, "Message received. I understand what you want me to do. I can't give you the result right now, but I've put it in the queue and I'll handle it. You don't need to wait around."
It's the digital equivalent of giving your ticket to a busy restaurant host. They don't bring you food immediately, but you trust that your place in line is secure and your meal will be ready eventually.
If you're building or using APIs that handle long-running tasks, understanding 202 Accepted
is key to creating responsive, scalable, and user-friendly applications.
So, what does this mean, and why is it important for developers, testers, and API consumers to understand it?
And before we dive into the mechanics, if you're designing APIs that require asynchronous workflows, you need a tool that can help you test and visualize these complex interactions. Download Apidog for free; it's an all-in-one API platform that allows you to easily simulate 202
responses, test polling mechanisms, and ensure your asynchronous processes are robust and reliable.
Now, let's unpack what 202 Accepted
means, when to use it, and how to implement it correctly.
Setting the Stage: The Problem with Synchronous Thinking
To understand why 202
is necessary, we must first recognize the limitations of synchronous requests.
The typical HTTP request-response cycle is synchronous and blocking:
- Client: Sends a request.
- Client: Waits... (this is often called "time to first byte" or TTFB).
- Server: Processes the request (this could involve complex calculations, database queries, calling other services).
- Server: Sends a response (
200 OK
,201 Created
, etc.). - Client: Receives the response and acts on it.
This model works perfectly for quick operations fetching a user profile, retrieving a list of products, or updating a single field. But what if the operation takes 5 seconds? 30 seconds? 5 minutes?
- The connection could time out, leading to errors.
- The user's browser or app would appear frozen, creating a terrible user experience.
- Your server processes would be tied up, unable to handle other incoming requests, leading to poor scalability.
The 202 Accepted
status code is the elegant solution to this problem. It breaks the blocking nature of HTTP, allowing for asynchronous processing.
What Does HTTP 202 Accepted Actually Mean?
The HTTP 202 Accepted
status code is defined in the RFC as a success response. However, it's a very specific type of success. The 202 Accepted status code belongs to the 2xx category, which generally indicates success. It indicates that:
- The request has been received and understood.
- The request has been accepted for processing.
- The processing is not yet complete.
- The processing may or may not eventually result in a completed action (it might even fail later).
However, unlike 200 OK
, which means the request was processed successfully and is complete, 202 tells us something different:
The server has accepted the request, but the processing is not finished yet.
Crucially, the response should give the client some indication of where they can check the status of the request or where the final result will be available in the future.
In other words, 202 is the server's polite way of saying:
"Hey, I've got your request. I’m working on it. But don't expect the result right away."
This makes it especially useful for asynchronous operation processes that take time, like sending an email, processing a large dataset, or kicking off a background job.
Why Does 202 Accepted Exist?
Not all requests can be processed instantly. Imagine if every time you sent an API call, the server had to wait until the entire job was complete before responding. That could lead to:
- Timeouts on long-running tasks.
- Poor user experience because clients would hang.
- Server overloads, since resources are tied up until jobs finish.
The 202 status code solves this problem by allowing servers to acknowledge requests without making clients wait.
The Asynchronous Workflow: A Step-by-Step Breakdown
Let's walk through a concrete example. Imagine an API for generating personalized data reports.
Step 1: The Client's Request
A client application sends a POST
request to start the report generation.
POST /api/reports/generate HTTP/1.1Host: api.example.comContent-Type: application/jsonAuthorization: Bearer <token>
{
"type": "annual_sales",
"year": 2023,
"format": "pdf"
}
Step 2: The Server's 202 Response
The server receives the request. It validates that the request is well-formed and the user is authorized. It then immediately places the job into a processing queue (using a system like Redis, RabbitMQ, or Amazon SQS) and responds.
HTTP/1.1 202 AcceptedLocation: <https://api.example.com/api/reports/status/job-12345Content-Type:> application/json
{
"message": "Your report generation request has been accepted and is being processed.",
"job_id": "job-12345",
"status_url": "<https://api.example.com/api/reports/status/job-12345>",
"estimated_completion_time": "2023-10-27T10:05:00Z"
}
This response is incredibly powerful. Let's break it down:
HTTP/1.1 202 Accepted
: The core message: "I've got it."Location
Header: A standard HTTP header that points to a URL where the status of the request can be monitored. This is a best practice for 202 responses.- Response Body: Provides helpful, human and machine-readable information about what happens next. The
job_id
andstatus_url
are crucial.
Step 3: The Asynchronous Processing
The client is now free to do other things. Meanwhile, on the server:
- A separate background worker (or process) picks up the job from the queue.
- It performs the time-consuming task: querying the database, compiling data, generating the PDF.
- Once complete, it stores the result (e.g., in cloud storage like S3) and updates the job status to "completed."
Step 4: The Client Checks for Completion
The client can now poll the status_url
provided in the 202 response.
GET https://api.example.com/api/reports/status/job-12345
The response to this polling request might change over time:
- Initially:
{"status": "processing", "progress": 45}
- When Complete:
{"status": "completed", "download_url": "<https://api.example.com/api/reports/download/job-12345.pdf>"}
Alternatively, the server could send a notification via a webhook to a URL provided by the client, which is a more advanced and efficient pattern than polling.
Key Characteristics of 202 Accepted
Here are the essential traits of a 202 response:
- Request received: The server got your request.
- Processing not done: The actual job is still ongoing.
- No guarantee of completion: Unlike 200, a 202 doesn’t promise the job will succeed only that it’s been accepted.
- Useful for async workflows: Background jobs, queues, or delayed processing.
202 Accepted vs. Other Success Codes: Knowing the Difference
It's easy to confuse 202
with other 2xx codes. Here’s a simple cheat sheet:
200 OK
: "I successfully processed your request and here is the result right now." (Synchronous, immediate result)201 Created
: "I successfully created a new resource right now. Here is its location and its data." (Synchronous, immediate creation)202 Accepted
: "I will process your request. Check back later for the result." (Asynchronous, deferred processing)204 No Content
: "I successfully processed your request, but I have no content to send back to you." (Synchronous, no body)
Use 202
when the outcome will be available in the future, not immediately.
Why Use 202 Accepted? The Key Benefits
- Improved User Experience (UX): The client application remains responsive. Users get immediate feedback that their request was received, not a spinning wheel of death.
- Better Server Scalability: The server's main request-handling threads are freed up almost instantly. They delegate the heavy lifting to background workers, allowing the server to handle many more incoming requests.
- Handles Uncertainty: The server can accept a request even if it's not 100% sure it can be fulfilled later. For example, it might accept a request that depends on a third-party service that is temporarily down.
- Realistic for Complex Operations: It accurately models real-world processes that take time, like sending emails, processing videos, running machine learning models, or handling large data exports.
Real-World Use Cases for HTTP 202
You'll encounter 202 Accepted
in many modern applications:
- File Processing: Image/video transcoding, document conversion (e.g., PDF generation).
- Data Operations: Large report generation, data export/import, bulk email sends.
- AI/Machine Learning: Submitting a task for model training or inference.
- Payment Processing: Some payment gateways accept a payment request asynchronously.
- DevOps/CI-CD: Triggering a build pipeline. The API accepts the request immediately and returns a link to the build logs.
Benefits of Using 202 Accepted
Why should developers and API designers use 202?
- Prevents client timeouts: Users don't have to wait.
- Improves scalability: Servers don't get locked up on long tasks.
- Better user feedback: Instead of silence, clients know the request is being handled.
- Supports async architectures: Essential for modern microservices.
202 Accepted in Asynchronous Workflows
Here's how it typically works:
- Client sends a request.
- Server responds with 202 and possibly a "status URL."
- Client checks back with the status endpoint to see if the job is done.
For example:
{
"status": "processing",
"check_status": "/jobs/12345/status"
}
This pattern keeps both sides happy: the client gets instant acknowledgment, and the server gets breathing room.
Testing 202 Workflows with Apidog

Testing an asynchronous API flow is more complex than testing a simple synchronous call. This is where Apidog becomes an invaluable tool.
With Apidog, you can:
- Script the Flow: Create a test scenario that first sends the
POST
request and validates that it returns a202
with astatus_url
. - Extract Variables: Use Apidog's scripting to automatically extract the
job_id
orstatus_url
from the202
response and save it as an environment variable. - Test Polling: Create a subsequent
GET
request that uses the extracted variable to call thestatus_url
. You can configure Apidog to retry this request until it gets a "completed" status. - Validate the Final Result: Once the job is done, write assertions to validate the final response from the download URL.
This allows you to automate the testing of the entire asynchronous journey, ensuring reliability and catching regressions.
How to Test 202 Accepted Responses (with Apidog)

This is where Apidog shines. Unlike static tools, Apidog lets you:
- Send requests and simulate different status codes (like 202).
- Mock API endpoints to test asynchronous workflows.
- Document APIs so developers know what to expect from a 202 response.
- Collaborate with team members to refine async handling.
With Apidog, you can build and test end-to-end 202 workflows from acceptance to completion without switching tools.
Potential Pitfalls and Common Misunderstandings
That said, 202 can be misused. Some pitfalls include:
- Assuming completion: Just because the request was accepted doesn't mean it succeeded.
- Not providing follow-ups: APIs should include ways for clients to check job status.
- Overusing 202: Don't use it for simple, immediate operations it’ll confuse clients.
Challenges and Best Practices
Implementing 202
correctly requires careful thought.
- Provide a Status Endpoint: This is non-negotiable. You must provide a URL (via the
Location
header or the response body) where the client can check the progress and final outcome of the request. - Idempotency is Crucial: If a client isn't sure their request went through (e.g., due to a network issue), they might retry. Your API should be designed to handle duplicate requests gracefully using idempotency keys to prevent the same job from being queued multiple times.
- Set Clear Expectations: Use the response body to give an estimated time to completion or a simple status message (
queued
,processing
,failed
,succeeded
). - Consider Webhooks: For a more efficient alternative to polling, allow clients to register a webhook URL that your server will call when the job is complete.
- Plan for Failure: The job might fail in the background. Your status endpoint needs to communicate failures and potentially provide reason codes.
Best Practices for Implementing 202 Accepted
If you're designing APIs that return 202, keep these best practices in mind:
- Always return context: Provide a job ID or status URL.
- Document clearly: Explain how clients should check progress.
- Use webhooks where possible: Notify clients when tasks finish.
- Don’t overuse it: Only return 202 for genuinely async tasks.
202 Accepted in REST vs GraphQL APIs
- REST APIs: 202 is common because requests often map to long-running processes.
- GraphQL APIs: Less common, since GraphQL favors synchronous queries, but still possible with async mutations.
Conclusion: Embracing Asynchronous Design
The HTTP 202 Accepted
Status code is a powerful tool in the API designer's toolkit. It represents a shift from thinking about APIs as simple request-response mechanisms to thinking of them as systems for orchestrating complex, real-world workflows. The 202 Accepted status code might not be the most famous HTTP code, but it plays a critical role in asynchronous API workflows. It tells clients, "We've got your request, but we're still working on it."
By using 202
, you build APIs that are more scalable, more resilient, and that provide a far superior experience for the developers who use them and the end-users who ultimately benefit from them.
It acknowledges that not everything in software happens instantly, and it provides a standardized, robust way to handle that reality.
So the next time you're designing an endpoint for a long-running task, don't force it to be synchronous. Embrace the asynchronous nature of the task. Return a202 Accepted
, provide a status URL, and free your application from the tyranny of the waiting request. If you're building or testing APIs that return 202, you need tools that let you simulate, test, and document these workflows without hassle. That's exactly what Apidog delivers. Use a tool like Apidog to ensure your implementation is robust, testable, and a pleasure to integrate with. Ready to simplify your API testing and documentation? Download Apidog for free today and make handling codes like 202 Accepted effortless.