Ir al contenido

Idempotency

Every POST to /api/v1/public requires an Idempotency-Key header. This includes creates and actions such as /contracts/{id}/activate. Relvo uses the key to process a request at most once, even if you retry after a timeout or a network error.

Idempotency-Key: 2f6a1e4c-9b3d-4a11-9e2f-6c1a8b0d5e77

There are two exceptions: POST /usage-events and POST /seat-events. Batch ingestion carries an idempotency_key on each event instead of in a header.

  • Send a unique key with every write. A UUID works well.
  • If Relvo has already completed a request with that key, it returns the original result and does not process the request again.
  • A missing header is rejected with 400 idempotency_key_required. A malformed key is rejected with 400 invalid_idempotency_key.
  • If you reuse a key with a different body, the response is 409 idempotency_key_reused. Either your retry logic generated the wrong key, or two unrelated operations collided.

PATCH, PUT, DELETE and actions on existing resources also need If-Match: W/"<version>". See Errors. Keep the same Idempotency-Key when you retry a request. When If-Match was stale, read the resource again, then send a new request with a new key.

  • Generate the key once per logical operation, before the first attempt. Every retry of that operation must reuse it.
  • Keys normally belong to a specific operation. The compatibility /credit-grants creation contract uses a permanent account-scoped marker; keep its keys unique across customer grant purchases. See Credits.
  • If you retry while Relvo is still processing the original request, you get a fast, safe rejection rather than a duplicate write.
Ventana de terminal
curl -X POST "https://app.relvoerp.com/api/v1/public/customers" \
-H "Authorization: Bearer rk_live_xxxxxxxxxxxxxxxxxxxx" \
-H "Idempotency-Key: 2f6a1e4c-9b3d-4a11-9e2f-6c1a8b0d5e77" \
-H "Content-Type: application/json" \
-d '{ "...": "..." }'