> ## Documentation Index
> Fetch the complete documentation index at: https://nuntly.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Migrate from Resend

> Move transactional email from Resend to Nuntly in four steps. Set up your domain and key, swap the SDK, move your webhooks, then test and cut over.

Move an app that sends transactional email with a Resend SDK to Nuntly, in TypeScript or Java. The four steps follow a real migration and keep a way back until the end.

## Prerequisites

* A Nuntly account. See [account setup](https://nuntly.com/docs/guides/account-setup.md).
* Access to the DNS records of the domain you send from.

> [!NOTE]
>
> Resend facts on this page come from Resend's own documentation and SDKs, read on November 16, 2026. The code samples compile with `@nuntly/sdk` 2.0.0 and `resend` 6.38.1 under TypeScript `strict`, and with `com.nuntly:nuntly-java` 2.0.0 and `com.resend:resend-java` 4.30.0 on Java 21.

> [!TIP]
>
> An AI coding agent can make the code changes of step 2 for you, then list the calls it could not map. See [Use Nuntly from an AI agent](https://nuntly.com/docs/guides/ai-agents.md). The other steps stay with you.

## Step 1: Set up Nuntly

### Verify your sending domain

Add the domain you send from today. You do not need to remove anything from Resend first.

1. In the Nuntly dashboard, go to **Domains** and click **Add Domain**.
2. Add the DKIM, SPF and MX records Nuntly shows to your DNS provider. DMARC is recommended but never blocks verification. You can import all records at once with the zone file. See [sending domains](https://nuntly.com/docs/guides/sending-domains.md).
3. The domain shows as verified once your DNS provider publishes the records, which takes from a few minutes to a few hours.

Keep Resend's records in place. Nuntly's DKIM, SPF and MX records use their own names, so both sets work on the same domain without conflict. If you publish a DMARC record already, keep it: one `_dmarc` record covers both providers.

If you track opens or clicks with Resend, turn on open and click tracking on the Nuntly domain once it is verified. Nuntly sets tracking per domain, for every email sent from it. See [open and click tracking](https://nuntly.com/docs/guides/sending-domains.md#enable-open-and-click-tracking).

### Create an API key

1. In the dashboard, go to **API Keys** and click **Create API Key**.
2. Pick **Sending only** for an app that only sends, and limit it to the domain above. Pick **Full access** only for code that also reads emails or manages domains, webhooks or keys.
3. Copy the key. It starts with `ntly_` and is shown once.

Store it next to your Resend key, under a new name:

```bash .env theme={null}
RESEND_API_KEY=re_your_resend_key
NUNTLY_API_KEY=ntly_your_api_key
```

Keeping both keys during the migration lets you switch providers with a flag in step 4. See [API keys](https://nuntly.com/docs/guides/api-keys.md) for permissions and domain restrictions.

## Step 2: Swap the SDK

Install the Nuntly SDK next to the Resend one. Remove the Resend SDK only after the cut-over.

```bash npm theme={null}
npm install @nuntly/sdk
```

```bash pnpm theme={null}
pnpm add @nuntly/sdk
```

```bash yarn theme={null}
yarn add @nuntly/sdk
```

```bash bun theme={null}
bun add @nuntly/sdk
```

```xml Maven theme={null}
<dependency>
  <groupId>com.nuntly</groupId>
  <artifactId>nuntly-java</artifactId>
  <version>2.0.0</version>
</dependency>
```

```kotlin Gradle theme={null}
implementation("com.nuntly:nuntly-java:2.0.0")
```

The same order-shipped email, before and after. Only the import, the client and the key change.

```typescript Resend (TypeScript) theme={null}
import { Resend } from 'resend';

const resend = new Resend(process.env.RESEND_API_KEY);

const { data, error } = await resend.emails.send(
  {
    from: 'Acme <hello@yourdomain.com>',
    to: ['user@example.com'],
    replyTo: 'support@yourdomain.com',
    subject: 'Your order has shipped',
    html: '<p>Your package is on the way.</p>',
    tags: [{ name: 'category', value: 'shipping' }],
  },
  { idempotencyKey: 'order-shipped/1234' },
);

if (error) {
  console.error('Email not sent', error.message);
} else {
  console.log('Sent', data.id);
}
```

```typescript Nuntly (TypeScript) theme={null}
import { createSafeNuntly } from '@nuntly/sdk';

const nuntly = createSafeNuntly({ apiKey: process.env.NUNTLY_API_KEY });

const { data, error } = await nuntly.emails.send(
  {
    from: 'Acme <hello@yourdomain.com>',
    to: ['user@example.com'],
    replyTo: 'support@yourdomain.com',
    subject: 'Your order has shipped',
    html: '<p>Your package is on the way.</p>',
    tags: [{ name: 'category', value: 'shipping' }],
  },
  { idempotencyKey: 'order-shipped/1234' },
);

if (error) {
  console.error('Email not sent', error.message);
} else {
  console.log('Sent', data.id, data.status);
}
```

```java Resend (Java) theme={null}
import com.resend.Resend;
import com.resend.core.exception.ResendException;
import com.resend.core.net.RequestOptions;
import com.resend.services.emails.model.CreateEmailOptions;
import com.resend.services.emails.model.CreateEmailResponse;
import com.resend.services.emails.model.Tag;

class ResendSendBefore {
  void send() {
    Resend resend = new Resend(System.getenv("RESEND_API_KEY"));

    CreateEmailOptions email = CreateEmailOptions.builder()
        .from("Acme <hello@yourdomain.com>")
        .to("user@example.com")
        .replyTo("support@yourdomain.com")
        .subject("Your order has shipped")
        .html("<p>Your package is on the way.</p>")
        .tags(Tag.builder().name("category").value("shipping").build())
        .build();

    try {
      CreateEmailResponse sent = resend.emails().send(
          email, RequestOptions.builder().setIdempotencyKey("order-shipped/1234").build());
      System.out.println("Sent " + sent.getId());
    } catch (ResendException e) {
      System.err.println("Email not sent: " + e.getMessage());
    }
  }
}
```

```java Nuntly (Java) theme={null}
import com.nuntly.sdk.ApiError;
import com.nuntly.sdk.IdempotentRequestOptions;
import com.nuntly.sdk.Nuntly;
import com.nuntly.sdk.models.CreateEmailRequest;
import com.nuntly.sdk.models.CreateEmailResponse;
import com.nuntly.sdk.models.Tag;
import java.util.List;

class NuntlySendAfter {
  void send() {
    Nuntly nuntly = Nuntly.create(Nuntly.builder().apiKey(System.getenv("NUNTLY_API_KEY")).build());

    CreateEmailRequest email = CreateEmailRequest.builder()
        .from("Acme <hello@yourdomain.com>")
        .to(List.of("user@example.com"))
        .replyTo(List.of("support@yourdomain.com"))
        .subject("Your order has shipped")
        .html("<p>Your package is on the way.</p>")
        .tags(List.of(Tag.builder().name("category").value("shipping").build()))
        .build();

    try {
      CreateEmailResponse sent = nuntly.emails().send(
          email, IdempotentRequestOptions.builder().idempotencyKey("order-shipped/1234").build());
      System.out.println("Sent " + sent.id() + " " + sent.status());
    } catch (ApiError e) {
      System.err.println("Email not sent: " + e.status() + " " + e.code());
    }
  }
}
```

Two behaviors to know:

* **Idempotency is on by default.** Without an idempotency key, the Nuntly SDKs generate one for each send and reuse it across their own retries, so an automatic retry cannot send twice. Pass your own key, as above, to deduplicate across calls. See [idempotency keys](https://nuntly.com/docs/guides/idempotency.md).
* **Errors are typed.** In TypeScript, `createSafeNuntly()` returns `{ data, error }` like the Resend SDK, and `error` is an `APIError` (with `status`, `code` and `requestId`) when the API answers, or a connection error otherwise. In Java, the client throws an `ApiError` subclass per status. See [errors](https://nuntly.com/docs/api-reference/errors.md).

### SMTP

If your app sends through Resend's SMTP relay, change the host to `smtp.nuntly.com`, the port to `587` with STARTTLS, the username to `nuntly` and the password to your Nuntly API key. See [SMTP](https://nuntly.com/docs/guides/send-emails-with-smtp.md).

### Batch sends

Split a Resend batch into calls of 20 emails or fewer. Values every email shares can move to `fallback`:

```typescript theme={null}
import { createSafeNuntly } from '@nuntly/sdk';

const nuntly = createSafeNuntly({ apiKey: process.env.NUNTLY_API_KEY });

const { data, error } = await nuntly.emails.bulk.send({
  fallback: {
    from: 'Acme <hello@yourdomain.com>',
    subject: 'Your weekly report',
  },
  emails: [
    { to: 'ana@example.com', html: '<p>Hi Ana, here is your report.</p>' },
    { to: 'ben@example.com', html: '<p>Hi Ben, here is your report.</p>' },
  ],
});

if (error) {
  console.error('Bulk not sent', error.message);
} else {
  for (const email of data.emails) {
    console.log(email.id, email.status);
  }
}
```

### Scheduled sends

Pass an ISO 8601 date in `scheduledAt`. To move a scheduled email, cancel it with `nuntly.emails.cancel(id)`, then send it again with the new date:

```typescript theme={null}
import { createSafeNuntly } from '@nuntly/sdk';

const nuntly = createSafeNuntly({ apiKey: process.env.NUNTLY_API_KEY });

const { data, error } = await nuntly.emails.send({
  from: 'Acme <hello@yourdomain.com>',
  to: 'user@example.com',
  subject: 'Your trial ends tomorrow',
  html: '<p>Your trial ends tomorrow.</p>',
  scheduledAt: '2026-12-01T09:00:00.000Z',
});

if (error) {
  console.error('Email not scheduled', error.message);
} else {
  console.log('Scheduled', data.id, data.status);
}
```

## Step 3: Move your webhooks

In the Nuntly dashboard, go to **Webhooks**, click **Create Webhook**, enter your endpoint URL and select the events you handle. Each event and its payload are described in [sending events](https://nuntly.com/docs/guides/sending-webhooks.md). Copy the signing secret into `NUNTLY_WEBHOOK_SECRET`: it is shown once. See [set up webhooks](https://nuntly.com/docs/guides/webhooks.md).

The handler, before and after. Both read the raw body, so in Express register the route before any JSON body parser:

```typescript Resend (TypeScript) theme={null}
import express from 'express';
import { Resend } from 'resend';

const resend = new Resend(process.env.RESEND_API_KEY);
const app = express();

app.post('/webhooks/email', express.text({ type: 'application/json' }), (req, res) => {
  let event;
  try {
    event = resend.webhooks.verify({
      payload: req.body,
      headers: {
        id: req.get('svix-id') ?? '',
        timestamp: req.get('svix-timestamp') ?? '',
        signature: req.get('svix-signature') ?? '',
      },
      webhookSecret: process.env.RESEND_WEBHOOK_SECRET!,
    });
  } catch {
    return res.status(401).json({ error: 'invalid_signature' });
  }

  switch (event.type) {
    case 'email.delivered':
      console.log(`Email ${event.data.email_id} delivered`);
      break;
    case 'email.bounced':
      console.log(`Email ${event.data.email_id} bounced (${event.data.bounce.type})`);
      break;
    case 'email.complained':
      console.log(`Email ${event.data.email_id} marked as spam`);
      break;
    default:
      console.log(`Unhandled event ${event.type}`);
  }

  res.json({ received: true });
});
```

```typescript Nuntly (TypeScript) theme={null}
import express from 'express';
import { verifyWebhook, WebhookVerificationError } from '@nuntly/sdk';

const app = express();

app.post('/webhooks/email', express.raw({ type: 'application/json' }), async (req, res) => {
  let event;
  try {
    event = await verifyWebhook(req.body, req.get('webhook-signature') ?? '', process.env.NUNTLY_WEBHOOK_SECRET!);
  } catch (err) {
    if (err instanceof WebhookVerificationError) {
      return res.status(401).json({ error: 'invalid_signature' });
    }
    throw err;
  }

  switch (event.type) {
    case 'email.delivered':
      console.log(`Email ${event.data.id} delivered`);
      break;
    case 'email.bounced':
      console.log(`Email ${event.data.id} bounced (${event.data.bounce.bounceType})`);
      break;
    case 'email.complained':
      console.log(`Email ${event.data.id} marked as spam`);
      break;
    default:
      console.log(`Unhandled event ${event.type}`);
  }

  res.json({ received: true });
});
```

```java Resend (Java) theme={null}
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.resend.Resend;
import com.resend.core.exception.ResendException;
import com.resend.services.webhooks.model.VerifyWebhookOptions;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;

@RestController
class ResendWebhookController {
  private final Resend resend = new Resend(System.getenv("RESEND_API_KEY"));
  private final ObjectMapper json = new ObjectMapper();

  @PostMapping("/webhooks/email")
  ResponseEntity<Void> receive(
      @RequestBody String payload,
      @RequestHeader("svix-id") String id,
      @RequestHeader("svix-timestamp") String timestamp,
      @RequestHeader("svix-signature") String signature) throws Exception {
    try {
      resend.webhooks().verify(VerifyWebhookOptions.builder()
          .payload(payload)
          .addHeader("svix-id", id)
          .addHeader("svix-timestamp", timestamp)
          .addHeader("svix-signature", signature)
          .secret(System.getenv("RESEND_WEBHOOK_SECRET"))
          .build());
    } catch (ResendException e) {
      return ResponseEntity.status(401).build();
    }

    JsonNode event = json.readTree(payload);
    String emailId = event.path("data").path("email_id").asText();
    switch (event.path("type").asText()) {
      case "email.delivered" -> System.out.println("Email " + emailId + " delivered");
      case "email.bounced" -> System.out.println(
          "Email " + emailId + " bounced (" + event.path("data").path("bounce").path("type").asText() + ")");
      case "email.complained" -> System.out.println("Email " + emailId + " marked as spam");
      default -> System.out.println("Unhandled event " + event.path("type").asText());
    }
    return ResponseEntity.ok().build();
  }
}
```

```java Nuntly (Java) theme={null}
import com.nuntly.sdk.lib.Webhook;
import com.nuntly.sdk.lib.WebhookVerificationError;
import com.nuntly.sdk.models.EmailBouncedEvent;
import com.nuntly.sdk.models.EmailComplainedEvent;
import com.nuntly.sdk.models.EmailDeliveredEvent;
import com.nuntly.sdk.models.WebhookEvent;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;

@RestController
class NuntlyWebhookController {
  @PostMapping("/webhooks/email")
  ResponseEntity<Void> receive(
      @RequestBody String payload,
      @RequestHeader(name = "webhook-signature", required = false) String signature) {
    WebhookEvent event;
    try {
      event = Webhook.verify(payload, signature, System.getenv("NUNTLY_WEBHOOK_SECRET"));
    } catch (WebhookVerificationError e) {
      return ResponseEntity.status(401).build();
    }

    switch (event) {
      case EmailDeliveredEvent e -> System.out.println("Email " + e.data().id() + " delivered");
      case EmailBouncedEvent e -> System.out.println(
          "Email " + e.data().id() + " bounced (" + e.data().bounce().bounceType() + ")");
      case EmailComplainedEvent e -> System.out.println("Email " + e.data().id() + " marked as spam");
      default -> System.out.println("Unhandled event " + event.type());
    }
    return ResponseEntity.ok().build();
  }
}
```

The Nuntly verification rejects a request whose signature does not match or whose timestamp is more than 5 minutes old. It returns a typed event: TypeScript narrows `event.data` in each `case`, and Java matches one record per event type. When your endpoint fails, Nuntly retries with exponential backoff, and you can replay a delivery from the [webhooks observability view](https://nuntly.com/docs/guides/observability-webhooks.md).

Run both handlers during the migration: Resend keeps sending events for the emails it delivered, and Nuntly sends events for its own.

### Carry over your suppressions

Before your first Nuntly send, export the addresses Resend suppressed (bounces and complaints), keep them in your app, and skip them before you call the send. From then on, Nuntly adds permanent bounces and spam complaints to its own suppression list, and an email to a suppressed address triggers `email.rejected`.

## Step 4: Test and cut over

### Send a test

Send to an inbox you own, from the verified domain, with the new key:

1. Send one email with the code from step 2.
2. In the dashboard, open **Emails**, select the email by its ID, and open **Email Timeline** to see its events.
3. Check that your webhook endpoint receives `email.delivered`, and that the signature check passes.
4. Open the email in the inbox and check the headers: DKIM should pass for your domain.

Then run your existing test suite against the Nuntly client to catch any field you forgot to map.

### Cut over

Switch providers with a configuration flag, and keep the Resend code until the cut-over is done:

1. Read the provider from configuration, for example `EMAIL_PROVIDER=nuntly`, and keep both clients in the code.
2. Move one message type at a time. Start with low-risk email such as notifications, watch bounces and complaints in the [observability dashboard](https://nuntly.com/docs/guides/observability.md), then move password resets and receipts.
3. Keep Resend's DNS records, API key and webhook endpoint active until no traffic has gone through Resend for a few days. Emails already scheduled on Resend still send from Resend: cancel them there and schedule them again on Nuntly, or let them run out.

When you are done, remove the Resend DNS records, revoke the Resend API key, delete the Resend webhook and remove the Resend SDK from your dependencies.

## Next steps

> [card] [Send email from Express](https://nuntly.com/docs/guides/send-email-from-express.md)
>
> A full Express app with sending, webhooks and error handling

> [card] [Send email from Spring Boot](https://nuntly.com/docs/guides/send-email-from-spring-boot.md)
>
> The Spring Boot starter, sending and a verified webhook controller

> [card] [Idempotency keys](https://nuntly.com/docs/guides/idempotency.md)
>
> Key formats, strategies and error codes

> [card] [Migrate from SendGrid](https://nuntly.com/docs/guides/migrate-from-sendgrid.md)
>
> The same steps for a SendGrid integration


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.