If-Match
What is If-Match?
If-Match: Send the request only if the current ETag MATCHES. Used for optimistic concurrency in PUT/PATCH. If-Match makes a request conditional. The client sends the ETag of the version it last saw, and the server only applies the change if the resource still has that ETag. This prevents lost updates. Two people open the same record, both edit it, and both save. Without a check, the second save silently overwrites the first. With If-Match, the second save fails with 412 Precondition Failed, and the client can show the latest version and let the user decide.
Frequently asked questions about If-Match
What should you keep in mind with If-Match?
It is called optimistic concurrency, because you do not lock the record while someone edits; you only check for conflicts when saving. APIs that manage shared data, such as documents, settings or inventory, benefit from it. Without ETags, a version number or updated_at timestamp sent with the update achieves the same.
What does an example of If-Match look like?
If-Match: "abc123" At a glance
| Category | HTTP headers |
|---|---|
| Explained by | Reinier de la Parra |
| Updated |