# Migrate from Resend to Sendtern

You can keep the Resend Node.js SDK and its `emails.send` call. To route requests through Sendtern, change the base URL, create a Sendtern key and verify your sending domain.

## Who this guide is for

This guide is for developers who send transactional email from a Node.js service with the Resend SDK and want to move that sending path to Sendtern. It covers a staged switch, checks to make before and after the change, and a code rollback.

## Point the SDK at Sendtern

Keep the `resend` package as a dependency and store a Sendtern API key in your server-side secret manager as `SENDTERN_API_KEY`. Set the SDK's base URL to `https://sendtern.com/resend` as shown below.

```js
import { Resend } from 'resend';

const resend = new Resend(process.env.SENDTERN_API_KEY, {
  baseUrl: 'https://sendtern.com/resend',
});

const { data, error } = await resend.emails.send({
  from: 'Reports <reports@your-verified-domain.example>',
  to: 'recipient@example.com',
  subject: 'Your report is ready',
  text: 'Sign in to see your report.',
  replyTo: 'support@your-verified-domain.example',
}, { idempotencyKey: 'report-123' });

if (error) throw new Error(error.message);
```

Use a stable idempotency key for retries of the same business event. Keep the request body and key unchanged on each retry. Sendtern honors send and batch idempotency for up to 24 hours. A successful response confirms that the request entered the queue. Check the delivery timeline for SMTP acceptance, a delay or a bounce.

## Verify what your integration uses

The compatibility endpoint supports common transactional fields, safe custom headers, inline base64 attachments up to 500 KiB total, and email list and retrieval calls. It supports scheduled-message updates and cancellation for future sends up to 30 days ahead. You can submit up to 100 immediate messages without attachments in a batch. Strict validation rejects the whole batch when a row fails. Permissive validation can accept valid rows and reject individual invalid rows.

Check these limits before switching.

- Encode each attachment as inline base64 content and keep the decoded total within 500 KiB.
- The Node SDK renders JSX client-side. A raw HTTP request must include `html` or `text`, or refer to a published Sendtern template.
- Cancel scheduled messages while they are still waiting. Once the request returns `queued`, follow the delivery timeline for the SMTP outcome.
- List and retrieval access requires a full-access key. For an application that only sends, create a `sending_access` key and use only supported sending calls.
- Domain switching across cloud regions and provider-specific tracking options are unavailable through the compatibility endpoint.
- Keep Sendtern's native URLs for webhook signature verification, delivery events, and provider-specific queue states. Existing Resend IDs and keys remain with Resend.

## Move DNS and traffic in stages

1. **Prepare Sendtern without changing production traffic.** Create a Sendtern project and a new API key. Add your sender domain in Sendtern and copy the DNS records shown there. Publish those records with your DNS provider, then verify the domain in the Sendtern dashboard. DNS verification can take time to propagate.
2. **Exercise a non-production path.** Configure a staging deployment with the Sendtern key and `https://sendtern.com/resend`. Send to an address you control using a domain verified in Sendtern. To inspect rendering in Email Playground first, set the SDK base URL to `https://sendtern.com/test`. Those captures stay in the Playground without using SMTP or live send quota.
3. **Switch a small production slice.** Route a limited portion of application traffic through Sendtern while the existing Resend path remains available. Keep the provider choice in server-side configuration so you can change it without editing templates or business logic.
4. **Check the outcome, then expand.** Review Sendtern's email timeline for SMTP acceptance, delays, and bounces. Compare the result with your application logs and expand the Sendtern share once the canary behaves as expected.

Do not reuse Resend's DNS records as a substitute for the records Sendtern provides. Avoid changing unrelated DNS records during the migration. Sendtern's setup guide has the [production setup steps](https://sendtern.com/docs/quickstart).

## Check results

Look for the returned email ID, then find it in the Sendtern delivery timeline. Check for SMTP acceptance, delays or bounces. Inspect a test capture in Email Playground to verify how the message renders. Keep the original request body and idempotency key for transient retries, and log errors without exposing API keys.

## Roll back the application change

If the canary fails, route new messages back to the existing Resend configuration and credential. Keep Sendtern's DNS records in place while you diagnose the issue. Before retrying an uncertain message through the other provider, check both timelines for earlier submissions. An idempotency key applies within each provider. Once the cause is fixed, repeat the staged switch with a new canary.

## Check the plan that fits

The Free plan covers 100 transactional recipients per month across up to five verified domains, with a daily limit of 100 and three days of API logs. Hobby costs $3 per month for 10,000 recipients and supports up to 10 verified domains. Team starts at $10 per month for 50,000 recipients and includes 30 days of API logs. These are base prices. See [Sendtern pricing](https://sendtern.com/pricing) for the full limits before you switch production traffic.
