Skip to content

HTTP Response Status Code 202 Accepted

What is HTTP Response Status Code 202 Accepted?

HTTP response status code 202 Accepted is an HTTP status code that indicates that a request has been accepted for processing but the processing has not been completed. It is a server response code, which means it is returned by the server in response to a client request. The 202 Accepted status code is an indication that the server has received the request and is working on it.

When is HTTP Response Status Code 202 Accepted Used?

The HTTP response status code 202 Accepted is used when a server needs more time to process a request, and the client needs to be informed about it. It is a non-final response code, which means that the processing of the request is not yet complete. The client may receive another status code once the request processing is complete.

The 202 Accepted status code is commonly used in asynchronous processing, where the server has accepted a request, but the processing of the request may take some time. This status code is also used when a server is overloaded with requests and cannot process them immediately.

Significance of HTTP Response Status Code 202 Accepted in Web Development ?

The HTTP response status code 202 Accepted plays a crucial role in web development. It enables developers to build applications that require asynchronous processing. With the 202 Accepted status code, developers can inform clients that a request has been accepted and is being processed, without the client having to wait for the processing to complete.

The 202 Accepted status code is also useful in load balancing, where a server may be overloaded with requests. By returning the 202 status code, the server can inform the client that the request has been accepted and is being processed by another server. This ensures that the client is not kept waiting, and the load on the server is balanced.

How to Implement HTTP Response Status Code 202 Accepted?

To implement the HTTP response status code 202 Accepted, the server needs to return the code in response to the client request. The server should also include a message indicating that the request has been accepted and is being processed.

Examples of Status Code 202 Accepted in Action!

Example 1: Asynchronous Processing

In this example, the client is sending a request to the server to place an order. The server responds with the 202 Accepted status code, indicating that the request has been accepted and is being processed. The client can continue with other tasks, knowing that the order is being processed in the background.
Request:

POST /api/orders HTTP/1.1
Host: example.com
Content-Type: application/json
{
“item”: “T-shirt”,
“size”: “M”,
“quantity”: 2
}

Response:

HTTP/1.1 202 Accepted
Content-Type: text/plain
Content-Length: 28

Your order is being processed.

Example 2: Load Balancing
In this example, the client is sending a request to the server to retrieve a product with ID 123. The server is currently overloaded with requests and can’t process the request immediately. Instead of returning an error code, the server returns the 202 Accepted status code, informing the client that the request has been accepted and is being processed. The server can then forward the request to another server for processing, ensuring that the client is not kept waiting indefinitely!
Request:

GET /api/products/123 HTTP/1.1
Host: example.com

Response:

HTTP/1.1 202 Accepted
Content-Type: text/plain Content-Length: 29

Your request is being processed.

HTTP Status Code 201 Created FAQ

The 200 OK status code indicates that a request has been successfully processed, while the 202 Accepted status code indicates that the request has been accepted but not yet processed..!

Yes, a server may return the 202 Accepted status code first, indicating that the request has been accepted, and then return another status code once the processing is complete.

No, the 202 Accepted status code is a non-final response code.

Conclusion

These examples demonstrate how the 202 Accepted status code can be used in different scenarios to inform clients that their requests have been accepted and are being processed.

I am the founder of SEO Leaders and have been involved in the internet and web development in one way or another for over 20 years. Since founding SEO Leaders some 6 years ago I have been heavily involved in web develepment, Digital PR and technical SEO for a wide variety of projects. I hope to enlighten you on a wide range of topics related to my chosen profession!

Back To Top