---
title: Idempotency
description: Deduplicate replayed email sends with an idempotency key.
icon: KeyRound
source: "src/idempotency.ts"
---

Deduplicate replayed email sends with an idempotency key.

<Callout title="The one rule">Wrap it outside RetryTransport so all retry attempts share a key.</Callout>

## Configuration

The optional options are `store` and `ttlMs`; memory is the default store.

<Steps><Step title="Wrap an email transport">

```ts
import { IdempotencyTransport } from "sently/idempotency";

const transport = new IdempotencyTransport(inner, { ttlMs: 86_400_000 });
```

</Step><Step title="Create the mailer">

```ts
const mailer = await createMailer({ transport });
```

</Step></Steps>

<Accordions><Accordion title="Does this replace the inner provider?">No. It delegates sends to the wrapped transport.</Accordion></Accordions>

<Cards><Card title="Email channel" href="/docs/channels/email" /></Cards>
