惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

腾讯CDC
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - Franky
博客园_首页
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
IT之家
IT之家
The Cloudflare Blog
V
Visual Studio Blog
罗磊的独立博客
T
Tailwind CSS Blog
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
V
V2EX
阮一峰的网络日志
阮一峰的网络日志
D
Docker
Last Week in AI
Last Week in AI
B
Blog RSS Feed
C
Check Point Blog
J
Java Code Geeks
The GitHub Blog
The GitHub Blog
有赞技术团队
有赞技术团队
博客园 - 聂微东
MongoDB | Blog
MongoDB | Blog
雷峰网
雷峰网

Resend RSS Feed

6 Tips for Accessible Emails Welcoming Manoel do Amaral, our new Brand Designer Welcoming Michael Vaz, our new Customer Success Engineer Six Steps to Improve Your Sender Reputation Welcoming Tatira Andrade, our new Executive Assistant Welcoming Pedro Ivo Hudson, our new Design Engineer Welcoming Diel Duarte, our new Open source Engineer Welcoming Areia Spinner, our new Recruiter Resend Forward: A Conference about Craft React Email 6.0 Custom Tracking Domains AI Email Editor Introducing Automations Welcoming Ahmed Tolba, our new SRE Engineer Welcoming Aneil Singh, our new Founding Account Executive Welcoming Lucas Motta, our new Software Engineer Welcoming Trey Knowles, our new Founding Account Executive Welcoming Anxhela Carciu, our new SRE Engineer Introducing DMARC Analyzer Welcoming Evan Thibodeau, our new Customer Success Engineer Welcoming Derich Pacheco, our new Software Engineer Welcoming Alec Ventura, our new Data Engineer Welcoming Felipe Freitag, our new Software Engineer Welcoming Mateusz Wos, our new Software Engineer Incident report for February 15, 2026 Email automation for OpenClaw How to Create a DevTools Agent Skill Introducing Email Skills Why You Should Embrace the Promotions Tab Slater Smith, our new Customer Success Engineer
Engineering Idempotency Keys
Alexandre Cisneiros, João Melo · 2025-05-07 · via Resend RSS Feed

We just released idempotency keys for our email API.

While adding idempotency to applications is a common pattern, the process includes a lot of details. We learned valuable lessons we'd like to share the process.

What is idempotency?

An idempotent operation is an action you can perform more than once, with the same input, and it always produces the same outcome and avoids repeating side effects.

Once an operation is idempotent, you can safely retry it without risking causing its effects more than once (e.g., sending an email again, using up quota twice, etc.).

How to send an idempotent email using Resend

We added support for idempotency keys on the POST /emails endpoint.

By adding an Idempotency-Key header, or using the equivalent field on our SDKs, you can tell Resend that this specific email should only be sent once, even if we get more than one request from you about it.

We mark the request as idempotent by checking the Idempotency-Key header and the request payload.

  • Key: the same key (256 characters max)
  • Timing: sent within 24 hours
  • Payload: the same payload in the request body

Sending the same payload when you retry a request with an idempotency key is important. We check the request payload to avoid unexpected side effects, such as suppressing unrelated emails. For instance, if you accidentally set the same string for all your idempotency keys, on different emails, and we didn't check that, only your first email would be delivered. By checking the payload, we can detect this is a mistake and let you know in the API response.

How idempotency benefits our customers

Idempotency is a key ingredient for building reliable systems.

Here are a few key benefits for our customers:

  • Dramatically simplifies retries for failed requests
  • Facilitates writing resilient, self-healing applications
  • Prevents duplicate emails for end users
  • Saves resources for both Resend and our customers

How to format your idempotency key

The exact format of your idempotency keys is up to you, but here are some recommendations.

Idempotency keys can be formatted to include an event type (e.g., order-sent) and an entity ID (e.g., 12345678).

Here are some common scenarios:

Order tracking: combine an order ID with an event type

Single-events: for events that happen only once per user, combine the user ID with an event type

Daily notifications: consider including the date in the key

Note that for us there is no special meaning to the separator characters or event names. As long as the keys are 1–256 characters, Resend will hash and store them. The specific format you use is up to you.

Patterns to avoid

Importantly, for idempotency to work, the key must identify exactly one email you want to send. Avoid the following patterns:

Hard-coded keys only

Random UUIDs for the same email

Our implementation details

When we receive an email to send with a valid idempotency key, we first check against existing emails with the same key. The process leads either to an error, the email being sent for the first time, or the cached response being returned.

Here is a full diagram of how we've implemented idempotency keys:

Testing our implementation

To thoroughly test our implementation, we pursued three main strategies.

1. Automated tests

We wrote automated tests to validate the idempotency key implementation.

2. Internal usage

We added idempotency key to our own usage of Resend's API (e.g., team invitations and quota threshold notifications) and then introduced deliberate retries in some of these flows to validate that emails were not sent more than once.

3. User testing

We reached out to users who previously requested this feature to try it out, validate and give us feedback.

Once confident in our internal and user testing, we rolled out the feature to all users. Because using the feature requires sending a specific header, it doesn't impact existing workflows.

Other considerations and lessons

During the implementation, we made several decisions about our implementation.

SDKs rollout

Since many of our users use our SDKs, we needed to model idempotency in natural ways for each of the platforms we support.

Implementation level

We decided to implement it on an API request level, instead of the data model object. This allows us to in the future generalise the implementation to other endpoints more easily, and also support endpoints that don't relate to a single entity, like the batch email endpoint.

Request normalization

We decided to normalize and hash the request body and store it in the idempotency cache with its response. This allows us to check for accidental idempotency key reuse without storing large amounts of data unnecessarily.

Resources we found useful

We referred to community resources and other tech companies implementations of idempotency and to requests from our users who were interested in this feature. Some useful resources include:

Conclusion

Support for idempotency keys was a highly requested feature, and we're happy to bring it to our users. We anticipate many useful use cases for it, and we're sure you will find even more.

We're excited to include this important feature in our API and hope this post helps you implement it in your own applications. If you have any questions, reach out to us and we'll be happy to help.