Skip to content

By the Octri team · Updated

202 Accepted

Share

A 202 means the server took the request and will do the work later. The response doesn’t say whether the work will succeed, so it should tell the client where to check.

All HTTP status codes

Class
2xx success
Defined in
RFC 9110, section 15.3.3
Retry
Not needed
Key header
Location
Cacheable by default
No

When your API should return 202

Return 202 when the work takes longer than a client should wait on one connection, like an export, a video encode or a bulk import. Respond as soon as the job is queued, with a job ID and a URL the client can poll, usually in Location and in the body.

If the work is done by the time you respond, return 201 or 200 with the result. A 202 promises nothing about the outcome, so the status endpoint has to report failures too, with the reason.

How public APIs declare 202 in their OpenAPI specs

Five of the eleven public specs we score declare a 202, as they were on 4 December 2026. GitHub does on 41 operations, Box on 10, and OpenAI, Twilio and SendGrid on one each.

Only one of those 54 responses documents a Location header, on Box. Everywhere else a developer has to find the job’s URL in the body schema or in the prose.

APIOperationsDeclare 202With Location
GitHub1,288410
Box297101
OpenAI40610
Twilio19710
SendGrid Mail310
Stripe61200
Plaid35100
Asana30200
Slack17400
Adyen Checkout2800
Swagger Petstore1900

Counted per operation from each vendor’s public OpenAPI document on 4 December 2026.

Declare 202 in your OpenAPI spec

Declare the 202 with a small job schema, and link it to the operation that reads the job, so a reader can follow the whole flow from your docs.

yaml
paths:
  /exports:
    post:
      operationId: createExport
      responses:
        "202":
          description: Export queued. Poll the Location URL for its status.
          headers:
            Location:
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ExportJob"
          links:
            GetExport:
              operationId: getExport
              parameters:
                exportId: $response.body#/id

What an Octri SDK does with a 202

An Octri SDK treats a 202 as a success and returns the job body typed from your spec. It doesn’t wait for the job to finish, since a spec has no standard way to say which field to poll and which values mean done.

The call that reads the job is an ordinary method, so while you poll it gets the SDK’s retries on a 429 or a 500, 502, 503 or 504.

typescript
import { Acme } from "acme-sdk";

const acme = new Acme({ apiKey: process.env.ACME_API_KEY });

// 202: the export is queued, and the body is the job.
let job = await acme.exports.create({ format: "csv" });

while (job.status === "pending") {
  await new Promise((resolve) => setTimeout(resolve, 2000));
  job = await acme.exports.get({ exportId: job.id });
}

More on retries and typed errors in SDK error handling.

HTTP 202 questions

Should a 202 response include Retry-After?

Often, yes. RFC 9110 defines it for 503 and redirects, but async APIs like Azure’s send it with a 202 to say how long to wait before the first poll, which cuts the number of requests you serve.

Should the status endpoint return an error when the job fails?

No. Return 200 with the job in a failed state and the reason. The poll itself worked, and an error status would read as the poll failing.

Is a 202 the same as a webhook?

No. A 202 leaves the client to poll, and a webhook calls the client when the job finishes. Many APIs offer both and let the client choose.

Share