Repository navigation
fix(emails): accept topic_id in send params - #314
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #314 +/- ##
===========================================
+ Coverage 82.66% 97.66% +14.99%
===========================================
Files 4 89 +85
Lines 75 5523 +5448
===========================================
+ Hits 62 5394 +5332
- Misses 13 129 +116 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
dielduarte
force-pushed
the
fix/emails-send-topic-id
branch
from
November 9, 2026 21:38
39e97b6 to
8faacf6
Compare
dielduarte
approved these changes
Nov 9, 2026
dielduarte
left a comment
Contributor
There was a problem hiding this comment.
Thanks @RaphaelFakhri! Clear issue, small fix, and tests that copy the existing broadcasts pattern. Nice work 🙌
I tested it live: Emails.send and Batch.send with topic_id were both delivered. An opt-out topic stopped the email, and an unknown topic returned a 404.
Before merging, I pushed a few small changes to your branch:
- Rebased onto the latest
main. - Moved
test_batch_send_sends_topic_idintotests/[batch_emails_test.py](https://github.com/Users/diel/localhost/resend-python/tests/batch_emails_test.py), where the other batch tests are. - Made the
topic_iddocstring match the API reference. It now also says what happens when the recipient isn't a contact: the topic's default subscription decides. - Bumped the version to
2.53.1so this can go out in the next release.
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.
Summary
POST /emailsandPOST /emails/batchaccept atopic_idbody parameter that scopes the email to a topic, so a contact that opted out of the topic does not receive it. The send email reference, the OpenAPI spec and the Node SDK (topicId) all document it, butEmails.SendParamshas notopic_idkey. Under mypy (the repo runs it in strict mode), this fails:Changes
topic_id: NotRequired[str]to the send params TypedDict, with a docstring entry.Batch.sendtakesList[Emails.SendParams], so batch sends get the key too.Emails.sendandBatch.sendpasstopic_idthrough in the JSON body.Testing
mypy --ignore-missing-imports resend/ examples/ tests/: before the change, it reportsExtra key "topic_id"on both new tests. After the change, those errors are gone.pytest tests: 854 passed.flake8,black --checkandisort --check-onlypass on the changed files.The fix only changes the type, so the runtime body was already correct when the type checker was bypassed.
Fixes #313
Summary by cubic
Adds the
topic_idkey toEmails.SendParamsso mypy strict mode accepts it when sending topic-scoped emails. Runtime behavior was already correct; this is a type-only fix with tests verifying the key passes through on bothEmails.sendandBatch.send, and bumps the version to 2.53.1.Written for commit 8faacf6. Summary will update on new commits.