Editing safely
How the API stops two edits from overwriting each other.
Every time you read a link, the response includes an ETag header: a fingerprint of the link as it is right now. To edit or revoke, send that value back in If-Match. If the link changed after you read it, your request is refused instead of silently undoing someone else's change.
- Read the link with
GETand keep theETag. - Edit with
PATCHor/revoke, sendingIf-Match: <ETag>. - If you get 412, read the link again, reapply your change and send it with the new ETag.
| Response | Meaning |
|---|---|
428 PRECONDITION_REQUIRED | If-Match is missing. |
400 INVALID_PRECONDITION | If-Match isn't an ETag. Send it exactly as received, quotes included. |
412 VERSION_CONFLICT | The link changed since you read it. Nothing was applied. |
Successful edits return the new ETag, so you can make another change without reading again. The ETag can also change when your account settings change, such as the Timer switch.