ETag, and writes accept it back in If-Match — three requests in total.
Before you begin
- A document to work with. The example uses one created beforehand.
Step 1: Read the version from the ETag header
Document reads return the current version in theETag response header:
Request
Response
ETag value — the next steps use it to guard a write.
Step 2: Attempt a write guarded by a wrong version
Pass a version in theIf-Match header to make a write conditional. If it does not match the document’s current version — typically because somebody changed the document after you read it — the write is rejected instead of overwriting their change:
Request
Response
412 says the document moved on since the version you supplied. Nothing changed on the server, so you are free to read the document again and decide what to do with the change you found.
A 412 can also come from the platform’s own background processing. Shortly after an upload, a signature or the first download of the document’s content, the platform itself updates the document (thumbnail, text extraction, read receipt). React to every 412 the same way: read the document again and retry, a bounded number of times.
Step 3: Retry with the current version
With the version from theETag you read earlier, the same delete succeeds:
Request
Response
If-Match is optional everywhere: omit it and writes apply unconditionally, last write wins. Use it when several actors may touch the same document.
Complete example
A conditional write that re-reads and retries, a bounded number of times, when it loses the race, as a Node.js script. Error handling is minimal for brevity — in production, inspect the error envelope of non-2xx responses.Next steps
- See a
412next to the other error classes — Handle errors. - Guard the writes that change a document’s content — Annotate and seal a document.
- Which writes accept
If-Matchis documented per endpoint in the API reference.