Skip to content

By the Octri team · Updated

412 Precondition Failed

Share

A 412 means a condition the client put on the request was false. Usually it sent `If-Match` with the ETag it last saw, and someone else has changed the resource since.

All HTTP status codes

Class
4xx client error
Defined in
RFC 9110, section 15.5.13
Retry
After a fresh read
Key header
If-Match
Cacheable by default
No

When your API should return 412

Return 412 when a conditional header like If-Match or If-Unmodified-Since doesn’t match the resource’s current state. This is how an API stops lost updates. Two clients read version 7, the first saves version 8, and the second gets a 412 where it would have overwritten the first client’s change.

To make clients send the condition, require it with a 428. A clash that doesn’t come from a conditional header, like a duplicate name, is a 409.

How public APIs declare 412 in their OpenAPI specs

Three of the eleven public specs we score declare a 412, as they were on 4 December 2026. Box does on 17 operations, GitHub on 4 and Asana on 1.

Box is the only one that also documents If-Match as a parameter, on 8 operations. A reader of the other specs can see that a 412 is possible without being told which header causes it.

APIOperationsDeclare 412Taking If-MatchHow errors are described
Box297178Per status code, plus a default
GitHub1,28840Per status code
Asana30210Per status code
Stripe61200One default error response
OpenAI40600Per status code
Plaid35100One default error response
Twilio19700No error responses
Slack17400One default error response
Adyen Checkout2800Per status code
Swagger Petstore1900Per status code, plus a default
SendGrid Mail300Per status code

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

Declare 412 in your OpenAPI spec

Declare If-Match as a header parameter and the 412 next to it, and return an ETag from the read operation so the client has something to send.

yaml
paths:
  /invoices/{invoiceId}:
    patch:
      operationId: updateInvoice
      parameters:
        - name: If-Match
          in: header
          required: true
          description: The ETag from your last read.
          schema:
            type: string
      responses:
        "200":
          $ref: "#/components/responses/Invoice"
        "412":
          description: The invoice changed since you read it. Fetch it again.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

What an Octri SDK does with a 412

A 412 has no error class of its own in an Octri SDK. The caller gets an SdkHttpError with statusCode 412, and the SDK doesn’t retry it, because only the caller can decide how to merge the two changes.

A header parameter your spec declares, If-Match included, becomes an argument of the generated method, so the condition is part of the typed call.

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

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

try {
  await acme.invoices.update({ invoiceId: "inv_123", ifMatch: '"v7"', memo: "Net 30" });
} catch (err) {
  if (err instanceof SdkHttpError && err.statusCode === 412) {
    // Someone saved first. Read the invoice again and reapply the change.
  }
  throw err;
}

More on retries and typed errors in SDK error handling.

HTTP 412 questions

Is a 412 the same as a 409?

No. A 412 means a condition the client sent was false. A 409 means the request clashes with the resource’s state, with or without a condition.

Can a GET return 412?

Partly. A GET with a matching If-None-Match gets a 304 Not Modified. A 412 on a GET only comes from If-Match or If-Unmodified-Since, which are rare on reads.

Should a 412 include the current ETag?

Yes. Sending the current ETag, or the whole resource, saves the client a read before it tries again.

Share