POST /v1/appointments leaves you unsure whether the appointment exists. With an idempotency key you can simply send the same request again: Brelio returns the first result instead of booking twice.
The rule
Every write (POST and PATCH) needs an Idempotency-Key header. Reads (GET) do not.
- Format: 8 to 255 printable ASCII characters without spaces. A UUID v4 is the simplest choice.
- One key per intended change. Generate it before the first attempt and keep it for every retry of that same change.
- Scope: per credential and operation. Two credentials never collide.
- Lifetime: Brelio remembers a key for 24 hours.
What happens
409 OPERATION_IDEMPOTENCY_CONFLICT
Secrets are shown once
Some writes return a secret once (a webhook’s signingsecret). A replay of that request returns the same record without the secret and the header Brelio-Secret-Already-Shown: true. Store the secret from the first answer.
Retry safely
Node.js