Skip to main content
In this tutorial you add a welcome email to a Node.js sign-up flow. By the end, every new account gets one welcome email, even if the sign-up request is retried.
You’ll need: a verified sending domain, an API key with the sending scope, Node.js 18+, and an Express app. See the Quickstart if you haven’t set these up.
1

Install the SDK

The SDK has no dependencies of its own. Install it once your package is published; until then, see the SDK status table.
2

Create the client

Store the key in an environment variable. Never hard-code it.
3

Send on sign-up, with an idempotency key

The key identifies the business event, not the request. Using the user’s ID means a retried request sends the same email once.
Send the welcome email after the user is saved, not before. If the save fails, nothing is sent.
4

Handle failures

Retryable failures (429 and 5xx) are retried by the SDK. A permanent failure, such as an unverified domain (403), is thrown, so log it and alert:
See Errors, retries and limits for every status code.
5

Test it

Sign up with your own address. Then check the email’s status:
Retry the same sign-up request with the same user.id to confirm the second send doesn’t deliver a duplicate.

Next