Skip to main content

Idempotency & Retries

This API guarantees idempotency in four places. Once you are clear on what each one's scope is, you will not end up with duplicate charges or duplicate assets.

Request idempotency (Idempotency-Key)​

Send a stable Idempotency-Key (≤200 characters) with POST /v1/messages:

Retrying a request that timed out
curl -X POST https://api.bluehola.com/v1/messages \
-H "Authorization: Bearer <API_KEY>" \
-H "Idempotency-Key: order-8821-notify" \
-H "Content-Type: application/json" \
-d '{ "phoneNumberId": "pn_01923abc", "to": "8613800138000",
"type": "text", "text": { "body": "Your order has shipped" } }'
  • Reusing the same key within the current authorization scope returns the original message; nothing is sent twice.
  • The same key with different request content returns 409 IDEMPOTENCY_CONFLICT — that is telling you your key generation logic is wrong. Do not work around it by changing the key.
  • If you do not know whether a request succeeded, retry with the same key: the original message is returned if it was created, and nothing is sent twice.

POST /v1/broadcasts accepts the same header at campaign level: one key creates at most one campaign. A repeat with the same key and body returns the original campaign with replayed: true; the same key with a different body returns 409 IDEMPOTENCY_CONFLICT. If you do not know whether a create request succeeded, look it up with GET /v1/broadcasts?idempotencyKey=<key> rather than creating it again under a new key. See Create Broadcast.

tip

Generate one key per business event (such as order-8821-notify), not one per HTTP call. When retrying after a network timeout, that is the only safe approach.

Ledger idempotency​

The ledger is append-only (inserts, never updates), and a given idempotency key is posted at most once:

  • Settlement happens when Meta returns a wamid.
  • A failed status callback triggers an automatic reversal, and the reversal record's idempotency key is derived from the message id, so repeated callbacks do not reverse repeatedly.

The upshot is that a message which was accepted but failed to deliver ends up costing nothing, with no manual intervention. See Billing & Credit Line.

Atomic claiming in onboarding orchestration​

The invitation link's complete endpoint performs an atomic claim (requiring the invitation to be pending and unexpired) before running the orchestration, so a customer double-clicking submit on the landing page does not produce two sets of assets.

After a failure you must call retry to continue the same operation:

danger

POSTing to the create endpoint again after a failure creates a brand-new operation — it does not resume. On retry, only code may change: wabaId and phoneNumberId were bound on first submission, and pointing at different target assets is rejected.

Credit line authorization is idempotent in the same way: an already-authorized Business Portfolio is not authorized again, and an already-attached WABA does not trigger another call to Meta.

At-least-once webhook delivery​

Because retries exist, delivery is at-least-once. De-duplicate by event id:

Signature schemeHeader to de-duplicate on
Default scheme (apiVersion: null)X-Delivery-Id
Connection protocol (apiVersion non-null)Webhook-Id

A manual redelivery (Redeliver a Delivery) keeps the original Webhook-Id under the connection protocol, but gets a new X-Delivery-Id under the default scheme; in that case de-duplicate on the event content (for example the message id / wamid).

The retry schedule is a fixed table, not exponential backoff. After the first delivery there are at most 7 retries, for 8 attempts in total:

Retry #Since previous failureElapsed total
1immediately~0
21 minute1 minute
35 minutes6 minutes
430 minutes36 minutes
52 hours2.6 hours
612 hours14.6 hours
724 hours38.6 hours

The early "immediately + 1 minute" steps cover the vast majority of transient faults; stretching the later ones out to hours leaves the receiving side's operators time to fix things. After 8 attempts it gives up — it will not retry forever. Events missed after that can be found with List Deliveries and sent again with Redeliver a Delivery.

warning

Only 5xx, 429 and network-level failures are retried; any other 4xx is treated as a terminal failure and is not retried. So make sure your endpoint returns 5xx rather than 4xx for transient faults — deliberately returning 4xx on a signature-verification failure means that event is not retried automatically, and can only be recovered by redelivering it manually.

For complete signature verification code, see Webhook Integration.