Skip to Content
Won.dev

Idempotency

Retry without doing anything twice. The same request again gets the first answer, and is not charged again.

When a request times out, you cannot tell whether it went through. Send it with an Idempotency-Key header, any string that is unique to this request, and send it again with the same key: if the first one went through, you get its answer instead of a second campaign, a second email or a second charge.

curl https://api.won.dev/v1/email/campaigns/cmp_7p1q8w3e5r4k2m9x/start \
  -X POST \
  -H "Authorization: Bearer $WON_API_KEY" \
  -H "Idempotency-Key: 3f6c1a2e-8b4d-4c1f-9e7a-5d2b0c8f4a61"

How it works

  • A key is any string of up to 255 characters, such as a UUID. Keys belong to the organization and are kept for 24 hours.
  • The same key with the same request returns the first answer, with usage.replayed: true. Nothing is done or charged again.
  • The same key with a different request fails with 409 idempotency_conflict. A new request needs a new key.
  • If the first request is still running, the repeat fails with 409 request_in_progress. Wait retry_after seconds and send it again with the same key.
  • A request that failed is not stored: sending it again with the same key runs it again.
  • A dry_run is never stored, so it does not use up a key.
  • Test keys and live keys never share stored answers.

Which requests

RequestsWithout a keyWith a key
Paid ones: trade data, enrichment, POST /email/messages, POST /email/replies/{id}/reply and POST /email/capacityThe same request within 24 hours returns the stored answer, free.The same, and a different request under the same key fails.
Every other POST, PATCH and DELETEDone again.The repeat returns the first answer.
POST /webhooksDone again.Done again: its answer holds the signing secret, which is shown once and never stored. Delete a second webhook if a retry made one.
Free GET requestsThey change nothing.The key is ignored.

A paid answer whose notice says a part could not be loaded is not stored: the repeat loads that part again, and what you already paid for is not charged a second time.

MCP

The MCP tools take no Idempotency-Key. A paid tool called again with the same arguments within 24 hours returns the stored answer for free, and email_launch_campaign never writes to the same person twice: people already in a campaign of yours that has not ended are left out.

On this page