When sending batch transactional emails, duplicate requests can cause the same emails to be sent multiple times. Use idempotency to ensure that identical requests are processed only once, preventing duplicate deliveries to recipients.
To enable idempotency, include an idempotencyKey header in your request. The API processes a request only once per unique key, ignoring subsequent requests with the same key within the time-to-live (TTL) period.
The idempotencyKey must be a UUID (Universally Unique Identifier). Generate a unique key for each distinct batch request. If you need to retry the exact same request, reuse the same key.
A complete request using the idempotency key:
The TTL for idempotencyKey is 30 minutes. After the TTL expires, you can reuse the same key for a new request.
If you submit a request with an idempotencyKey that was used within the last 30 minutes, the API returns a duplicate_parameter error and does not process the request. This prevents duplicate emails from being sent.
Idempotency works with messageVersions for sending personalized batches. The same idempotency key applies to the entire batch, regardless of how many versions are included.
When using messageVersions with an idempotency key, the API returns one message ID per version. In the example above, the response contains two message IDs — one per message version.