← 输入框|github.com|刷新
Skip to content

fix(emails): accept topic_id in send params - #314

Merged
dielduarte merged 3 commits into
resend:mainfrom
RaphaelFakhri:fix/emails-send-topic-id
Nov 9, 2026
Merged

dielduarte merged 3 commits into
resend:mainfrom
RaphaelFakhri:fix/emails-send-topic-id

Conversation

@RaphaelFakhri

@RaphaelFakhri RaphaelFakhri commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

POST /emails and POST /emails/batch accept a topic_id body 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, but Emails.SendParams has no topic_id key. Under mypy (the repo runs it in strict mode), this fails:

params: resend.Emails.SendParams = {
    "from": "from@email.com",
    "to": "to@email.com",
    "subject": "subject",
    "html": "html",
    "topic_id": "b6d24b8e-af0b-4c3c-be0c-359bbd97381e",
}
# error: Extra key "topic_id" for TypedDict "SendParams"  [typeddict-unknown-key]

Changes

  • Add topic_id: NotRequired[str] to the send params TypedDict, with a docstring entry. Batch.send takes List[Emails.SendParams], so batch sends get the key too.
  • Add tests that check Emails.send and Batch.send pass topic_id through in the JSON body.

Testing

  • mypy --ignore-missing-imports resend/ examples/ tests/: before the change, it reports Extra key "topic_id" on both new tests. After the change, those errors are gone.
  • pytest tests: 854 passed.
  • flake8, black --check and isort --check-only pass 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_id key to Emails.SendParams so 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 both Emails.send and Batch.send, and bumps the version to 2.53.1.

Written for commit 8faacf6. Summary will update on new commits.

View guided diff

@codecov-commenter

codecov-commenter commented Nov 5, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.66%. Comparing base (7f1acd0) to head (8faacf6).
⚠️ Report is 252 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dielduarte
dielduarte force-pushed the fix/emails-send-topic-id branch from 39e97b6 to 8faacf6 Compare November 9, 2026 21:38

@dielduarte dielduarte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_id into tests/[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_id docstring 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.1 so this can go out in the next release.

@dielduarte
dielduarte merged commit 29a69b9 into resend:main Nov 9, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Emails.SendParams is missing topic_id

3 participants