Networks fail at the worst moment: after your request reached the server, but before the answer reached you. Did the text go out? Without an idempotency key, retrying might send it twice.
What idempotency is
A request is idempotent when making it twice has the same effect as making it once. Reading a message is idempotent; sending one isn't, unless the server can tell a retry from a new request.
An IETF draft, now expired, describes an Idempotency-Key request header for exactly this: making methods such as POST and PATCH fault-tolerant. bubbl3 uses the same header name on every write call.
How bubbl3 fingerprints a request
bubbl3 keeps each key, for your workspace, with the request it came with and the answer it gave:
- The same key with the same request returns the first answer, with
idempotent-replayed: true. Nothing is sent again. - The same key with a different request is refused with
409 idempotency_conflict, and so is a retry while the first request is still running. - Keys last 24 hours. They're 1 to 255 printable characters without spaces.
- A
5xxanswer frees the key, so a retry runs the request again. A4xxanswer is kept, so a retry gets the same answer. - Keys starting with
outreach:,workflow:oragent:are reserved for messages bubbl3 sends itself, and are refused.
curl https://api.bubbl3.com/v1/messages \
-H "Authorization: Bearer $BUBBL3_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-1042-confirmation" \
-d '{ "to": "+13475550142", "body": "Your order is on its way." }'
The MCP server's send_message and reply_to_conversation tools take an idempotency_key that works the same way.
Patterns
- Name the action, not the attempt.
order-1042-confirmationis a good key. A random value made fresh on each retry protects nothing. - One key per message you mean to send. A reminder 48 hours ahead and one on the day are two messages:
appt-881-reminder-48handappt-881-reminder-day. - Retry with backoff, with the same key. After a network error, a
429or a5xx, wait and retry. For a429, wait forretry-after. - Let the SDK help, but pass your own key. The TypeScript SDK makes a key per call if you don't, which protects its own retries but not yours. Pass
{ idempotencyKey }on every send. - Webhooks that trigger sends. If a webhook from another system triggers a text, build the key from that system's event id, so a retried webhook can't text twice.
See the idempotency key glossary entry and the TypeScript quick-start.