DeckleDocs
Dashboard

API reference

Idempotency

Safely retry a send without the risk of delivering it twice.

Network hiccups happen. The send endpoint accepts an idempotency key so a retried request returns the original result instead of sending again.

The Idempotency-Key header#

Send a unique Idempotency-Key header with your request. Reuse the exact same key when you retry. In the SDK, pass idempotencyKey.

curl -X POST https://app.getdeckle.com/api/v1/send \
  -H "Authorization: Bearer $DECKLE_API_KEY" \
  -H "Idempotency-Key: order_1234_receipt" \
  -H "Content-Type: application/json" \
  -d '{ "from": "Acme <hello@acme.com>", "to": "jane@example.com",
        "subject": "Receipt", "html": "<p>Thanks!</p>" }'

Behavior#

The first request with a given key sends the email and records the result. Any later request with the same key — for this project — skips sending and returns the original result with idempotent: true and a 200 status.

json
{
  "id": "email_9f2c1a8b",
  "status": "sent",
  "messageId": "0000018f-...-amazonses",
  "idempotent": true
}

Choosing a key

Derive the key from the business action, not the moment — for example order_1234_receipt or user_42_welcome. That way an accidental double-fire of the same logical event is de-duplicated, while genuinely different emails still send.