# Resend (/docs/v/0.6.1/adapters/resend)



The Resend adapter calls the [Resend Email API](https://resend.com/docs/api-reference/emails/send-email) over `fetch` — no extra dependency. It is the default first adapter in these docs: short setup, broad field support, and it is the only adapter that forwards [idempotency keys](/docs/v/0.6.1/concepts/fallbacks-and-retries#idempotency-keys) to the provider natively.

<ProviderBadge adapter="resend" />

## Configure [#configure]

Grab an API key from the [Resend dashboard](https://resend.com/api-keys) and verify the domain you plan to send from.

```ts title="lib/email.ts"
import { createEmailClient } from "@opencoredev/email-sdk";
import { resend } from "@opencoredev/email-sdk/resend";

export const email = createEmailClient({
  adapters: [resend({ apiKey: process.env.RESEND_API_KEY! })],
});
```

<TypeTable
  type="{
  apiKey: {
    description: &#x22;Resend API key.&#x22;,
    type: &#x22;string&#x22;,
    required: true,
  },
  baseUrl: {
    description: &#x22;Override the API origin, e.g. for a proxy.&#x22;,
    type: &#x22;string&#x22;,
    default: '&#x22;https://api.resend.com&#x22;',
  },
  fetch: {
    description: &#x22;Custom fetch implementation for tests or special runtimes.&#x22;,
    type: &#x22;typeof fetch&#x22;,
  },
  headers: {
    description: &#x22;Extra HTTP headers sent with every request.&#x22;,
    type: &#x22;Record<string, string>&#x22;,
  },
}"
/>

## Send [#send]

Resend maps every common transactional field: `cc`, `bcc`, `replyTo`, `headers`, `attachments`, and `tags`.

```ts
const result = await email.send(
  {
    from: "Acme <hello@acme.com>",
    to: [{ email: "user@example.com", name: "Ada" }],
    replyTo: "support@example.com",
    subject: "Welcome to Acme",
    html: "<p>Your workspace is ready.</p>",
    tags: [{ name: "type", value: "welcome" }],
    attachments: [
      { filename: "welcome.txt", content: "Welcome to Acme.", contentType: "text/plain" },
    ],
  },
  { idempotencyKey: "welcome:user_123" },
);

console.log(result.id); // Resend email id, also exposed as result.messageId
```

The `idempotencyKey` is sent as Resend's `Idempotency-Key` header, so retried requests cannot double-send.

<Callout type="warn" title="No metadata field">
  Resend has no metadata concept, so `metadata` on a message throws an `EmailValidationError`
  before any request is made. Use `tags` instead, or pick a [metadata-capable
  adapter](/docs/v/0.6.1/adapters/field-support).
</Callout>

## Verify from the CLI [#verify-from-the-cli]

```bash
RESEND_API_KEY="re_..." npx email-sdk doctor --adapter resend
```

```bash
RESEND_API_KEY="re_..." npx email-sdk send \
  --adapter resend \
  --from "Acme <hello@acme.com>" \
  --to user@example.com \
  --subject "Resend smoke test" \
  --text "It works" \
  --dry-run
```

Drop `--dry-run` to perform one real send from the environment that will send production email — that is the only check that proves the account, sender domain, and recipient policy are ready.
