feat(events): accept idempotencyKey on events.send
Merged
NI
2d ago+32+32+01234567890123456789-1-1-0123456789
Why
resend.events.send should accept an idempotencyKey option, the same way resend.emails.send does.
Today resend.events.send(payload, { idempotencyKey }) fails to compile with 'idempotencyKey' does not exist in type 'RequestOptions'.
What changed
- New
SendEventRequestOptionsextendsPostOptionsandIdempotentRequest, the same shape asCreateEmailRequestOptionsandSendInboxDraftRequestOptions. The package root exports it throughsrc/events/interfaces. events.sendtakesSendEventRequestOptionsinstead ofRequestOptions.Resend.postalready turnsidempotencyKeyinto theIdempotency-Keyheader, so no runtime code changes.
await resend.events.send(
{ event: 'order.created', email: 'ana@example.com' },
{ idempotencyKey: 'order_created:123' },
);
Blast Radius
The change widens the type of an optional parameter. Existing calls compile and send the same request.
Verification
pnpm lint,pnpm typecheck, andpnpm testpass.- New spec in
src/events/events.spec.tschecks the header on the outgoing request. With the oldRequestOptionstype,pnpm typecheckfails on that spec with TS2353. - Against the built
dist/, a local HTTP server gotIdempotency-Key: order_created:123on a call with the key, and no header on a call without it. - A strict consumer that imports
SendEventRequestOptionsfromresendtypechecks againstdist/index.d.mts. Passing{ idempotencyKey: 1 }fails with TS2322.


Summary by cubic
Allows resend.events.send to accept an idempotencyKey option so resending POST /events/send with the same key within 24 hours returns the cached 202 instead of triggering a second automation run (MES-3033).
events.sendnow takes aSendEventRequestOptionstype that mirrorsCreateEmailRequestOptions; the package root exports it.- Passing
{ idempotencyKey }sends theIdempotency-Keyheader, which previously failed typechecking. - A new spec in
src/events/events.spec.tsverifies the header on the outgoing request. - Existing calls compile and send the same request; release after the API change (MES-3036) deploys so the key has an effect.