Sending and APIs
Idempotency key
An idempotency key is a unique value you send with a request so that retrying it, after a timeout for example, can't send the same email twice.
The server stores the key with the first result. A retry with the same key and the same body gets the stored result back instead of creating a new email. Reusing a key with a different body is an error.
Derive the key from the business event (order id plus email type), not a random value made at retry time, or a crash between attempts still sends twice.
In Envello
POST /emails accepts an Idempotency-Key header and keeps it for 24 hours. POST /emails/batch doesn't take one, so retry a failed batch only for the items that failed.