- 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.
| API | Operations | Declare 412 | Taking If-Match | How errors are described |
|---|---|---|---|---|
| Box | 297 | 17 | 8 | Per status code, plus a default |
| GitHub | 1,288 | 4 | 0 | Per status code |
| Asana | 302 | 1 | 0 | Per status code |
| Stripe | 612 | 0 | 0 | One default error response |
| OpenAI | 406 | 0 | 0 | Per status code |
| Plaid | 351 | 0 | 0 | One default error response |
| Twilio | 197 | 0 | 0 | No error responses |
| Slack | 174 | 0 | 0 | One default error response |
| Adyen Checkout | 28 | 0 | 0 | Per status code |
| Swagger Petstore | 19 | 0 | 0 | Per status code, plus a default |
| SendGrid Mail | 3 | 0 | 0 | Per 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.
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.
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.