`contacts.create` posts to `/audiences/undefined/contacts` when `audienceId` is undefined
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 70/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, typescript
- Domain
- api
Research direction
Start by reading the contacts.create() implementation and compare how contacts.get(), contacts.update(), and contacts.remove() handle an undefined audienceId. Check the existing contact tests and add coverage for undefined audienceId, including when segments are present. Done when creation uses POST /contacts in these cases and the tests pass.
Written by the indexing model from the issue text.
Description
Describe the bug
resend.contacts.create() picks the deprecated audiences endpoint whenever the payload has an audienceId key, even if its value is undefined. The request goes to POST /audiences/undefined/contacts and fails, and a payload that also has segments or topics returns the "audienceId is deprecated" error without any request.
contacts.get(), contacts.update() and contacts.remove() already treat an undefined audienceId as absent and use the /contacts endpoints.
This passes type checking when the options object isn't an object literal, for example when it's built from optional config:
const options = {
email: '[email protected]',
audienceId: process.env.RESEND_AUDIENCE_ID, // unset after moving to segments
segments: [{ id: 'segment-id' }],
};
await resend.contacts.create(options);
// error: "`audienceId` is deprecated, and cannot be used together with `segments` or `topics`. ..."
await resend.contacts.create({ email: options.email, audienceId: options.audienceId });
// request: POST https://api.resend.com/audiences/undefined/contacts
Expected behavior
When audienceId is undefined, contacts.create() uses POST /contacts, like the other contact methods.
SDK version
resend 6.37.0 (current canary)
- Dominant language
- TypeScript
- Stars
- 973
- Forks
- 99
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 37
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from resend/resend-node
-
Dependency DashboardOpen
Difficulty 4/5 3-5 days Newbie friendliness 10/100
resend/resend-node#3 ·
Maintainers usually reply within 1 day
All issues in resend/resend-node
Similar issues
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 83/100
lingdojo/kana-dojo#33701 · 1 comment · 5 reactions ·
Maintainers usually reply within 1 day
-
tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
rookslog/zlibrary-mcp#408 ·
Maintainers usually reply within 1 day
-
mp4box.js — 20-byte `sgpd` box with large `entry_count` causes unbounded loop and heap OOM abortOpen
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
status: needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
mastra-ai/mastra#29641 · 1 comment ·
Maintainers usually reply within 1 day