How it works
- Format: any string of 1 to 255 characters. Use something tied to the business event, such as
order-1042-welcome, or a UUID you store with the job. - Scope: a key is scoped to your workspace, your API key and a route family (below). The same key on a different route family is independent.
- Lifetime: Blujay keeps a key for 24 hours after the request that used it. Retry within that window.
- Optional, but use it: without a key, every retry is a new request and can send a duplicate message.
Route families
Each idempotent endpoint belongs to a route family. A key is unique within its family, not within one URL.
The two send endpoints also accept the key as an
idempotency_key field in the body. If you send both, they must match, or you get IDEMPOTENCY_KEY_MISMATCH.
Writes that ignore the key
These endpoints accept anIdempotency-Key header without error but don’t use it. A retry does the work again, so check before you repeat one.
Workflow enrollments use their own required
request_id field instead. See Workflows.
Rejected requests are not remembered
Blujay remembers a key only when the request was accepted (202, or 200 for an edit or unsend). A request rejected with a 4xx, for example VALIDATION_ERROR or PRE_REPLY_CONTENT_BLOCKED, releases the key. You can send the fixed request with the same key or a new one; both run as a new request.
If Blujay never finished the original request (for example your connection dropped mid-way and the work was lost), the key is released after about 5 minutes, and a retry with the same key runs the request. Until then the retry returns IDEMPOTENCY_IN_PROGRESS.
When to retry
Back off between retries, for example 1, 2, 4, 8 and 16 seconds with some random jitter, and give up after about 5 attempts or a few minutes. Keep the key with the job so a retry after a restart uses the same key. If a
Retry-After is longer than you want to wait (for example a daily limit), schedule the send for later; a key is honored for 24 hours.
Next steps
Errors
Every error code and whether it is retryable.
Rate limits
Request limits and how to back off.
Track a message
What happens after
202, and when to retry a failed message.