Skip to main content
A receptionist edits a patient in Brelio while your integration updates the same patient. Without a check, the last write silently wins. Brelio prevents that: every record has a version, and every change says which version it was based on.

The rule

  1. Read the record. Its version is in the response.
  2. Send that value unchanged as expectedVersion in the change.
  3. If someone changed the record in between, Brelio answers 409 and changes nothing. Read it again, decide again, retry.
Sending the old version again answers:
409 VERSION_CONFLICT

Treat the version as opaque

Copy version exactly as you read it. Do not build, parse, compare or increment it. Its form depends on the resource and may change: Send it with the type the resource gave it: a string where version is a string, a number where it is a number.

Operations that need it

Creates do not take one: there is nothing to overwrite.

Handle a 409

Do not retry the same request: it will fail again. Read the record, check whether your change still makes sense with the new data (the appointment may already be cancelled), and send a new request with the new version and a new Idempotency-Key.
Node.js