What is the If-Match header?
The If-Match request header makes the request conditional. The server will perform the requested mutation (PUT, PATCH, DELETE) only if the provided ETag matches the current ETag of the resource on the server.
API Usage & Best Practices
- Prevents lost updates: Forces clients to check if the resource has been modified since they last read it.
- Handle failures: If the ETags do not match, abort the update and return a
412 Precondition Failed. - Strong comparison only: RFC 9110 requires the origin to compare
If-Matchvalues with the strong comparison function, so a weak tag such asW/"3a84e27f01"never matches. Use strong ETags on any resource that accepts conditional writes.
Examples
PATCH /v1/leads/lead_123 HTTP/1.1If-Match: "3a84e27f01"