Skip to content

Idempotency

Network failures happen mid-request. Did the send go through? With an idempotency key you never need to know: retry as many times as you like and exactly one email is created.

await sendbyte.emails.send({
from: 'PayLink <receipts@paylink.ng>',
to: 'amaka@halo.ng',
subject: 'Receipt for ₦45,000',
html: receiptHtml,
idempotency_key: 'order-4421-receipt',
});

How it behaves

  • First request with a key: email created, 201 returned
  • Any repeat with the same key (same project): the original email returned with 200, no duplicate send
  • Keys are scoped per project and can be any string up to 256 characters

Choosing keys

Derive the key from the business event, not the attempt: order-4421-receipt, user-892-welcome, otp-attempt-77f3. If your system might legitimately send two different emails for one order, put the email’s purpose in the key.