Repository navigation
feat: add per-email idempotency keys to batch send - #40
Merged
Merged
Conversation
Add the `BatchEmailMessage` type, an `EmailMessage` with an optional `idempotency_key`, and accept it in `emails.sendBatch()`. Each key is sent in its own batch item, separate from the request-level `idempotencyKey` option. A retried batch returns the original result of every email that was already accepted and sends only the rest. Builders get a key by spreading `builder.build()`. `send()` is unchanged. Document that a failed batch lists the emails accepted before the failure in `error.details.accepted`. Co-Authored-By: Claude <noreply@anthropic.com>
bjarn
force-pushed
the
feat/batch-idempotency-keys
branch
from
October 18, 2026 16:08
2ebf52a to
e7ca763
Compare
bjarn
added this pull request to stack #41
October 18, 2026 17:20
bjornftw
approved these changes
Oct 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #39 — merge that first.
What changed
Non-breaking; suggested bump: minor.
BatchEmailMessage: anEmailMessagewith an optional per-emailidempotency_key.emails.sendBatch()now accepts(BatchEmailMessage | EmailBuilder)[].EmailMessage[]still works as before.idempotency_key. It is separate from the request-levelidempotencyKeyoption, which still sends theIdempotency-Keyheader.{ ...builder.build(), idempotency_key }. No builder setter was added, sobuilder.send()andemails.send()stay unchanged andEmailMessage(the single-send type) does not get the field.409 Conflictwhen a key is reused with different content). The SDK adds no client-side checks.error.details.acceptedlists the emails that were already accepted ({ index, message_id }).Usage
Checks
Run locally on Node 26.5.0:
npm run lint: passed (33 files, no fixes)npm run type-check: passednpm run generate:check: generated files up to date (with the generator), and the header check passed without itnpm run test:coverage: 319 passed, 8 suitesnpm run build: CJS, ESM and DTS builds succeedednpm run test:smoke: ESM import, CJS require and type declarations okNot run locally
Suggested release tag
v3.2.0if released together with #39, otherwise the next minor after it.🤖 Generated with Claude Code