Skip to main content

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.

  1. Read the link with GET and keep the ETag.
  2. Edit with PATCH or /revoke, sending If-Match: <ETag>.
  3. If you get 412, read the link again, reapply your change and send it with the new ETag.
ResponseMeaning
428 PRECONDITION_REQUIREDIf-Match is missing.
400 INVALID_PRECONDITIONIf-Match isn't an ETag. Send it exactly as received, quotes included.
412 VERSION_CONFLICTThe 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.