> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mailofly.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Idempotency Keys

> Prevent duplicate email sends during network retries or payment webhooks.

# Idempotency Keys

To avoid sending duplicate emails when retrying failed requests or handling at-least-once webhooks (e.g. Stripe checkout completion), include an `Idempotency-Key` header.

## How It Works

1. You supply a unique key (such as `checkout_session_12345` or a UUID) in the `Idempotency-Key` HTTP header.
2. If Mailofly receives another request with the identical key within 24 hours, it returns the existing message result instead of dispatching a second email.

```bash theme={null}
curl -X POST "https://api.mailofly.com/api/emails" \
  -H "Authorization: Bearer mf_live_..." \
  -H "Idempotency-Key: invoice_98765" \
  -d '{ ... }'
```


## Related topics

- [Manage API Keys](/guides/api-keys/manage-api-keys.md)
- [API Key Security](/guides/api-keys/api-key-security.md)
- [Leaked API Keys](/guides/api-keys/leaked-api-keys.md)
- [Create API key](/getting-started/api-keys.md)
- [SDKs](/sdks/index.md)
