calvana/Docs
Docs pages

Idempotency

Last updated: November 19, 2026

An Idempotency-Key lets you retry a POST after a timeout or a dropped connection without doing the thing twice.

When to send a key

Any POST or PATCH takes an Idempotency-Key header, so you can retry after a timeout without doing the thing twice. POST /v1/bookings requires one, because a booking that ran twice books two calls. A PATCH that ran twice would overwrite a change made in between. GET and DELETE ignore the header, since sending them again changes nothing more.

Create a webhook endpoint once, however many times you retry
curl -X POST https://api.calvana.com/v1/webhook_endpoints \
  -H "Authorization: Bearer calvana_live_..." \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 7d0f4c2e-9b1a-4e8f-a3c6-52d9e1b07a44" \
  -d '{"url": "https://hooks.example.com/calvana", "event_types": ["booking.created"]}'
  • A key is 1 to 255 printable ASCII characters. Anything else gets 400 invalid_request.
  • Use one UUID per operation. Make it when your code decides to act, store it with the job, and send the same one on every retry.
  • Calvana keeps a key for at least 24 hours, per workspace and per credential: the API key, or the OAuth connection, which is one member's grant of an AI assistant. Two members who connected the same assistant have their own keys. Rolling an API key keeps its ID, and refreshing a token keeps its grant, so neither makes a retry run twice. An assistant sends its key as a tool call's idempotency_key.

Replays

The same key with the same method, path and body gets the first answer back as it was sent, its request_id included, with the header Idempotent-Replayed: true. Calvana compares bodies as JSON, so key order and spacing don't matter.

The same request sent again
HTTP/1.1 201 Created
Content-Type: application/json
Idempotent-Replayed: true

{ "id": "whe_01jcb2d4f6h8j0k2m4n6p8r0s2", "object": "webhook_endpoint", "...": "the first answer, unchanged" }

Clashes

You sendCalvana answers
The same key with a different method, path or body422 idempotency_key_reused. Use a new key for a new operation.
The same key while the first request still runs409 idempotency_key_in_use. Retry after a second.

What Calvana stores

  • Every answer the work itself produced: any 2xx, and 400, 404, 409 and 422. A retry gets that answer back, errors included.
  • Never 401, 403, 429, a 5xx or the two clash errors, so a retry after any of them runs the request again.
  • The change and its stored answer commit together. A request that dies part way saves neither, and its retry runs cleanly.
  • A stored refusal replays for the key's whole life, even once the state behind it has changed. If you change the request, or wait for what a 409 booking_changed, conflict, booking_account_missing or slot_unavailable named to change, send it again with a new key.
  • A daily sweep deletes keys older than 24 hours, so a key lasts between 24 and 48 hours.