Developers/Guides

Idempotency

Creating POSTs accept an Idempotency-Key header so a retry after a timeout cannot create a second resource.

HTTP
POST /v1/templates
Authorization: Bearer pb_live_…
Idempotency-Key: crm-00123-welcome
Content-Type: application/json

{ "name": "Welcome", "productSpecificationId": "psp_…" }

Rules:

  • The key is 1 to 255 characters and scoped to your organisation and the endpoint; the same key on another endpoint is a different key.
  • A repeat with the same body replays the stored response, with the header Idempotent-Replayed: true.
  • The same key with another body answers 422 idempotency_key_reused.
  • While the first request is still running, a duplicate answers 409 idempotency_in_progress; retry after a moment.
  • A failed request releases the key, so the corrected retry runs.
  • Keys are kept for 24 hours. For a card (POST /v1/postflows/{id}/items) the key also stays on the card for those 24 hours: a repeat answers that card, the same key in another Postflow answers 422 idempotency_key_reused, and after 24 hours the key makes a new card.
  • The answer of a card's endpoints (create, retry, skip, cancel) is stored without the recipient and the field values. A replay reads them from the card as it is now: the repaired values after a repair, null once the card's personal data was removed by retention. The other fields are replayed as they were.
  • The Postbatch import (POST /v1/postbatches/{id}/import) keeps its key with the import for as long as the import exists: the same key with the same upload and mapping answers that import.
  • A Postflow batch (POST /v1/postflows/{id}/items/batch) and a file's start (POST /v1/postflows/{id}/items/files/start) keep their key with the ingestion they made for its life, as the Postbatch import does: the same key with the same body (the same items, or the same upload) answers that ingestion with 202, the same key with another body answers 422 idempotency_key_reused. Its cards carry no key of their own. See batches and files.

Use a natural key when you have one, such as the CRM record id plus the event that triggered the call. The SDKs expose idempotencyKey() / idempotency_key() for a random one. Operations that accept the header carry the "Idempotency-Key" pill in the reference.