`contacts.create` posts to `/audiences/undefined/contacts` when `audienceId` is undefined

Open Beginner friendly
#1,176 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@RaphaelFakhri is already working on this.

Since Nov 3, 2026.

  • #1177 by @RaphaelFakhri — open

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from resend/resend-node

All issues in resend/resend-node

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.