202 Accepted

HTTP response status code 202 Accepted is returned by the server to indicate that a HTTP request has been received, although the processing is not yet complete and ultimately, the HTTP request may not be fulfilled.

Usage

When the 202 Accepted status code is sent, it can be taken only as an acknowledgment that the server has received the HTTP request and at this point, intends to process it. In practice, this may indicate that the server has validated the format of the request and has placed it into an internal queue for processing. For example, it may be a very long-running process, or part of a batch operation that is run daily.

There is no way for the server to return a HTTP response to indicate the eventual outcome of the HTTP request, so it is the client’s responsibility to check periodically, provided the server supports it.

Once the 200 OK status code of success has been received, the client can stop polling. Other examples of valid HTTP response status codes are 201 Created and 204 No Content. If 201 Created was returned to indicate that a new resource was created and is now available, it is specified by the Location response header field and available for the client to access. Status code 204 No Content may simply indicate that the job is complete but there is nothing for the client to retrieve as a result.

Example

In the example, the client posts XML data to the server that defines a job to be complete. The server responds by acknowledging that the data was accepted. Subsequent HTTP requests by the client are used to determine whether the work is completed. Ultimately, the server indicates that the job is complete.

Request

POST /job HTTP/1.1
Host: www.example.re
Content-Type: application/xml
Content-Length: 67
<?xml version="1.0">
<job>
  <id>125</id>
  <task>G01</task>
</job>

Response to the initial request

HTTP/1.1 202 Accepted
Link: </job/status/125> rel="http://example.re/job-status"
Content-Length: 0

Status request 1

GET /job-status/125
Host: www.example.re

Response to status request 1

HTTP/1.1 202 Accepted
Content-Length: 0

Status request 2

GET /job-status/125
Host: www.example.re

Response to status request 2

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 19

{“success":"true"}

After the 200 OK status code is received, the client stops polling and will act accordingly.

Code references

.NET

HttpStatusCode.Accepted

Rust

http::StatusCode::ACCEPTED

Rails

:accepted

Go

http.StatusAccepted

Symfony

Response::HTTP_ACCEPTED

Python3.5+

http.HTTPStatus.ACCEPTED

Java

java.net.HttpURLConnection.HTTP_ACCEPTED

Apache HttpComponents Core

org.apache.hc.core5.http.HttpStatus.SC_ACCEPTED

Angular

@angular/common/http/HttpStatusCode.Accepted

Takeaway

HTTP response status code 202 Accepted indicates that a HTTP request has been received and the processing is either not started or not yet complete. It does not indicate success or failure of the HTTP request.

See also

Last updated: August 2, 2023