# AI Onboarding Source: https://resend.com/docs/ai-onboarding Everything you need to onboard your AI agent to Resend. If you're developing with AI, Resend offers several resources to improve your experience. * [Resend MCP Server](#resend-mcp-server) * [Resend Docs for Agents](#resend-docs-for-agents) * [Email Skills for Agents](#email-skills-for-agents) * [Quick Start Guides](#quick-start-guides) * [OpenClaw Guide](#openclaw-guide) * [Chat SDK](#chat-sdk) * [AI Builder Integrations](#ai-builder-integrations) ## Prerequisite: Create an API Key Currently, we require a human to create a Resend account. Once you have an account, you'll need to [create an API key](https://resend.com/api-keys). With an API key, your agent can perform many other tasks. To send or receive with Resend, you'll need to [verify a domain](https://resend.com/domains). While an agent can [create a domain](/api-reference/domains/create-domain), the API returns DNS records you will need to add in your DNS provider before [verifying your DNS records](/api-reference/domains/verify-domain). You may find it easier to verify your domain in the dashboard. ## Resend MCP Server MCP is an open protocol that standardizes how applications provide context to LLMs. Among other benefits, it provides LLMs tools to act on your behalf. Our [MCP server](https://github.com/resend/resend-mcp) is open-source and covers our full API surface area. The Resend MCP server is available on NPM and can be added to any supported MCP client. For example: ```json theme={"theme":{"light":"github-light","dark":"vesper"}} { "mcpServers": { "resend": { "command": "npx", "args": ["-y", "resend-mcp"], "env": { "RESEND_API_KEY": "re_xxxxxxxxx" } } } } ``` View installation instructions for Cursor, Codex, Claude Desktop, Windsurf, and more. ## Resend Docs for Agents You can give your agent current docs in a context-aware way in three ways: 1. **Markdown docs** Every doc includes a markdown version (append `md` to any page) ``` Docs for this page: https://resend.com/docs/ai-onboarding.md ``` 2. **Full llms.txt** Give your agent all our docs in a single file. ``` Here are the Resend docs: https://resend.com/docs/llms-full.txt ``` 3. **MCP Docs server** For a more structured approach using MCP tools, you can install our MCP docs server in any MCP client, like Cursor, Codex, or Claude Code. ``` npx add-mcp https://resend.com/docs/mcp ``` ## Email Skills for Agents Skills give AI agents specialized knowledge for specific tasks. Install all three for full coverage: ```bash theme={"theme":{"light":"github-light","dark":"vesper"}} npx skills add resend/resend-skills resend/react-email resend/email-best-practices ``` Or install individually: | Skill | Install | What it does | | --------------------------------------------------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | | [Resend](/resend-skill) | `npx skills add resend/resend-skills` | Send and receive emails, handle errors, prevent duplicate sends, get code examples from various SDKs | | [React Email](/react-email-skill) | `npx skills add resend/react-email` | Build emails in React, Tailwind, and TypeScript. Audit existing React emails for style and cross-client rendering. | | [Email Best Practices](/email-best-practices-skill) | `npx skills add resend/email-best-practices` | Audit SPF/DKIM/DMARC setup, compliance (CAN-SPAM, GDPR), webhook handling | ## Quick Start Guides Throughout our documentation, we provide quick start guides for common tasks with Resend. They contain step-by-step instructions for sending emails, creating templates, and more. Copy the prompt for your agent or click to open in Cursor. Resend provides two endpoints for sending emails: | Approach | Endpoint | Use Case | | ---------- | -------------------- | ------------------------------------------------------------------------- | | **Single** | `POST /emails` | Individual transactional emails, emails with attachments, scheduled sends | | **Batch** | `POST /emails/batch` | Multiple distinct emails in one request (max 100), bulk notifications | **Choose batch when:** * Sending 2+ distinct emails at once * Reducing API calls is important (by default, rate limit is 2 requests per second) * No attachments or scheduling needed **Choose single when:** * Sending one email * Email needs attachments * Email needs to be scheduled * Different recipients need different timing ## Quick Start 1. **Detect project language** from config files (package.json, requirements.txt, go.mod, etc.) 2. **Install SDK** (preferred) or use cURL 3. **Choose single or batch** based on the decision matrix above 4. **Implement best practices** - Idempotency keys, error handling, retries ## Best Practices (Critical for Production) Always implement these for production email sending. ### Idempotency Keys Prevent duplicate emails when retrying failed requests. | Key Facts | | | --------------------- | ---------------------------------------------------------------- | | **Format (single)** | `/` (e.g., `welcome-email/user-123`) | | **Format (batch)** | `batch-/` (e.g., `batch-orders/batch-456`) | | **Expiration** | 24 hours | | **Max length** | 256 characters | | **Duplicate payload** | Returns original response without resending | | **Different payload** | Returns 409 error | ### Error Handling | Code | Action | | -------- | ------------------------------------------------------------------------------------------- | | 400, 422 | Fix request parameters, don't retry | | 401, 403 | Check API key / verify domain, don't retry | | 409 | Idempotency conflict - use new key or fix payload | | 429 | Rate limited - retry with exponential backoff (by default, rate limit is 2 requests/second) | | 500 | Server error - retry with exponential backoff | ### Retry Strategy * **Backoff:** Exponential (1s, 2s, 4s...) * **Max retries:** 3-5 for most use cases * **Only retry:** 429 (rate limit) and 500 (server error) * **Always use:** Idempotency keys when retrying ## Single Email **Endpoint:** `POST /emails` (prefer SDK over cURL) ### Required Parameters | Parameter | Type | Description | | ---------------- | --------- | --------------------------------------------------- | | `from` | string | Sender address. Format: `"Name "` | | `to` | string\[] | Recipient addresses (max 50) | | `subject` | string | Email subject line | | `html` or `text` | string | Email body content | ### Optional Parameters | Parameter | Type | Description | | ---------------- | --------- | --------------------------------- | | `cc` | string\[] | CC recipients | | `bcc` | string\[] | BCC recipients | | `reply_to`\* | string\[] | Reply-to addresses | | `scheduled_at`\* | string | Schedule send time (ISO 8601) | | `attachments` | array | File attachments (max 40MB total) | | `tags` | array | Key/value pairs for tracking | | `headers` | object | Custom headers | \*Parameter naming varies by SDK (e.g., `replyTo` in Node.js, `reply_to` in Python). ### Minimal Example (Node.js) ```typescript theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend(process.env.RESEND_API_KEY); const { data, error } = await resend.emails.send( { from: 'Acme ', to: ['delivered@resend.dev'], subject: 'Hello World', html: '

Email body here

', }, { idempotencyKey: `welcome-email/${userId}` }, ); if (error) { console.error('Failed:', error.message); return; } console.log('Sent:', data.id); ``` ## Batch Email **Endpoint:** `POST /emails/batch` (but prefer SDK over cURL) ### Limitations * **No attachments** - Use single sends for emails with attachments * **No scheduling** - Use single sends for scheduled emails * **Atomic** - If one email fails validation, the entire batch fails * **Max 100 emails** per request * **Max 50 recipients** per individual email in the batch ### Pre-validation Since the entire batch fails on any validation error, validate all emails before sending: * Check required fields (from, to, subject, html/text) * Validate email formats * Ensure batch size is less than or equal to 100 ### Minimal Example (Node.js) ```typescript theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend(process.env.RESEND_API_KEY); const { data, error } = await resend.batch.send( [ { from: 'Acme ', to: ['delivered@resend.dev'], subject: 'Order Shipped', html: '

Your order has shipped!

', }, { from: 'Acme ', to: ['delivered@resend.dev'], subject: 'Order Confirmed', html: '

Your order is confirmed!

', }, ], { idempotencyKey: `batch-orders/${batchId}` }, ); if (error) { console.error('Batch failed:', error.message); return; } console.log( 'Sent:', data.map((e) => e.id), ); ```
## OpenClaw Guide OpenClaw is a tool that allows you to build and deploy AI agents. Agents can interact with APIs like Resend. Equipping your agent with its own email inbox can be a powerful tool to unlock new workflows. Alternatively, give it access to your Resend account to support agentic flows for sending and receiving emails. View the OpenClaw guide. ## Chat SDK The `@resend/chat-sdk-adapter` package is a Vercel Chat SDK adapter that turns email into a two-way communication channel. Receive inbound emails through webhooks, reply through the Resend API, and let the adapter handle threading automatically. It also supports card emails, attachments, and proactive outreach. Build conversational email experiences with the Chat SDK adapter. ## AI Builder Integrations We offer integrations with popular AI builders to help you get started with AI agents. * [Anything Integration](/anything-integration) * [Lovable Integration](/lovable-integration) * [v0 Integration](/v0-integration) * [Bolt.new Integration](/bolt-new-integration) * [Replit Integration](/replit-integration) * [Base44 Integration](/base44-integration) * [Leap.new Integration](/leap-new-integration) # How to add the Resend integration to your Anything project Source: https://resend.com/docs/anything-integration Learn how to add the Resend integration to your Anything project. [Anything](https://createanything.com) is a platform for building web sites, tools, apps, and projects via chat. With their [Resend integration](https://www.createanything.com/docs/integrations/resend), you can send emails from your Anything project. If you prefer to watch a video, check out our video walkthrough below. ## 1. Call the Resend integration in Anything Type `/Resend` in the chat and select the integration, and ask Anything to add email functionality to your project. adding the Resend integration to a Anything chat ## 2. Add your Resend API key Anything usually prompts you for a Resend API key, which you can add in the [Resend Dashboard](https://resend.com/api-keys). If Anything doesn't prompt you for a Resend API key, click the **More options** button and select **Secrets**. Click the **Add new secret** button. * **Name:** `RESEND_API_KEY` * **Value:** Your Resend API key (e.g., `re_xxxxxxxxx0`) Learn more about [Secrets in Create](https://www.createanything.com/docs/essentials#project-settings). ## 3. Add a custom domain to your Resend account By default, you can only send emails to your own email address. To send emails to other email addresses: 1. Add a [custom domain to your Resend account](https://resend.com/domains). 2. Add the custom domain to the `from` field in the `resend` function in Create. Learn more about [Functions in Create](https://www.createanything.com/docs/builder/functions). # Create API key Source: https://resend.com/docs/api-reference/api-keys/create-api-key POST /api-keys Add a new API key to authenticate communications with Resend. ## Body Parameters The API key name. Maximum 50 characters. The API key can have full access to Resend's API or be only restricted to send emails. \* `full_access`: Can create, delete, get, and update any resource. \* `sending_access`: Can only send emails. Restrict an API key to send emails only from a specific domain. This is only used when the `permission` is set to `sending_access`. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.apiKeys.create({ name: 'Production' }); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->apiKeys->create([ 'name' => 'Production' ]); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" params: resend.ApiKeys.CreateParams = { "name": "Production", } resend.ApiKeys.create(params) ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" params = { name: "Production" } Resend::ApiKeys.create(params) ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import "github.com/resend/resend-go/v3" func main() { client := resend.NewClient("re_xxxxxxxxx") params := &resend.CreateApiKeyRequest{ Name: "Production", } client.ApiKeys.Create(params) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{types::CreateApiKeyOptions, Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _api_key = resend .api_keys .create(CreateApiKeyOptions::new("Production")) .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); CreateApiKeyOptions params = CreateApiKeyOptions .builder() .name("Production").build(); CreateApiKeyResponse apiKey = resend.apiKeys().create(params); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.ApiKeyCreateAsync( "Production" ); Console.WriteLine( "Token={0}", resp.Content.Token ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X POST 'https://api.resend.com/api-keys' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'{ "name": "Production" }' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "id": "dacf4072-4119-4d88-932f-6202748ac7c8", "token": "re_c1tpEyD8_NKFusih9vKVQknRAQfmFcWCv" } ``` # Delete API key Source: https://resend.com/docs/api-reference/api-keys/delete-api-key DELETE /api-keys/:api_key_id Remove an existing API key. ## Path Parameters The API key ID. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.apiKeys.remove( 'b6d24b8e-af0b-4c3c-be0c-359bbd97381e', ); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->apiKeys->remove('b6d24b8e-af0b-4c3c-be0c-359bbd97381e'); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" resend.ApiKeys.remove(api_key_id="b6d24b8e-af0b-4c3c-be0c-359bbd97381e") ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::ApiKeys.remove "b6d24b8e-af0b-4c3c-be0c-359bbd97381e" ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import "github.com/resend/resend-go/v3" func main() { client := resend.NewClient("re_xxxxxxxxx") client.ApiKeys.Remove("b6d24b8e-af0b-4c3c-be0c-359bbd97381e") } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); resend .api_keys .delete("b6d24b8e-af0b-4c3c-be0c-359bbd97381e") .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); resend.apiKeys().remove("b6d24b8e-af0b-4c3c-be0c-359bbd97381e"); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI await resend.ApiKeyDeleteAsync( new Guid( "b6d24b8e-af0b-4c3c-be0c-359bbd97381e" ) ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X DELETE 'https://api.resend.com/api-keys/b6d24b8e-af0b-4c3c-be0c-359bbd97381e' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```text Response theme={"theme":{"light":"github-light","dark":"vesper"}} HTTP 200 OK ``` # List API keys Source: https://resend.com/docs/api-reference/api-keys/list-api-keys GET /api-keys Retrieve a list of API keys for the authenticated user. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.apiKeys.list(); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->apiKeys->list(); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" resend.ApiKeys.list() ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::ApiKeys.list ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import "github.com/resend/resend-go/v3" func main() { client := resend.NewClient("re_xxxxxxxxx") client.ApiKeys.List() } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result, list_opts::ListOptions}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _api_keys = resend.api_keys.list(ListOptions::default()).await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); resend.apiKeys().list(); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.ApiKeyListAsync(); Console.WriteLine( "Nr keys={0}", resp.Content.Count ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X GET 'https://api.resend.com/api-keys' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "list", "has_more": false, "data": [ { "id": "91f3200a-df72-4654-b0cd-f202395f5354", "name": "Production", "created_at": "2023-04-08T00:11:13.110779+00:00", "last_used_at": "2024-11-01T17:09:51.813959+00:00" } ] } ``` # Create Broadcast Source: https://resend.com/docs/api-reference/broadcasts/create-broadcast POST /broadcasts Create a new broadcast to send to your contacts. ## Body Parameters The ID of the segment you want to send to. Audiences are now called Segments. Follow the [Migration Guide](/dashboard/segments/migrating-from-audiences-to-segments). Sender email address. To include a friendly name, use the format `"Your Name "`. Email subject. Reply-to email address. For multiple addresses, send as an array of strings. The HTML version of the message. You can include Contact Properties in the body of the Broadcast. Learn more about [Contact Properties](/dashboard/audiences/contacts). The plain text version of the message. You can include Contact Properties in the body of the Broadcast. Learn more about [Contact Properties](/dashboard/audiences/contacts). If not provided, the HTML will be used to generate a plain text version. You can opt out of this behavior by setting value to an empty string. The React component used to write the message. *Only available in the Node.js SDK.* The friendly name of the broadcast. Only used for internal reference. The topic ID that the broadcast will be scoped to. Send the broadcast immediately after creation. Defaults to `false`. When set to `true`, the broadcast will be sent or scheduled (if `scheduled_at` is provided) without requiring a separate call to the [Send Broadcast](/api-reference/broadcasts/send-broadcast) endpoint. Schedule the broadcast to be sent later. The date should be in natural language (e.g.: `in 1 min`) or ISO 8601 format (e.g: `2024-08-05T11:52:01.858Z`). This parameter requires `send` to be set to `true`. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); // Create a draft broadcast const { data, error } = await resend.broadcasts.create({ segmentId: '78261eea-8f8b-4381-83c6-79fa7120f1cf', from: 'Acme ', subject: 'hello world', html: 'Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}', }); // Create and send immediately const { data, error } = await resend.broadcasts.create({ segmentId: '78261eea-8f8b-4381-83c6-79fa7120f1cf', from: 'Acme ', subject: 'hello world', html: 'Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}', send: true, }); // Create and schedule const { data, error } = await resend.broadcasts.create({ segmentId: '78261eea-8f8b-4381-83c6-79fa7120f1cf', from: 'Acme ', subject: 'hello world', html: 'Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}', send: true, scheduledAt: 'in 1 hour', }); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); // Create a draft broadcast $resend->broadcasts->create([ 'segment_id' => '78261eea-8f8b-4381-83c6-79fa7120f1cf', 'from' => 'Acme ', 'subject' => 'hello world', 'html' => 'Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}', ]); // Create and send immediately $resend->broadcasts->create([ 'segment_id' => '78261eea-8f8b-4381-83c6-79fa7120f1cf', 'from' => 'Acme ', 'subject' => 'hello world', 'html' => 'Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}', 'send' => true, ]); // Create and schedule $resend->broadcasts->create([ 'segment_id' => '78261eea-8f8b-4381-83c6-79fa7120f1cf', 'from' => 'Acme ', 'subject' => 'hello world', 'html' => 'Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}', 'send' => true, 'scheduled_at' => 'in 1 hour', ]); ``` ```py Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" // Create a draft broadcast params: resend.Broadcasts.CreateParams = { "segment_id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", "from": "Acme ", "subject": "Hello, world!", "html": "Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}", } resend.Broadcasts.create(params) // Create and send immediately params: resend.Broadcasts.CreateParams = { "segment_id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", "from": "Acme ", "subject": "Hello, world!", "html": "Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}", "send": true, } resend.Broadcasts.create(params) // Create and schedule params: resend.Broadcasts.CreateParams = { "segment_id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", "from": "Acme ", "subject": "Hello, world!", "html": "Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}", "send": true, "scheduled_at": "in 1 hour", } resend.Broadcasts.create(params) ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" // Create a draft broadcast params = { "segment_id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", "from": "Acme ", "subject": "hello world", "html": "Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}", } Resend::Broadcasts.create(params) // Create and send immediately params = { "segment_id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", "from": "Acme ", "subject": "Hello, world!", "html": "Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}", "send": true, } Resend::Broadcasts.create(params) // Create and schedule params = { "segment_id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", "from": "Acme ", "subject": "Hello, world!", "html": "Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}", "send": true, "scheduled_at": "in 1 hour", } Resend::Broadcasts.create(params) ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import "github.com/resend/resend-go/v3" // Create a draft broadcast params := &resend.CreateBroadcastRequest{ SegmentId: "78261eea-8f8b-4381-83c6-79fa7120f1cf", From: "Acme ", Html: "Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}", Subject: "Hello, world!", } broadcast, _ := client.Broadcasts.Create(params) // Create and send immediately params = { "segment_id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", "from": "Acme ", "subject": "Hello, world!", "html": "Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}", "send": true, } broadcast, _ := client.Broadcasts.Create(params) // Create and schedule params = { "segment_id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", "from": "Acme ", "subject": "Hello, world!", "html": "Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}", "send": true, "scheduled_at": "in 1 hour", } broadcast, _ := client.Broadcasts.Create(params) ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{types::CreateBroadcastOptions, Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let segment_id = "78261eea-8f8b-4381-83c6-79fa7120f1cf"; let from = "Acme "; let subject = "hello world"; let html = "Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}"; let opts = CreateBroadcastOptions::new(segment_id, from, subject).with_html(html); // Create a draft broadcast let _broadcast = resend.broadcasts.create(opts.clone()).await?; // Create and send immediately let _broadcast = resend .broadcasts .create(opts.clone().with_send(true)) .await?; // Create and schedule let _broadcast = resend .broadcasts .create(opts.with_send(true).with_scheduled_at("in 1 hour")) .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} Resend resend = new Resend("re_xxxxxxxxx"); // Create a draft broadcast CreateBroadcastOptions params = CreateBroadcastOptions.builder() .segmentId("78261eea-8f8b-4381-83c6-79fa7120f1cf") .from("Acme ") .subject("hello world") .html("Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}") .build(); CreateBroadcastResponseSuccess data = resend.broadcasts().create(params); // Create and send immediately CreateBroadcastOptions params = CreateBroadcastOptions.builder() .segmentId("78261eea-8f8b-4381-83c6-79fa7120f1cf") .from("Acme ") .subject("hello world") .html("Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}") .send(true) .build(); CreateBroadcastResponseSuccess data = resend.broadcasts().create(params); // Create and schedule CreateBroadcastOptions params = CreateBroadcastOptions.builder() .segmentId("78261eea-8f8b-4381-83c6-79fa7120f1cf") .from("Acme ") .subject("hello world") .html("Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}") .send(true) .scheduledAt("in 1 hour") .build(); CreateBroadcastResponseSuccess data = resend.broadcasts().create(params); ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI // Create a draft broadcast var resp = await resend.BroadcastAddAsync( new BroadcastData() { DisplayName = "Example Broadcast", SegmentId = new Guid( "78261eea-8f8b-4381-83c6-79fa7120f1cf" ), From = "Acme ", Subject = "Hello, world!", HtmlBody = "Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}", } ); Console.WriteLine( "Broadcast Id={0}", resp.Content ); // Create and send immediately var resp = await resend.BroadcastAddAsync( new BroadcastData() { DisplayName = "Example Broadcast", SegmentId = new Guid( "78261eea-8f8b-4381-83c6-79fa7120f1cf" ), From = "Acme ", Subject = "Hello, world!", HtmlBody = "Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}", Send = true, } ); Console.WriteLine( "Broadcast Id={0}", resp.Content ); // Create and schedule var resp = await resend.BroadcastAddAsync( new BroadcastData() { DisplayName = "Example Broadcast", SegmentId = new Guid( "78261eea-8f8b-4381-83c6-79fa7120f1cf" ), From = "Acme ", Subject = "Hello, world!", HtmlBody = "Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}", Send = true, ScheduledAt = DateTime.UtcNow.AddHours( 1 ), } ); Console.WriteLine( "Broadcast Id={0}", resp.Content ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} # Create a draft broadcast curl -X POST 'https://api.resend.com/broadcasts' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $' { "segment_id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", "from": "Acme ", "subject": "hello world", "html": "Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}" }' # Create and send immediately curl -X POST 'https://api.resend.com/broadcasts' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $' { "segment_id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", "from": "Acme ", "subject": "hello world", "html": "Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}", "send": true }' # Create and schedule curl -X POST 'https://api.resend.com/broadcasts' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $' { "segment_id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", "from": "Acme ", "subject": "hello world", "html": "Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}", "send": true, "scheduled_at": "in 1 hour" }' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "id": "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794" } ``` # Delete Broadcast Source: https://resend.com/docs/api-reference/broadcasts/delete-broadcast DELETE /broadcasts/:broadcast_id Remove an existing broadcast. You can only delete broadcasts that are in the `draft` status. In addition, if you delete a broadcast that has already been scheduled to be sent, we will automatically cancel the scheduled delivery and it won't be sent. ## Path Parameters The broadcast ID. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.broadcasts.remove( '559ac32e-9ef5-46fb-82a1-b76b840c0f7b', ); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->broadcasts->remove('559ac32e-9ef5-46fb-82a1-b76b840c0f7b'); ``` ```py Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" resend.Broadcasts.remove(id="559ac32e-9ef5-46fb-82a1-b76b840c0f7b") ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::Broadcasts.remove("559ac32e-9ef5-46fb-82a1-b76b840c0f7b") ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import "github.com/resend/resend-go/v3" func main() { client := resend.NewClient("re_xxxxxxxxx") client.Broadcasts.Remove("559ac32e-9ef5-46fb-82a1-b76b840c0f7b") } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _deleted = resend .broadcasts .delete("559ac32e-9ef5-46fb-82a1-b76b840c0f7b") .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} Resend resend = new Resend("re_xxxxxxxxx"); RemoveBroadcastResponseSuccess data = resend.broadcasts().remove("559ac32e-9ef5-46fb-82a1-b76b840c0f7b"); ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI await resend.BroadcastDeleteAsync( new Guid( "559ac32e-9ef5-46fb-82a1-b76b840c0f7b" ) ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X DELETE 'https://api.resend.com/broadcasts/559ac32e-9ef5-46fb-82a1-b76b840c0f7b' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "broadcast", "id": "559ac32e-9ef5-46fb-82a1-b76b840c0f7b", "deleted": true } ``` # Retrieve Broadcast Source: https://resend.com/docs/api-reference/broadcasts/get-broadcast GET /broadcasts/:broadcast_id Retrieve a single broadcast. You can retrieve broadcasts created via both this API and the Resend dashboard. ## Path Parameters The broadcast ID. See all available `status` types in [the Broadcasts overview](/dashboard/broadcasts/introduction#understand-broadcast-statuses). ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.broadcasts.get( '559ac32e-9ef5-46fb-82a1-b76b840c0f7b', ); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->broadcasts->get('559ac32e-9ef5-46fb-82a1-b76b840c0f7b'); ``` ```py Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" resend.Broadcasts.get(id="559ac32e-9ef5-46fb-82a1-b76b840c0f7b") ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::Broadcasts.get("559ac32e-9ef5-46fb-82a1-b76b840c0f7b") ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import "github.com/resend/resend-go/v3" func main() { client := resend.NewClient("re_xxxxxxxxx") client.Broadcasts.Get("559ac32e-9ef5-46fb-82a1-b76b840c0f7b") } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _broadcast = resend .broadcasts .get("559ac32e-9ef5-46fb-82a1-b76b840c0f7b") .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} Resend resend = new Resend("re_xxxxxxxxx"); GetBroadcastResponseSuccess data = resend.broadcasts().get("559ac32e-9ef5-46fb-82a1-b76b840c0f7b"); ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.BroadcastRetrieveAsync( new Guid( "559ac32e-9ef5-46fb-82a1-b76b840c0f7b" ) ); Console.WriteLine( "Broadcast name={0}", resp.Content.DisplayName ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X GET 'https://api.resend.com/broadcasts/559ac32e-9ef5-46fb-82a1-b76b840c0f7b' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "broadcast", "id": "559ac32e-9ef5-46fb-82a1-b76b840c0f7b", "name": "Announcements", "audience_id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", // now called segment_id "segment_id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", "from": "Acme ", "subject": "hello world", "reply_to": null, "preview_text": "Check out our latest announcements", "html": "

Hello {{{FIRST_NAME|there}}}!

", "text": "Hello {{{FIRST_NAME|there}}}!", "status": "draft", "created_at": "2024-12-01T19:32:22.980Z", "scheduled_at": null, "sent_at": null, "topic_id": "b6d24b8e-af0b-4c3c-be0c-359bbd97381e" } ```
# List Broadcasts Source: https://resend.com/docs/api-reference/broadcasts/list-broadcasts GET /broadcasts Retrieve a list of broadcast. See all available `status` types in [the Broadcasts overview](/dashboard/broadcasts/introduction#understand-broadcast-statuses). ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.broadcasts.list(); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->broadcasts->list(); ``` ```py Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" resend.Broadcasts.list() ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::Broadcasts.list() ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import "github.com/resend/resend-go/v3" func main() { client := resend.NewClient("re_xxxxxxxxx") client.Broadcasts.List() } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result, list_opts::ListOptions}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _broadcasts = resend.broadcasts.list(ListOptions::default()).await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} Resend resend = new Resend("re_xxxxxxxxx"); ListBroadcastsResponseSuccess data = resend.broadcasts().list(); ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.BroadcastListAsync(); Console.WriteLine( "Nr Broadcasts={0}", resp.Content.Count ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X GET 'https://api.resend.com/broadcasts' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "list", "has_more": false, "data": [ { "id": "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794", "audience_id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", // now called segment_id "segment_id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", "status": "draft", "created_at": "2024-11-01T15:13:31.723Z", "scheduled_at": null, "sent_at": null, "topic_id": "b6d24b8e-af0b-4c3c-be0c-359bbd97381e" }, { "id": "559ac32e-9ef5-46fb-82a1-b76b840c0f7b", "audience_id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", // now called segment_id "segment_id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", "status": "sent", "created_at": "2024-12-01T19:32:22.980Z", "scheduled_at": "2024-12-02T19:32:22.980Z", "sent_at": "2024-12-02T19:32:22.980Z", "topic_id": "b6d24b8e-af0b-4c3c-be0c-359bbd97381e" } ] } ``` # Send Broadcast Source: https://resend.com/docs/api-reference/broadcasts/send-broadcast POST /broadcasts/:broadcast_id/send Start sending broadcasts to your audience through the Resend API. You can send broadcasts only if they were created via the API. ## Path Parameters The broadcast ID. ## Body Parameters Schedule email to be sent later. The date should be in natural language (e.g.: `in 1 min`) or ISO 8601 format (e.g: `2024-08-05T11:52:01.858Z`). ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.broadcasts.send( '559ac32e-9ef5-46fb-82a1-b76b840c0f7b', { scheduledAt: 'in 1 min', }, ); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->broadcasts->send('559ac32e-9ef5-46fb-82a1-b76b840c0f7b', [ 'scheduled_at' => 'in 1 min', ]); ``` ```py Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" params: resend.Broadcasts.SendParams = { "broadcast_id": "559ac32e-9ef5-46fb-82a1-b76b840c0f7b", "scheduled_at": "in 1 min" } resend.Broadcasts.send(params) ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" params = { broadcast_id: "559ac32e-9ef5-46fb-82a1-b76b840c0f7b", scheduled_at: "in 1 min" } Resend::Broadcasts.send(params) ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import "github.com/resend/resend-go/v3" func main() { client := resend.NewClient("re_xxxxxxxxx") sendParams := &resend.SendBroadcastRequest{ BroadcastId: "559ac32e-9ef5-46fb-82a1-b76b840c0f7b", ScheduledAt: "in 1 min", } client.Broadcasts.Send(sendParams) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{types::SendBroadcastOptions, Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let opts = SendBroadcastOptions::new("559ac32e-9ef5-46fb-82a1-b76b840c0f7b").with_scheduled_at("in 1 min"); let _broadcast = resend.broadcasts.send(opts).await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} Resend resend = new Resend("re_xxxxxxxxx"); SendBroadcastOptions params = SendBroadcastOptions.builder() .scheduledAt("in 1 min") .build(); SendBroadcastResponseSuccess data = resend.broadcasts().send(params, "498ee8e4-7aa2-4eb5-9f04-4194848049d1"); ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI // Send now await resend.BroadcastSendAsync( new Guid( "559ac32e-9ef5-46fb-82a1-b76b840c0f7b" ) ); // Send in 5 mins await resend.BroadcastScheduleAsync( new Guid( "559ac32e-9ef5-46fb-82a1-b76b840c0f7b" ), DateTime.UtcNow.AddMinutes( 5 ) ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X POST 'https://api.resend.com/broadcasts/559ac32e-9ef5-46fb-82a1-b76b840c0f7b/send' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'{ "scheduled_at": "in 1 min" }' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "id": "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794" } ``` # Update Broadcast Source: https://resend.com/docs/api-reference/broadcasts/update-broadcast PATCH /broadcasts/:broadcast_id Update a broadcast to send to your contacts. ## Path Parameters The ID of the broadcast you want to update. ## Body Parameters The ID of the segment you want to send to. Audiences are now called Segments. Follow the [Migration Guide](/dashboard/segments/migrating-from-audiences-to-segments). Sender email address. To include a friendly name, use the format `"Your Name "`. Email subject. Reply-to email address. For multiple addresses, send as an array of strings. The HTML version of the message. The plain text version of the message. If not provided, the HTML will be used to generate a plain text version. You can opt out of this behavior by setting value to an empty string. The React component used to write the message. *Only available in the Node.js SDK.* The friendly name of the broadcast. Only used for internal reference. The topic ID that the broadcast will be scoped to. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.broadcasts.update( '49a3999c-0ce1-4ea6-ab68-afcd6dc2e794', { html: 'Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}', }, ); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->broadcasts->update('49a3999c-0ce1-4ea6-ab68-afcd6dc2e794', [ 'html' => 'Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}', ]); ``` ```py Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" params: resend.Broadcasts.UpdateParams = { "id": "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794", "html": "Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}" } resend.Broadcasts.update(params) ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" params = { "id": "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794", "html": "Hi #{FIRST_NAME}, you can unsubscribe here: #{RESEND_UNSUBSCRIBE_URL}", } Resend::Broadcasts.update(params) ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import "github.com/resend/resend-go/v3" func main() { client := resend.NewClient("re_xxxxxxxxx") params := &resend.UpdateBroadcastRequest{ Id: "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794", Html: "Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}", } client.Broadcasts.Update(params) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{types::UpdateBroadcastOptions, Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let id = "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794"; let html = "Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}"; let opts = UpdateBroadcastOptions::new().with_html(html); let _broadcast = resend.broadcasts.update(id, opts).await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} Resend resend = new Resend("re_xxxxxxxxx"); UpdateBroadcastOptions params = UpdateBroadcastOptions.builder() .id("49a3999c-0ce1-4ea6-ab68-afcd6dc2e794") .html("Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}") .build(); UpdateBroadcastResponseSuccess data = resend.broadcasts().update(params); ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.BroadcastUpdateAsync( new Guid( "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794" ), new BroadcastUpdateData() { HtmlBody = "Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}", } ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X PATCH 'https://api.resend.com/broadcasts/49a3999c-0ce1-4ea6-ab68-afcd6dc2e794' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'{ "html": "Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}" }' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "id": "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794" } ``` # Create Contact Property Source: https://resend.com/docs/api-reference/contact-properties/create-contact-property POST /contact-properties Create a custom property for your contacts. ## Body Parameters The property key. Max length is `50` characters. Only alphanumeric characters and underscores are allowed. The property type. Possible values: `string` or `number`. The default value to use when the property is not set for a contact. Must match the type specified in the `type` field. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.contactProperties.create({ key: 'company_name', type: 'string', fallbackValue: 'Acme Corp', }); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->contactProperties->create([ 'key' => 'company_name', 'type' => 'string', 'fallback_value' => 'Acme Corp', ]); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = 're_xxxxxxxxx' params = { "key": "company_name", "type": "string", "fallback_value": "Acme Corp", } contact_property = resend.ContactProperties.create(params) ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" property = Resend::ContactProperties.create({ key: "company_name", type: "string", fallback_value: "Acme Corp" }) ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import ( "context" "fmt" "github.com/resend/resend-go/v3" ) func main() { ctx := context.TODO() client := resend.NewClient("re_xxxxxxxxx") params := &resend.CreateContactPropertyRequest{ Key: "company_name", Type: "string", FallbackValue: "Acme Corp", } property, err := client.ContactProperties.CreateWithContext(ctx, params) if err != nil { panic(err) } fmt.Println(property) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{ types::{CreateContactPropertyOptions, PropertyType}, Resend, Result, }; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let contact_property = CreateContactPropertyOptions::new("company_name", PropertyType::String) .with_fallback("Acme Corp"); let _contact_property = resend.contacts.create_property(contact_property).await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); CreateContactPropertyOptions options = CreateContactPropertyOptions.builder() .key("company_name") .type("string") .fallbackValue("Acme Corp") .build(); resend.contactProperties().create(options); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.ContactPropCreateAsync( new ContactPropertyData() { Key = "company_name", PropertyType = ContactPropertyType.String, DefaultValue = "Acme Corp", } ); Console.WriteLine( "Prop Id={0}", resp.Content ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X POST 'https://api.resend.com/contact-properties' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'{ "key": "company_name", "type": "string", "fallback_value": "Acme Corp" }' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "contact_property", "id": "b6d24b8e-af0b-4c3c-be0c-359bbd97381e" } ``` # Delete Contact Property Source: https://resend.com/docs/api-reference/contact-properties/delete-contact-property DELETE /contact-properties/:contact_property_id Remove an existing contact property. ## Path Parameters The Contact Property ID. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.contactProperties.remove( 'b6d24b8e-af0b-4c3c-be0c-359bbd97381e', ); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->contactProperties->remove('b6d24b8e-af0b-4c3c-be0c-359bbd97381'); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = 're_xxxxxxxxx' contact_property = resend.ContactProperties.remove('b6d24b8e-af0b-4c3c-be0c-359bbd97381e') ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::ContactProperties.remove("b6d24b8e-af0b-4c3c-be0c-359bbd97381e") ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import ( "context" "fmt" "github.com/resend/resend-go/v3" ) func main() { ctx := context.TODO() client := resend.NewClient("re_xxxxxxxxx") property, err := client.ContactProperties.RemoveWithContext(ctx, "b6d24b8e-af0b-4c3c-be0c-359bbd97381e") if err != nil { panic(err) } fmt.Println(property) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _deleted = resend .contacts .delete_property("b6d24b8e-af0b-4c3c-be0c-359bbd97381e") .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); resend.contactProperties().remove("b6d24b8e-af0b-4c3c-be0c-359bbd97381e"); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.ContactPropDeleteAsync( new Guid( "b6d24b8e-af0b-4c3c-be0c-359bbd97381e" ) ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X DELETE 'https://api.resend.com/contact-properties/b6d24b8e-af0b-4c3c-be0c-359bbd97381e' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "contact_property", "id": "b6d24b8e-af0b-4c3c-be0c-359bbd97381e", "deleted": true } ``` # Retrieve Contact Property Source: https://resend.com/docs/api-reference/contact-properties/get-contact-property GET /contact-properties/:contact_property_id Retrieve a contact property by its ID. ## Path Parameters The Contact Property ID. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.contactProperties.get( 'b6d24b8e-af0b-4c3c-be0c-359bbd97381e', ); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->contactProperties->get('b6d24b8e-af0b-4c3c-be0c-359bbd97381'); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = 're_xxxxxxxxx' contact_property = resend.ContactProperties.get('b6d24b8e-af0b-4c3c-be0c-359bbd97381e') ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" property = Resend::ContactProperties.get("b6d24b8e-af0b-4c3c-be0c-359bbd97381e") ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import ( "context" "fmt" "github.com/resend/resend-go/v3" ) func main() { ctx := context.TODO() client := resend.NewClient("re_xxxxxxxxx") property, err := client.ContactProperties.GetWithContext(ctx, "b6d24b8e-af0b-4c3c-be0c-359bbd97381e") if err != nil { panic(err) } fmt.Println(property) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _property = resend .contacts .get_property("b6d24b8e-af0b-4c3c-be0c-359bbd97381e") .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); resend.contactProperties().get("b6d24b8e-af0b-4c3c-be0c-359bbd97381e"); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.ContactPropRetrieveAsync( new Guid( "b6d24b8e-af0b-4c3c-be0c-359bbd97381e" ) ); Console.WriteLine( "Prop Id={0}", resp.Content.Id ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X GET 'https://api.resend.com/contact-properties/b6d24b8e-af0b-4c3c-be0c-359bbd97381e' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "contact_property", "id": "b6d24b8e-af0b-4c3c-be0c-359bbd97381e", "key": "company_name", "type": "string", "fallback_value": "Acme Corp", "created_at": "2023-04-08T00:11:13.110779+00:00" } ``` # List Contact Properties Source: https://resend.com/docs/api-reference/contact-properties/list-contact-properties GET /contact-properties Retrieve a list of contact properties. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.contactProperties.list(); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->contactProperties->list(); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = 're_xxxxxxxxx' contact_properties = resend.ContactProperties.list() ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" properties = Resend::ContactProperties.list ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import ( "context" "fmt" "github.com/resend/resend-go/v3" ) func main() { ctx := context.TODO() client := resend.NewClient("re_xxxxxxxxx") properties, err := client.ContactProperties.ListWithContext(ctx) if err != nil { panic(err) } fmt.Println(properties) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{list_opts::ListOptions, Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _contact_properties = resend .contacts .list_properties(ListOptions::default()) .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); resend.contactProperties().list(); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.ContactPropListAsync(); Console.WriteLine( "Nr Props={0}", resp.Content.Data.Count ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X GET 'https://api.resend.com/contact-properties' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "list", "has_more": false, "data": [ { "id": "b6d24b8e-af0b-4c3c-be0c-359bbd97381e", "key": "company_name", "type": "string", "fallback_value": "Acme Corp", "created_at": "2023-04-08T00:11:13.110779+00:00" } ] } ``` # Update Contact Property Source: https://resend.com/docs/api-reference/contact-properties/update-contact-property PATCH /contact-properties/:contact_property_id Update an existing contact property. ## Path Parameters The Contact Property ID. The `key` and `type` fields cannot be changed after creation. This preserves data integrity for existing contact values. ## Body Parameters The default value to use when the property is not set for a contact. Must match the type of the property. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.contactProperties.update({ id: 'b6d24b8e-af0b-4c3c-be0c-359bbd97381e', fallbackValue: 'Example Company', }); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->contactProperties->update('b6d24b8e-af0b-4c3c-be0c-359bbd97381', [ 'fallback_value' => 'Example Company', ]); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = 're_xxxxxxxxx' params = { "id": "b6d24b8e-af0b-4c3c-be0c-359bbd97381e", "fallback_value": "Example Company", } contact_property = resend.ContactProperties.update(params) ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" property = Resend::ContactProperties.update({ id: "b6d24b8e-af0b-4c3c-be0c-359bbd97381e", fallback_value: "Example Company" }) ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import ( "context" "fmt" "github.com/resend/resend-go/v3" ) func main() { ctx := context.TODO() client := resend.NewClient("re_xxxxxxxxx") params := &resend.UpdateContactPropertyRequest{ Id: "b6d24b8e-af0b-4c3c-be0c-359bbd97381e", FallbackValue: "Example Company", } property, err := client.ContactProperties.UpdateWithContext(ctx, params) if err != nil { panic(err) } fmt.Println(property) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{types::ContactPropertyChanges, Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let update = ContactPropertyChanges::default().with_fallback("Example Company"); let _contact_property = resend .contacts .update_property("b6d24b8e-af0b-4c3c-be0c-359bbd97381e", update) .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); UpdateContactPropertyOptions options = UpdateContactPropertyOptions.builder() .id("b6d24b8e-af0b-4c3c-be0c-359bbd97381e") .fallbackValue("Example Company") .build(); resend.contactProperties().update(options); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.ContactPropUpdateAsync( new Guid( "b6d24b8e-af0b-4c3c-be0c-359bbd97381e" ), new ContactPropertyUpdateData() { DefaultValue = "Example Company", } ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X PATCH 'https://api.resend.com/contact-properties/b6d24b8e-af0b-4c3c-be0c-359bbd97381e' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'{ "fallback_value": "Example Company" }' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "contact_property", "id": "b6d24b8e-af0b-4c3c-be0c-359bbd97381e" } ``` # Add Contact to Segment Source: https://resend.com/docs/api-reference/contacts/add-contact-to-segment POST /contacts/:contact_id/segments/:segment_id Add an existing contact to a segment. ## Path Parameters Either `id` or `email` must be provided. The Contact ID. The Contact Email. The Segment ID. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); // Add by contact id const { data, error } = await resend.contacts.segments.add({ contactId: 'e169aa45-1ecf-4183-9955-b1499d5701d3', segmentId: '78261eea-8f8b-4381-83c6-79fa7120f1cf', }); // Add by contact email const { data, error } = await resend.contacts.segments.add({ email: 'steve.wozniak@gmail.com', segmentId: '78261eea-8f8b-4381-83c6-79fa7120f1cf', }); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); // Add by contact id $resend->contacts->segments->add( contact: 'e169aa45-1ecf-4183-9955-b1499d5701d3', segmentId: '78261eea-8f8b-4381-83c6-79fa7120f1cf' ); // Add by contact email $resend->contacts->segments->add( contact: 'steve.wozniak@gmail.com', segmentId: '78261eea-8f8b-4381-83c6-79fa7120f1cf' ); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = 're_xxxxxxxxx' # Add by contact id params = { "segment_id": '78261eea-8f8b-4381-83c6-79fa7120f1cf', "contact_id": 'e169aa45-1ecf-4183-9955-b1499d5701d3', } response = resend.Contacts.Segments.add(params) ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require 'resend' Resend.api_key = 're_xxxxxxxxx' # Add by contact id result = Resend::Contacts::Segments.add( contact_id: 'e169aa45-1ecf-4183-9955-b1499d5701d3', segment_id: '78261eea-8f8b-4381-83c6-79fa7120f1cf' ) # Add by contact email result = Resend::Contacts::Segments.add( email: 'steve.wozniak@gmail.com', segment_id: '78261eea-8f8b-4381-83c6-79fa7120f1cf' ) ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import ( "context" "fmt" "github.com/resend/resend-go/v3" ) func main() { ctx := context.TODO() client := resend.NewClient("re_xxxxxxxxx") // Add by contact id addParams := &resend.AddContactSegmentRequest{ ContactId: "e169aa45-1ecf-4183-9955-b1499d5701d3", SegmentId: "78261eea-8f8b-4381-83c6-79fa7120f1cf", } response, err := client.Contacts.Segments.AddWithContext(ctx, addParams) if err != nil { panic(err) } fmt.Println(response) // Add by contact email addByEmailParams := &resend.AddContactSegmentRequest{ Email: "steve.wozniak@gmail.com", SegmentId: "78261eea-8f8b-4381-83c6-79fa7120f1cf", } response, err = client.Contacts.Segments.AddWithContext(ctx, addByEmailParams) if err != nil { panic(err) } fmt.Println(response) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); // Update by contact id let _contact = resend .contacts .add_contact_segment( "e169aa45-1ecf-4183-9955-b1499d5701d3", "78261eea-8f8b-4381-83c6-79fa7120f1cf", ) .await?; // // Update by contact email let _contact = resend .contacts .add_contact_segment( "steve.wozniak@gmail.com", "78261eea-8f8b-4381-83c6-79fa7120f1cf", ) .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); // Add by contact id AddContactToSegmentOptions optionsById = AddContactToSegmentOptions.builder() .id("e169aa45-1ecf-4183-9955-b1499d5701d3") .segmentId("78261eea-8f8b-4381-83c6-79fa7120f1cf") .build(); resend.contacts().segments().add(optionsById); // Add by contact email AddContactToSegmentOptions optionsByEmail = AddContactToSegmentOptions.builder() .email("steve.wozniak@gmail.com") .segmentId("78261eea-8f8b-4381-83c6-79fa7120f1cf") .build(); resend.contacts().segments().add(optionsByEmail); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI await resend.ContactAddToSegmentAsync( contactId: new Guid( "e169aa45-1ecf-4183-9955-b1499d5701d3" ), segmentId: new Guid( "78261eea-8f8b-4381-83c6-79fa7120f1cf" ) ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} // Update by contact id curl -X POST 'https://api.resend.com/contacts/e169aa45-1ecf-4183-9955-b1499d5701d3/segments/78261eea-8f8b-4381-83c6-79fa7120f1cf' \ -H 'Authorization: Bearer re_xxxxxxxxx' // Update by contact email curl -X POST 'https://api.resend.com/contacts/steve.wozniak@gmail.com/segments/78261eea-8f8b-4381-83c6-79fa7120f1cf' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "id": "78261eea-8f8b-4381-83c6-79fa7120f1cf" } ``` # Create Contact Source: https://resend.com/docs/api-reference/contacts/create-contact POST /contacts Create a contact. ## Body Parameters The email address of the contact. The first name of the contact. The last name of the contact. The Contact's global subscription status. If set to `true`, the contact will be unsubscribed from all Broadcasts. A map of custom property keys and values to create. The property key. The property value. Array of objects. Each object must contain the ID of the segment that you'd like to add the contact to. The segment ID. Array of topic subscriptions for the contact. The topic ID. The subscription status for this topic. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.contacts.create({ email: 'steve.wozniak@gmail.com', firstName: 'Steve', lastName: 'Wozniak', unsubscribed: false, }); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->contacts->create( parameters: [ 'email' => 'steve.wozniak@gmail.com', 'first_name' => 'Steve', 'last_name' => 'Wozniak', 'unsubscribed' => false ] ); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" params: resend.Contacts.CreateParams = { "email": "steve.wozniak@gmail.com", "first_name": "Steve", "last_name": "Wozniak", "unsubscribed": False, } resend.Contacts.create(params) ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" params = { "email": "steve.wozniak@gmail.com", "first_name": "Steve", "last_name": "Wozniak", "unsubscribed": false, } Resend::Contacts.create(params) ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import "github.com/resend/resend-go/v3" func main() { client := resend.NewClient("re_xxxxxxxxx") params := &resend.CreateContactRequest{ Email: "steve.wozniak@gmail.com", FirstName: "Steve", LastName: "Wozniak", Unsubscribed: false, } client.Contacts.Create(params) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{types::CreateContactOptions, Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let contact = CreateContactOptions::new("steve.wozniak@gmail.com") .with_first_name("Steve") .with_last_name("Wozniak") .with_unsubscribed(false); let _contact = resend.contacts.create(contact).await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); CreateContactOptions params = CreateContactOptions.builder() .email("steve.wozniak@gmail.com") .firstName("Steve") .lastName("Wozniak") .unsubscribed(false) .build(); CreateContactResponseSuccess data = resend.contacts().create(params); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.ContactAddAsync( new ContactData() { Email = "steve.wozniak@gmail.com", FirstName = "Steve", LastName = "Wozniak", IsUnsubscribed = false, } ); Console.WriteLine( "Contact Id={0}", resp.Content ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X POST 'https://api.resend.com/contacts' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'{ "email": "steve.wozniak@gmail.com", "first_name": "Steve", "last_name": "Wozniak", "unsubscribed": false }' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "contact", "id": "479e3145-dd38-476b-932c-529ceb705947" } ``` # Delete Contact Source: https://resend.com/docs/api-reference/contacts/delete-contact DELETE /contacts/:contact_id Remove an existing contact. ## Path Parameters Either `id` or `email` must be provided. The Contact ID. The Contact email. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); // Delete by contact id const { data, error } = await resend.contacts.remove({ id: '520784e2-887d-4c25-b53c-4ad46ad38100', }); // Delete by contact email const { data, error } = await resend.contacts.remove({ email: 'acme@example.com', }); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); // Delete by contact id $resend->contacts->remove( id: '520784e2-887d-4c25-b53c-4ad46ad38100' ); // Delete by contact email $resend->contacts->remove( email: 'acme@example.com' ); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" # Delete by contact id resend.Contacts.remove( id="520784e2-887d-4c25-b53c-4ad46ad38100" ) # Delete by contact email resend.Contacts.remove( email="acme@example.com" ) ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" # Delete by contact id Resend::Contacts.remove( id: "520784e2-887d-4c25-b53c-4ad46ad38100" ) # Delete by contact email Resend::Contacts.remove( email: "acme@example.com" ) ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import "github.com/resend/resend-go/v3" func main() { client := resend.NewClient("re_xxxxxxxxx") // Delete by contact id client.Contacts.Remove("520784e2-887d-4c25-b53c-4ad46ad38100") // Delete by contact email client.Contacts.Remove("acme@example.com") } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); // Delete by contact id let _deleted = resend .contacts .delete("520784e2-887d-4c25-b53c-4ad46ad38100") .await?; // Delete by contact email let _deleted = resend .contacts .delete("acme@example.com") .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); // Delete by contact id resend.contacts().remove(ContactRequestOptions.builder() .id("520784e2-887d-4c25-b53c-4ad46ad38100") .build()); // Delete by contact email resend.contacts().remove(ContactRequestOptions.builder() .email("acme@example.com") .build()); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI // By Id await resend.ContactDeleteAsync( contactId: new Guid( "520784e2-887d-4c25-b53c-4ad46ad38100" ) ); // By Email await resend.ContactDeleteByEmailAsync( "acme@example.com" ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} # Delete by contact id curl -X DELETE 'https://api.resend.com/contacts/520784e2-887d-4c25-b53c-4ad46ad38100' \ -H 'Authorization: Bearer re_xxxxxxxxx' # Deleted by contact email curl -X DELETE 'https://api.resend.com/contacts/acme@example.com' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "contact", "contact": "520784e2-887d-4c25-b53c-4ad46ad38100", "deleted": true } ``` # Delete Contact Segment Source: https://resend.com/docs/api-reference/contacts/delete-contact-segment DELETE /contacts/:contact_id/segments/:segment_id Remove an existing contact from a segment. ## Path Parameters Either `id` or `email` must be provided. The Contact ID. The Contact Email. The Segment ID. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); // Remove by contact id const { data, error } = await resend.contacts.segments.remove({ id: 'e169aa45-1ecf-4183-9955-b1499d5701d3', segmentId: '78261eea-8f8b-4381-83c6-79fa7120f1cf', }); // Remove by contact email const { data, error } = await resend.contacts.segments.remove({ email: 'steve.wozniak@gmail.com', segmentId: '78261eea-8f8b-4381-83c6-79fa7120f1cf', }); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); // Remove by contact id $resend->contacts->segments->remove( contact: 'e169aa45-1ecf-4183-9955-b1499d5701d3', segmentId: '78261eea-8f8b-4381-83c6-79fa7120f1cf' ); // Remove by contact email $resend->contacts->segments->remove( contact: 'steve.wozniak@gmail.com', segmentId: '78261eea-8f8b-4381-83c6-79fa7120f1cf' ); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = 're_xxxxxxxxx' # Remove by contact id params = { "segment_id": '78261eea-8f8b-4381-83c6-79fa7120f1cf', "contact_id": 'e169aa45-1ecf-4183-9955-b1499d5701d3', } response = resend.Contacts.Segments.remove(params) ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require 'resend' Resend.api_key = 're_xxxxxxxxx' # Remove by contact id removed = Resend::Contacts::Segments.remove( contact_id: 'e169aa45-1ecf-4183-9955-b1499d5701d3', segment_id: '78261eea-8f8b-4381-83c6-79fa7120f1cf' ) # Remove by contact email removed = Resend::Contacts::Segments.remove( email: 'steve.wozniak@gmail.com', segment_id: '78261eea-8f8b-4381-83c6-79fa7120f1cf' ) ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import ( "context" "fmt" "github.com/resend/resend-go/v3" ) func main() { ctx := context.TODO() client := resend.NewClient("re_xxxxxxxxx") // Remove by contact id removeParams := &resend.RemoveContactSegmentRequest{ ContactId: "e169aa45-1ecf-4183-9955-b1499d5701d3", SegmentId: "78261eea-8f8b-4381-83c6-79fa7120f1cf", } response, err := client.Contacts.Segments.RemoveWithContext(ctx, removeParams) if err != nil { panic(err) } fmt.Println(response) // Remove by contact email removeByEmailParams := &resend.RemoveContactSegmentRequest{ Email: "steve.wozniak@gmail.com", SegmentId: "78261eea-8f8b-4381-83c6-79fa7120f1cf", } response, err = client.Contacts.Segments.RemoveWithContext(ctx, removeByEmailParams) if err != nil { panic(err) } fmt.Println(response) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); // Update by contact id let _contact = resend .contacts .delete_contact_segment( "e169aa45-1ecf-4183-9955-b1499d5701d3", "78261eea-8f8b-4381-83c6-79fa7120f1cf", ) .await?; // // Update by contact email let _contact = resend .contacts .delete_contact_segment( "steve.wozniak@gmail.com", "78261eea-8f8b-4381-83c6-79fa7120f1cf", ) .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); // Remove by contact id RemoveContactFromSegmentOptions optionsById = RemoveContactFromSegmentOptions.builder() .id("e169aa45-1ecf-4183-9955-b1499d5701d3") .segmentId("78261eea-8f8b-4381-83c6-79fa7120f1cf") .build(); resend.contacts().segments().remove(optionsById); // Remove by contact email RemoveContactFromSegmentOptions optionsByEmail = RemoveContactFromSegmentOptions.builder() .email("steve.wozniak@gmail.com") .segmentId("78261eea-8f8b-4381-83c6-79fa7120f1cf") .build(); resend.contacts().segments().remove(optionsByEmail); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI await resend.ContactRemoveFromSegmentAsync( contactId: new Guid( "e169aa45-1ecf-4183-9955-b1499d5701d3" ), segmentId: new Guid( "78261eea-8f8b-4381-83c6-79fa7120f1cf" ) ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} // Update by contact id curl -X DELETE 'https://api.resend.com/contacts/e169aa45-1ecf-4183-9955-b1499d5701d3/segments/78261eea-8f8b-4381-83c6-79fa7120f1cf' \ -H 'Authorization: Bearer re_xxxxxxxxx' // Update by contact email curl -X DELETE 'https://api.resend.com/contacts/steve.wozniak@gmail.com/segments/78261eea-8f8b-4381-83c6-79fa7120f1cf' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", "deleted": true } ``` # Retrieve Contact Source: https://resend.com/docs/api-reference/contacts/get-contact GET /contacts/:contact_id Retrieve a single contact. ## Path Parameters Either `id` or `email` must be provided. The Contact ID. The Contact Email. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); // Get by contact id const { data, error } = await resend.contacts.get({ id: 'e169aa45-1ecf-4183-9955-b1499d5701d3', }); // Get by contact email const { data, error } = await resend.contacts.get({ email: 'steve.wozniak@gmail.com', }); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); // Get by contact id $resend->contacts->get( id: 'e169aa45-1ecf-4183-9955-b1499d5701d3' ); // Get by contact email $resend->contacts->get( email: 'steve.wozniak@gmail.com' ); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" # Get by contact id resend.Contacts.get( id="e169aa45-1ecf-4183-9955-b1499d5701d3", ) # Get by contact email resend.Contacts.get( email="steve.wozniak@gmail.com", ) ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" # Get by contact id params = { "id": "e169aa45-1ecf-4183-9955-b1499d5701d3", } Resend::Contacts.get(params) # Get by contact email params = { "email": "steve.wozniak@gmail.com", } Resend::Contacts.get(params) ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import "github.com/resend/resend-go/v3" func main() { client := resend.NewClient("re_xxxxxxxxx") // Get by contact id client.Contacts.Get("e169aa45-1ecf-4183-9955-b1499d5701d3") // Get by contact email client.Contacts.Get("steve.wozniak@gmail.com") } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); // Get by contact id let _contact = resend .contacts .get("e169aa45-1ecf-4183-9955-b1499d5701d3") .await?; // Get by contact email let _contact = resend .contacts .get("steve.wozniak@gmail.com") .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); // Get by contact id GetContactOptions params = GetContactOptions.builder() .id("e169aa45-1ecf-4183-9955-b1499d5701d3") .build(); // Get by contact email GetContactOptions params = GetContactOptions.builder() .email("steve.wozniak@gmail.com") .build(); GetContactResponseSuccess data = resend.contacts().get(params); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI // Get by contact id var resp1 = await resend.ContactRetrieveAsync( contactId: new Guid( "e169aa45-1ecf-4183-9955-b1499d5701d3" ) ); // Get by contact email var resp2 = await resend.ContactRetrieveByEmailAsync( email: "steve.wozniak@gmail.com" ); Console.WriteLine( "Contact Email={0}", resp2.Content.Email ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} # Get by contact id curl -X GET 'https://api.resend.com/contacts/e169aa45-1ecf-4183-9955-b1499d5701d3' \ -H 'Authorization: Bearer re_xxxxxxxxx' # Get by contact email curl -X GET 'https://api.resend.com/contacts/steve.wozniak@gmail.com' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "contact", "id": "e169aa45-1ecf-4183-9955-b1499d5701d3", "email": "steve.wozniak@gmail.com", "first_name": "Steve", "last_name": "Wozniak", "created_at": "2023-10-06T23:47:56.678Z", "unsubscribed": false, "properties": { "company_name": "Acme Corp", "department": "Engineering" } } ``` # Retrieve Contact Topics Source: https://resend.com/docs/api-reference/contacts/get-contact-topics GET /contacts/:contact_id/topics Retrieve a list of topics subscriptions for a contact. ## Path Parameters Either `id` or `email` must be provided. The Contact ID. The Contact Email. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); // Get by contact id const { data, error } = await resend.contacts.topics.list({ id: 'e169aa45-1ecf-4183-9955-b1499d5701d3', }); // Get by contact email const { data, error } = await resend.contacts.topics.list({ email: 'steve.wozniak@gmail.com', }); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); // Get by contact id $resend->contacts->topics->get('e169aa45-1ecf-4183-9955-b1499d5701d3'); // Get by contact email $resend->contacts->topics->get('steve.wozniak@gmail.com'); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = 're_xxxxxxxxx' # Get by contact id topics = resend.Contacts.Topics.list(contact_id='e169aa45-1ecf-4183-9955-b1499d5701d3') # Get by contact email topics = resend.Contacts.Topics.list(email='steve.wozniak@gmail.com') ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" # Get by contact id contact_topics = Resend::Contacts::Topics.list(id: "e169aa45-1ecf-4183-9955-b1499d5701d3") # Get by contact email contact_topics = Resend::Contacts::Topics.list(id: "steve.wozniak@gmail.com") ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import ( "context" "fmt" "github.com/resend/resend-go/v3" ) func main() { ctx := context.TODO() client := resend.NewClient("re_xxxxxxxxx") // Get by contact id topics, err := client.Contacts.Topics.ListWithContext(ctx, &resend.ListContactTopicsRequest{ ContactId: "e169aa45-1ecf-4183-9955-b1499d5701d3", }) if err != nil { panic(err) } fmt.Println(topics) // Get by contact email topics, err = client.Contacts.Topics.ListWithContext(ctx, &resend.ListContactTopicsRequest{ Email: "steve.wozniak@gmail.com", }) if err != nil { panic(err) } fmt.Println(topics) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{list_opts::ListOptions, Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _topics = resend .contacts .get_contact_topics( "e169aa45-1ecf-4183-9955-b1499d5701d3", ListOptions::default(), ) .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); // Get by contact id resend.contacts().topics().list("e169aa45-1ecf-4183-9955-b1499d5701d3"); // Get by contact email resend.contacts().topics().list("steve.wozniak@gmail.com"); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.ContactListTopicsAsync( new Guid( "e169aa45-1ecf-4183-9955-b1499d5701d3" )); Console.WriteLine( "Nr Topics={0}", resp.Content.Data.Count ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} // Get by contact id curl -X GET 'https://api.resend.com/contacts/e169aa45-1ecf-4183-9955-b1499d5701d3/topics' \ -H 'Authorization: Bearer re_xxxxxxxxx' // Get by contact email curl -X GET 'https://api.resend.com/contacts/steve.wozniak@gmail.com/topics' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "list", "has_more": false, "data": [ { "id": "b6d24b8e-af0b-4c3c-be0c-359bbd97381e", "name": "Product Updates", "description": "New features, and latest announcements.", "subscription": "opt_in" } ] } ``` # List Contact Segments Source: https://resend.com/docs/api-reference/contacts/list-contact-segments GET /contacts/:contact_id/segments Retrieve a list of segments that a contact is part of. ## Path Parameters Either `id` or `email` must be provided. The Contact ID. The Contact Email. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.contacts.segments.list({ id: 'e169aa45-1ecf-4183-9955-b1499d5701d3', }); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->contacts->segments->list( contactId: 'e169aa45-1ecf-4183-9955-b1499d5701d3' ); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = 're_xxxxxxxxx' params = { "contact_id": 'e169aa45-1ecf-4183-9955-b1499d5701d3', } segments = resend.Contacts.Segments.list(params) ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require 'resend' Resend.api_key = 're_xxxxxxxxx' segments = Resend::Contacts::Segments.list( contact_id: 'e169aa45-1ecf-4183-9955-b1499d5701d3' ) ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import ( "context" "github.com/resend/resend-go/v3" ) func main() { client := resend.NewClient("re_xxxxxxxxx") listParams := &resend.ListContactSegmentsRequest{ ContactId: "479e3145-dd38-476b-932c-529ceb705947", } client.Contacts.Segments.List(listParams) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result, list_opts::ListOptions}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _contacts = resend .contacts .list_contact_segment( "e169aa45-1ecf-4183-9955-b1499d5701d3", ListOptions::default() ) .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); resend.contacts().segments().list("e169aa45-1ecf-4183-9955-b1499d5701d3"); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.ContactListSegmentsAsync( new Guid( "e169aa45-1ecf-4183-9955-b1499d5701d3" )); Console.WriteLine( "Nr Segments={0}", resp.Content.Data.Count ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X GET 'https://api.resend.com/contacts/e169aa45-1ecf-4183-9955-b1499d5701d3/segments' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "list", "data": [ { "id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", "name": "Registered Users", "created_at": "2023-10-06T22:59:55.977Z" } ], "has_more": false } ``` # List Contacts Source: https://resend.com/docs/api-reference/contacts/list-contacts GET /contacts Show all contacts. ## Path Parameters The Segment ID to filter contacts by. If provided, only contacts in this Segment will be returned. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.contacts.list(); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->contacts->list(); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" resend.Contacts.list() ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::Contacts.list() ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import "github.com/resend/resend-go/v3" func main() { client := resend.NewClient("re_xxxxxxxxx") client.Contacts.List() } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result, list_opts::ListOptions}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _contacts = resend .contacts .list( ListOptions::default(), ) .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); ListContactsResponseSuccess data = resend.contacts().list(); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.ContactListAsync(); Console.WriteLine( "Nr Contacts={0}", resp.Content.Data.Count ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X GET 'https://api.resend.com/contacts' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "list", "has_more": false, "data": [ { "id": "e169aa45-1ecf-4183-9955-b1499d5701d3", "email": "steve.wozniak@gmail.com", "first_name": "Steve", "last_name": "Wozniak", "created_at": "2023-10-06T23:47:56.678Z", "unsubscribed": false } ] } ``` # Update Contact Source: https://resend.com/docs/api-reference/contacts/update-contact PATCH /contacts/:contact_id Update an existing contact. ## Path Parameters Either `id` or `email` must be provided. The Contact ID. The Contact Email. ## Body Parameters The first name of the contact. The last name of the contact. The Contact's global subscription status. If set to `true`, the contact will be unsubscribed from all Broadcasts. A map of custom property keys and values to update. The property key. The property value. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); // Update by contact id const { data, error } = await resend.contacts.update({ id: 'e169aa45-1ecf-4183-9955-b1499d5701d3', unsubscribed: true, }); // Update by contact email const { data, error } = await resend.contacts.update({ email: 'acme@example.com', unsubscribed: true, }); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); // Update by contact id $resend->contacts->update( id: 'e169aa45-1ecf-4183-9955-b1499d5701d3', parameters: [ 'unsubscribed' => true ] ); // Update by contact email $resend->contacts->update( email: 'acme@example.com', parameters: [ 'unsubscribed' => true ] ); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" # Update by contact id params: resend.Contacts.UpdateParams = { "id": "e169aa45-1ecf-4183-9955-b1499d5701d3", "unsubscribed": True, } resend.Contacts.update(params) # Update by contact email params: resend.Contacts.UpdateParams = { "email": "acme@example.com", "unsubscribed": True, } resend.Contacts.update(params) ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" # Update by contact id params = { "id": "e169aa45-1ecf-4183-9955-b1499d5701d3", "unsubscribed": true, } Resend::Contacts.update(params) # Update by contact email params = { "email": "acme@example.com", "unsubscribed": true, } Resend::Contacts.update(params) ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import "github.com/resend/resend-go/v3" func main() { client := resend.NewClient("re_xxxxxxxxx") // Update by contact id params := &resend.UpdateContactRequest{ Id: "e169aa45-1ecf-4183-9955-b1499d5701d3", Unsubscribed: true, } client.Contacts.Update(params) // Update by contact email params = &resend.UpdateContactRequest{ Email: "acme@example.com", Unsubscribed: true, } client.Contacts.Update(params) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{types::ContactChanges, Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let changes = ContactChanges::new().with_unsubscribed(true); // Update by contact id let _contact = resend .contacts .update("e169aa45-1ecf-4183-9955-b1499d5701d3", changes.clone()) .await?; // Update by contact email let _contact = resend .contacts .update("acme@example.com", changes) .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); // Update by contact id UpdateContactOptions params = UpdateContactOptions.builder() .id("e169aa45-1ecf-4183-9955-b1499d5701d3") .unsubscribed(true) .build(); // Update by contact email UpdateContactOptions params = UpdateContactOptions.builder() .email("acme@example.com") .unsubscribed(true) .build(); UpdateContactResponseSuccess data = resend.contacts().update(params); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI // By Id await resend.ContactUpdateAsync( contactId: new Guid( "e169aa45-1ecf-4183-9955-b1499d5701d3" ), new ContactData() { FirstName = "Stevie", LastName = "Wozniaks", IsUnsubscribed = true, } ); // By Email await resend.ContactUpdateByEmailAsync( "acme@example.com", new ContactData() { FirstName = "Stevie", LastName = "Wozniaks", IsUnsubscribed = true, } ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} # Update by contact id curl -X PATCH 'https://api.resend.com/contacts/520784e2-887d-4c25-b53c-4ad46ad38100' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'{ "unsubscribed": true }' # Update by contact email curl -X PATCH 'https://api.resend.com/contacts/acme@example.com' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'{ "unsubscribed": true }' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "contact", "id": "479e3145-dd38-476b-932c-529ceb705947" } ``` # Update Contact Topics Source: https://resend.com/docs/api-reference/contacts/update-contact-topics PATCH /contacts/:contact_id/topics Update topic subscriptions for a contact. ## Path Parameters Either `id` or `email` must be provided. The Contact ID. The Contact Email. ## Body Parameters Array of topic subscription updates. The Topic ID. The subscription action. Must be either `opt_in` or `opt_out`. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); // Update by contact id const { data, error } = await resend.contacts.topics.update({ id: 'e169aa45-1ecf-4183-9955-b1499d5701d3', topics: [ { id: 'b6d24b8e-af0b-4c3c-be0c-359bbd97381e', subscription: 'opt_out', }, { id: '07d84122-7224-4881-9c31-1c048e204602', subscription: 'opt_in', }, ], }); // Update by contact email const { data, error } = await resend.contacts.topics.update({ email: 'steve.wozniak@gmail.com', topics: [ { id: '07d84122-7224-4881-9c31-1c048e204602', subscription: 'opt_out', }, { id: '07d84122-7224-4881-9c31-1c048e204602', subscription: 'opt_in', }, ], }); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); // Update by contact id $resend->contacts->topics->update('e169aa45-1ecf-4183-9955-b1499d5701d3', [ [ 'id' => '07d84122-7224-4881-9c31-1c048e204602', 'subscription' => 'opt_out', ], [ 'id' => '07d84122-7224-4881-9c31-1c048e204602', 'subscription' => 'opt_in', ], ]); // Update by contact email $resend->contacts->topics->update('steve.wozniak@gmail.com', [ [ 'id' => '07d84122-7224-4881-9c31-1c048e204602', 'subscription' => 'opt_out', ], [ 'id' => '07d84122-7224-4881-9c31-1c048e204602', 'subscription' => 'opt_in', ], ]); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = 're_xxxxxxxxx' # Update by contact id params = { "id": "e169aa45-1ecf-4183-9955-b1499d5701d3", "topics": [ {"id": "b6d24b8e-af0b-4c3c-be0c-359bbd97381e", "subscription": "opt_out"}, {"id": "07d84122-7224-4881-9c31-1c048e204602", "subscription": "opt_in"}, ], } response = resend.Contacts.Topics.update(params) # Update by contact email params_by_email = { "email": "steve.wozniak@gmail.com", "topics": [ {"id": "07d84122-7224-4881-9c31-1c048e204602", "subscription": "opt_out"}, {"id": "07d84122-7224-4881-9c31-1c048e204602", "subscription": "opt_in"}, ], } response = resend.Contacts.Topics.update(params_by_email) ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" # Update by contact id update_params = { id: "e169aa45-1ecf-4183-9955-b1499d5701d3", topics: [ { id: "b6d24b8e-af0b-4c3c-be0c-359bbd97381e", subscription: "opt_out" }, { id: "07d84122-7224-4881-9c31-1c048e204602", subscription: "opt_in" } ] } updated_topics = Resend::Contacts::Topics.update(update_params) # Update by contact email update_params = { email: "steve.wozniak@gmail.com", topics: [ { id: "07d84122-7224-4881-9c31-1c048e204602", subscription: "opt_out" }, { id: "07d84122-7224-4881-9c31-1c048e204602", subscription: "opt_in" } ] } updated_topics = Resend::Contacts::Topics.update(update_params) ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import ( "context" "fmt" "github.com/resend/resend-go/v3" ) func main() { ctx := context.TODO() client := resend.NewClient("re_xxxxxxxxx") // Update by contact id params := &resend.UpdateContactTopicsRequest{ ContactId: "e169aa45-1ecf-4183-9955-b1499d5701d3", Topics: []resend.TopicSubscriptionUpdate{ { Id: "b6d24b8e-af0b-4c3c-be0c-359bbd97381e", Subscription: "opt_out", }, { Id: "07d84122-7224-4881-9c31-1c048e204602", Subscription: "opt_in", }, }, } updatedTopics, err := client.Contacts.Topics.UpdateWithContext(ctx, params) if err != nil { panic(err) } fmt.Println(updatedTopics) // Update by contact email params = &resend.UpdateContactTopicsRequest{ Email: "steve.wozniak@gmail.com", Topics: []resend.TopicSubscriptionUpdate{ { Id: "07d84122-7224-4881-9c31-1c048e204602", Subscription: "opt_out", }, { Id: "b6d24b8e-af0b-4c3c-be0c-359bbd97381e", Subscription: "opt_in", }, }, } updatedTopics, err = client.Contacts.Topics.UpdateWithContext(ctx, params) if err != nil { panic(err) } fmt.Println(updatedTopics) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{ types::{SubscriptionType, UpdateContactTopicOptions}, Resend, Result, }; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let topics = [ UpdateContactTopicOptions::new( "b6d24b8e-af0b-4c3c-be0c-359bbd97381e", SubscriptionType::OptOut, ), UpdateContactTopicOptions::new( "07d84122-7224-4881-9c31-1c048e204602", SubscriptionType::OptIn, ), ]; let _contact = resend .contacts .update_contact_topics("e169aa45-1ecf-4183-9955-b1499d5701d3", topics) .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); // Update by contact id UpdateContactTopicsOptions optionsById = UpdateContactTopicsOptions.builder() .id("e169aa45-1ecf-4183-9955-b1499d5701d3") .topics(ContactTopicOptions.builder() .id("b6d24b8e-af0b-4c3c-be0c-359bbd97381e") .subscription("opt_out") .build(), ContactTopicOptions.builder() .id("07d84122-7224-4881-9c31-1c048e204602") .subscription("opt_in") .build()) .build(); resend.contacts().topics().update(optionsById); // Update by contact email UpdateContactTopicsOptions optionsByEmail = UpdateContactTopicsOptions.builder() .email("steve.wozniak@gmail.com") .topics(ContactTopicOptions.builder() .id("07d84122-7224-4881-9c31-1c048e204602") .subscription("opt_in") .build(), ContactTopicOptions.builder() .id("b6d24b8e-af0b-4c3c-be0c-359bbd97381e") .subscription("opt_out") .build()) .build(); resend.contacts().topics().update(optionsById); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var topics = new List(); topics.Add( new TopicSubscription() { Id = new Guid( "07d84122-7224-4881-9c31-1c048e204602" ), Subscription = SubscriptionType.OptIn, }); topics.Add( new TopicSubscription() { Id = new Guid( "b6d24b8e-af0b-4c3c-be0c-359bbd97381e" ), Subscription = SubscriptionType.OptOut, }); await resend.ContactUpdateTopicsAsync( new Guid( "e169aa45-1ecf-4183-9955-b1499d5701d3" ), topics ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} // Update by contact id curl -X PATCH 'https://api.resend.com/contacts/e169aa45-1ecf-4183-9955-b1499d5701d3/topics' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'[ { "id": "b6d24b8e-af0b-4c3c-be0c-359bbd97381e", "subscription": "opt_out" } ]' // Update by contact email curl -X PATCH 'https://api.resend.com/contacts/steve.wozniak@gmail.com/topics' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'[ { "id": "b6d24b8e-af0b-4c3c-be0c-359bbd97381e", "subscription": "opt_out" } ]' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "id": "b6d24b8e-af0b-4c3c-be0c-359bbd97381e" } ``` # Create Domain Source: https://resend.com/docs/api-reference/domains/create-domain POST /domains Create a domain through the Resend Email API. ## Body Parameters The name of the domain you want to create. The region where emails will be sent from. Possible values: `'us-east-1' | 'eu-west-1' | 'sa-east-1' | 'ap-northeast-1'` For advanced use cases, choose a subdomain for the Return-Path address. The custom return path is used for SPF authentication, DMARC alignment, and handling bounced emails. Defaults to `send` (i.e., `send.yourdomain.tld`). Avoid setting values that could undermine credibility (e.g. `testing`), as they may be exposed to recipients. Learn more about [custom return paths](/dashboard/domains/introduction#custom-return-path). Track the open rate of each email. Track clicks within the body of each HTML email.
  • `opportunistic`: Opportunistic TLS means that it always attempts to make a secure connection to the receiving mail server. If it can't establish a secure connection, it sends the message unencrypted.
  • `enforced`: Enforced TLS on the other hand, requires that the email communication must use TLS no matter what. If the receiving server does not support TLS, the email will not be sent.
Configure the domain capabilities for sending and receiving emails. At least one capability must be enabled. Enable or disable sending emails from this domain. Possible values: `'enabled' | 'disabled'` Enable or disable receiving emails to this domain. Possible values: `'enabled' | 'disabled'` See all available `status` types in [the Domains overview](/dashboard/domains/introduction#understand-a-domain-status). ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.domains.create({ name: 'example.com' }); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->domains->create([ 'name' => 'example.com' ]); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" params: resend.Domains.CreateParams = { "name": "example.com", } resend.Domains.create(params) ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} Resend.api_key = ENV["RESEND_API_KEY"] params = { name: "example.com", } domain = Resend::Domains.create(params) puts domain ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import "github.com/resend/resend-go/v3" func main() { client := resend.NewClient("re_xxxxxxxxx") params := &resend.CreateDomainRequest{ Name: "example.com", } client.Domains.Create(params) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{types::CreateDomainOptions, Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _domain = resend .domains .add(CreateDomainOptions::new("example.com")) .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); CreateDomainOptions params = CreateDomainOptions .builder() .name("example.com").build(); CreateDomainResponse domain = resend.domains().create(params); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.DomainAddAsync( "example.com" ); Console.WriteLine( "Domain Id={0}", resp.Content.Id ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X POST 'https://api.resend.com/domains' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'{ "name": "example.com" }' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "id": "4dd369bc-aa82-4ff3-97de-514ae3000ee0", "name": "example.com", "created_at": "2023-03-28T17:12:02.059593+00:00", "status": "not_started", "capabilities": { "sending": "enabled", "receiving": "disabled" }, "records": [ { "record": "SPF", "name": "send", "type": "MX", "ttl": "Auto", "status": "not_started", "value": "feedback-smtp.us-east-1.amazonses.com", "priority": 10 }, { "record": "SPF", "name": "send", "value": "\"v=spf1 include:amazonses.com ~all\"", "type": "TXT", "ttl": "Auto", "status": "not_started" }, { "record": "DKIM", "name": "nhapbbryle57yxg3fbjytyodgbt2kyyg._domainkey", "value": "nhapbbryle57yxg3fbjytyodgbt2kyyg.dkim.amazonses.com.", "type": "CNAME", "status": "not_started", "ttl": "Auto" }, { "record": "DKIM", "name": "xbakwbe5fcscrhzshpap6kbxesf6pfgn._domainkey", "value": "xbakwbe5fcscrhzshpap6kbxesf6pfgn.dkim.amazonses.com.", "type": "CNAME", "status": "not_started", "ttl": "Auto" }, { "record": "DKIM", "name": "txrcreso3dqbvcve45tqyosxwaegvhgn._domainkey", "value": "txrcreso3dqbvcve45tqyosxwaegvhgn.dkim.amazonses.com.", "type": "CNAME", "status": "not_started", "ttl": "Auto" } ], "region": "us-east-1" } ``` # Delete Domain Source: https://resend.com/docs/api-reference/domains/delete-domain DELETE /domains/:domain_id Remove an existing domain. ## Path Parameters The Domain ID. ```js Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.domains.remove( 'd91cd9bd-1176-453e-8fc1-35364d380206', ); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->domains->remove('d91cd9bd-1176-453e-8fc1-35364d380206'); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" resend.Domains.remove(domain_id="d91cd9bd-1176-453e-8fc1-35364d380206") ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} Resend.api_key = ENV["RESEND_API_KEY"] Resend::Domains.remove("d91cd9bd-1176-453e-8fc1-35364d380206") ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import "github.com/resend/resend-go/v3" func main() { client := resend.NewClient("re_xxxxxxxxx") client.Domains.Remove("d91cd9bd-1176-453e-8fc1-35364d380206") } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _deleted = resend .domains .delete("d91cd9bd-1176-453e-8fc1-35364d380206") .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); RemoveDomainResponse removed = resend.domains().remove("d91cd9bd-1176-453e-8fc1-35364d380206"); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI await resend.DomainDeleteAsync( new Guid( "d91cd9bd-1176-453e-8fc1-35364d380206" ) ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X DELETE 'https://api.resend.com/domains/d91cd9bd-1176-453e-8fc1-35364d380206' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "domain", "id": "d91cd9bd-1176-453e-8fc1-35364d380206", "deleted": true } ``` # Retrieve Domain Source: https://resend.com/docs/api-reference/domains/get-domain GET /domains/:domain_id Retrieve a single domain for the authenticated user. ## Path Parameters The Domain ID. See all available `status` types in [the Domains overview](/dashboard/domains/introduction#understand-a-domain-status). ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.domains.get( 'd91cd9bd-1176-453e-8fc1-35364d380206', ); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->domains->get('d91cd9bd-1176-453e-8fc1-35364d380206'); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" resend.Domains.get(domain_id="d91cd9bd-1176-453e-8fc1-35364d380206") ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::Domains.get "d91cd9bd-1176-453e-8fc1-35364d380206" ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import "github.com/resend/resend-go/v3" func main() { client := resend.NewClient("re_xxxxxxxxx") client.Domains.Get("d91cd9bd-1176-453e-8fc1-35364d380206") } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _domain = resend .domains .get("d91cd9bd-1176-453e-8fc1-35364d380206") .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); Domain domain = resend.domains().get("d91cd9bd-1176-453e-8fc1-35364d380206"); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.DomainRetrieveAsync( new Guid( "d91cd9bd-1176-453e-8fc1-35364d380206" ) ); Console.WriteLine( "Domain Id={0}", resp.Content.Name ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X GET 'https://api.resend.com/domains/d91cd9bd-1176-453e-8fc1-35364d380206' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "domain", "id": "d91cd9bd-1176-453e-8fc1-35364d380206", "name": "example.com", "status": "not_started", "created_at": "2023-04-26T20:21:26.347412+00:00", "region": "us-east-1", "capabilities": { "sending": "enabled", "receiving": "disabled" }, "records": [ { "record": "SPF", "name": "send", "type": "MX", "ttl": "Auto", "status": "not_started", "value": "feedback-smtp.us-east-1.amazonses.com", "priority": 10 }, { "record": "SPF", "name": "send", "value": "\"v=spf1 include:amazonses.com ~all\"", "type": "TXT", "ttl": "Auto", "status": "not_started" }, { "record": "DKIM", "name": "resend._domainkey", "value": "p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDsc4Lh8xilsngyKEgN2S84+21gn+x6SEXtjWvPiAAmnmggr5FWG42WnqczpzQ/mNblqHz4CDwUum6LtY6SdoOlDmrhvp5khA3cd661W9FlK3yp7+jVACQElS7d9O6jv8VsBbVg4COess3gyLE5RyxqF1vYsrEXqyM8TBz1n5AGkQIDAQA2", "type": "TXT", "status": "not_started", "ttl": "Auto" } ] } ``` # List Domains Source: https://resend.com/docs/api-reference/domains/list-domains GET /domains Retrieve a list of domains for the authenticated user. See all available `status` types in [the Domains overview](/dashboard/domains/introduction#understand-a-domain-status). ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.domains.list(); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->domains->list(); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" resend.Domains.list() ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} Resend.api_key = ENV["RESEND_API_KEY"] Resend::Domains.list ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import "github.com/resend/resend-go/v3" func main() { client := resend.NewClient("re_xxxxxxxxx") client.Domains.List() } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result, list_opts::ListOptions}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _domains = resend.domains.list(ListOptions::default()).await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); ListDomainsResponse response = resend.domains().list(); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.DomainListAsync(); Console.WriteLine( "Nr Domains={0}", resp.Content.Count ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X GET 'https://api.resend.com/domains' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "list", "has_more": false, "data": [ { "id": "d91cd9bd-1176-453e-8fc1-35364d380206", "name": "example.com", "status": "not_started", "created_at": "2023-04-26T20:21:26.347412+00:00", "region": "us-east-1", "capabilities": { "sending": "enabled", "receiving": "disabled" } } ] } ``` # Update Domain Source: https://resend.com/docs/api-reference/domains/update-domain PATCH /domains/:domain_id Update an existing domain. ## Path Parameters The Domain ID. ## Body Parameters Track clicks within the body of each HTML email. Track the open rate of each email.
  • `opportunistic`: Opportunistic TLS means that it always attempts to make a secure connection to the receiving mail server. If it can't establish a secure connection, it sends the message unencrypted.
  • `enforced`: Enforced TLS on the other hand, requires that the email communication must use TLS no matter what. If the receiving server does not support TLS, the email will not be sent.
Update the domain capabilities for sending and receiving emails. You can specify one or both fields. Omitted fields will keep their current value. At least one capability must remain enabled. Enable or disable sending emails from this domain. Possible values: `'enabled' | 'disabled'` Enable or disable receiving emails to this domain. Possible values: `'enabled' | 'disabled'` ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.domains.update({ id: 'b8617ad3-b712-41d9-81a0-f7c3d879314e', openTracking: false, clickTracking: true, tls: 'enforced', }); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->domains->update( 'b8617ad3-b712-41d9-81a0-f7c3d879314e', [ 'open_tracking' => false, 'click_tracking' => true, 'tls' => 'enforced', ] ); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" params: resend.Domains.UpdateParams = { "id": "b8617ad3-b712-41d9-81a0-f7c3d879314e", "open_tracking": False, "click_tracking": True, "tls": "enforced", } resend.Domains.update(params) ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} Resend.api_key = "re_xxxxxxxxx" Resend::Domains.update({ id: "b8617ad3-b712-41d9-81a0-f7c3d879314e", open_tracking: false, click_tracking: true, tls: "enforced", }) ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import "github.com/resend/resend-go/v3" func main() { client := resend.NewClient("re_xxxxxxxxx") updateDomainParams := &resend.UpdateDomainRequest{ OpenTracking: false, ClickTracking: true, Tls: resend.Enforced, } client.Domains.Update("b8617ad3-b712-41d9-81a0-f7c3d879314e", updateDomainParams) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{types::{DomainChanges, Tls}, Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let changes = DomainChanges::new() .with_open_tracking(false) .with_click_tracking(true) .with_tls(Tls::Enforced); let _domain = resend .domains .update("b8617ad3-b712-41d9-81a0-f7c3d879314e", changes) .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} Resend resend = new Resend("re_xxxxxxxxx"); UpdateDomainOptions params = UpdateDomainOptions.builder() .id("b8617ad3-b712-41d9-81a0-f7c3d879314e") .openTracking(false) .clickTracking(true) .tls(Tls.ENFORCED) .build(); resend.domains().update(params); ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI await resend.DomainUpdateAsync( new Guid( "b8617ad3-b712-41d9-81a0-f7c3d879314e" ), new DomainUpdateData() { TrackOpen = false, TrackClicks = true, TlsMode = TlsMode.Enforced, } ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X PATCH 'https://api.resend.com/domains/b8617ad3-b712-41d9-81a0-f7c3d879314e' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'{ "open_tracking": false, "click_tracking": true, "tls": "enforced" }' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "domain", "id": "b8617ad3-b712-41d9-81a0-f7c3d879314e" } ``` # Verify Domain Source: https://resend.com/docs/api-reference/domains/verify-domain POST /domains/:domain_id/verify Verify an existing domain. Calling this API endpoint triggers an **asynchronous domain verification process**. The domain will be temporarily marked as `pending` regardless of its current status while the verification is in progress. Since this request initiates the complete domain verification cycle, it will trigger `domain.updated` webhook events as the domain status changes during the verification process. ## Path Parameters The Domain ID. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.domains.verify( 'd91cd9bd-1176-453e-8fc1-35364d380206', ); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->domains->verify('d91cd9bd-1176-453e-8fc1-35364d380206'); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" resend.Domains.verify(domain_id="d91cd9bd-1176-453e-8fc1-35364d380206") ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} Resend.api_key = ENV["RESEND_API_KEY"] Resend::Domains.verify("d91cd9bd-1176-453e-8fc1-35364d380206") ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import "github.com/resend/resend-go/v3" func main() { client := resend.NewClient("re_xxxxxxxxx") client.Domains.Verify("d91cd9bd-1176-453e-8fc1-35364d380206") } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); resend .domains .verify("d91cd9bd-1176-453e-8fc1-35364d380206") .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); VerifyDomainResponse verified = resend.domains().verify("d91cd9bd-1176-453e-8fc1-35364d380206"); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.DomainVerifyAsync( new Guid( "d91cd9bd-1176-453e-8fc1-35364d380206" ) ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X POST 'https://api.resend.com/domains/d91cd9bd-1176-453e-8fc1-35364d380206/verify' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "domain", "id": "d91cd9bd-1176-453e-8fc1-35364d380206" } ``` # Cancel Email Source: https://resend.com/docs/api-reference/emails/cancel-email POST /emails/:email_id/cancel Cancel a scheduled email. ## Path Parameters The Email ID. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.emails.cancel( '49a3999c-0ce1-4ea6-ab68-afcd6dc2e794', ); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->emails->cancel('49a3999c-0ce1-4ea6-ab68-afcd6dc2e794'); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" resend.Emails.cancel(email_id="49a3999c-0ce1-4ea6-ab68-afcd6dc2e794") ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::Emails.cancel("49a3999c-0ce1-4ea6-ab68-afcd6dc2e794") ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import ( "fmt" "github.com/resend/resend-go/v3" ) func main() { client := resend.NewClient("re_xxxxxxxxx") canceled, err := client.Emails.Cancel("49a3999c-0ce1-4ea6-ab68-afcd6dc2e794") if err != nil { panic(err) } fmt.Println(canceled.Id) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _canceled = resend .emails .cancel("49a3999c-0ce1-4ea6-ab68-afcd6dc2e794") .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); CancelEmailResponse canceled = resend .emails() .cancel("49a3999c-0ce1-4ea6-ab68-afcd6dc2e794"); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI await resend.EmailCancelAsync( new Guid( "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794" ) ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X POST 'https://api.resend.com/emails/49a3999c-0ce1-4ea6-ab68-afcd6dc2e794/cancel' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "email", "id": "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794" } ``` # List Attachments Source: https://resend.com/docs/api-reference/emails/list-email-attachments GET /emails/:email_id/attachments Retrieve a list of attachments from a sent email. ## Path Parameters The Email ID. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.emails.attachments.list({ emailId: '4ef9a417-02e9-4d39-ad75-9611e0fcc33c', }); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->emails->attachments->list( emailId: '4ef9a417-02e9-4d39-ad75-9611e0fcc33c' ); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = 're_xxxxxxxxx' attachments = resend.Emails.Attachments.list( email_id='4ef9a417-02e9-4d39-ad75-9611e0fcc33c' ) ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require 'resend' Resend.api_key = 're_xxxxxxxxx' Resend::Emails::Attachments.list( email_id: "4ef9a417-02e9-4d39-ad75-9611e0fcc33c" ) ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} import ( "context" "github.com/resend/resend-go/v3" ) func main() { client := resend.NewClient("re_xxxxxxxxx") client.Emails.ListAttachmentsWithContext( context.TODO(), "4ef9a417-02e9-4d39-ad75-9611e0fcc33c", ) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{list_opts::ListOptions, Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _email = resend .emails .list_attachments( "4ef9a417-02e9-4d39-ad75-9611e0fcc33c", ListOptions::default(), ) .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); ListAttachmentsResponse response = resend.emails().listAttachments( "4ef9a417-02e9-4d39-ad75-9611e0fcc33c" ); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.EmailAttachmentListAsync( new Guid( "4ef9a417-02e9-4d39-ad75-9611e0fcc33c" )); Console.WriteLine( "Nr Attachments={0}", resp.Content.Data.Count ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X GET 'https://api.resend.com/emails/4ef9a417-02e9-4d39-ad75-9611e0fcc33c/attachments' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "list", "has_more": false, "data": [ { "id": "2a0c9ce0-3112-4728-976e-47ddcd16a318", "filename": "avatar.png", "size": 4096, "content_type": "image/png", "content_disposition": "inline", "content_id": "img001", "download_url": "https://outbound-cdn.resend.com/4ef9a417-02e9-4d39-ad75-9611e0fcc33c/attachments/2a0c9ce0-3112-4728-976e-47ddcd16a318?some-params=example&signature=sig-123", "expires_at": "2025-10-17T14:29:41.521Z" } ] } ``` # List Sent Emails Source: https://resend.com/docs/api-reference/emails/list-emails GET /emails Retrieve a list of emails sent by your team. You can list all emails sent by your team. The list returns references to individual emails. If needed, you can use the `id` of an email to retrieve the email HTML to plain text using the [Retrieve Email](/api-reference/emails/retrieve-email) endpoint or the [Retrieve Attachments](/api-reference/emails/list-email-attachments) endpoint to get an email's attachments. This endpoint only returns emails sent by your team. If you need to list emails received by your domain, use the [List Received Emails](/api-reference/emails/list-received-emails) endpoint. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.emails.list(); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->emails->list(); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" resend.Emails.list() ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} Resend.api_key = "re_xxxxxxxxx" emails = Resend::Emails.list puts emails ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import ( "context" "github.com/resend/resend-go/v3" ) func main() { ctx := context.TODO() client := resend.NewClient("re_xxxxxxxxx") paginatedResp, err := client.Emails.ListWithOptions(ctx, nil) if err != nil { panic(err) } if paginatedResp.HasMore { opts := &resend.ListOptions{ After: &paginatedResp.Data[len(paginatedResp.Data)-1].ID, } client.Emails.ListWithOptions(ctx, opts) } } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{list_opts::ListOptions, Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _emails = resend.emails.list(ListOptions::default()).await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); ListEmailsResponseSuccess emails = resend.emails().list(); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.EmailListAsync(); Console.WriteLine( "Count={0}", resp.Content.Data.Count ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X GET 'https://api.resend.com/emails' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "list", "has_more": false, "data": [ { "id": "4ef9a417-02e9-4d39-ad75-9611e0fcc33c", "to": ["delivered@resend.dev"], "from": "Acme ", "created_at": "2023-04-03T22:13:42.674981+00:00", "subject": "Hello World", "bcc": null, "cc": null, "reply_to": null, "last_event": "delivered", "scheduled_at": null }, { "id": "3a9f8c2b-1e5d-4f8a-9c7b-2d6e5f8a9c7b", "to": ["user@example.com"], "from": "Acme ", "created_at": "2023-04-03T21:45:12.345678+00:00", "subject": "Welcome to Acme", "bcc": null, "cc": null, "reply_to": null, "last_event": "opened", "scheduled_at": null } ] } ``` # List Attachments Source: https://resend.com/docs/api-reference/emails/list-received-email-attachments GET /emails/receiving/:email_id/attachments Retrieve a list of attachments from a received email. ## Path Parameters The Email ID. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.emails.receiving.attachments.list({ emailId: '4ef9a417-02e9-4d39-ad75-9611e0fcc33c', }); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->emails->receiving->attachments->list( emailId: '4ef9a417-02e9-4d39-ad75-9611e0fcc33c' ); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = 're_xxxxxxxxx' attachments = resend.Emails.Receiving.Attachments.list( email_id='4ef9a417-02e9-4d39-ad75-9611e0fcc33c' ) ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require 'resend' Resend.api_key = 're_xxxxxxxxx' attachments = Resend::Emails::Receiving::Attachments.list( email_id: '4ef9a417-02e9-4d39-ad75-9611e0fcc33c' ) ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} import ( "context" "github.com/resend/resend-go/v3" ) func main() { client := resend.NewClient("re_xxxxxxxxx") client.Emails.Receiving.ListAttachmentsWithContext( context.TODO(), "4ef9a417-02e9-4d39-ad75-9611e0fcc33c", ) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{list_opts::ListOptions, Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _email = resend .receiving .list_attachments( "4ef9a417-02e9-4d39-ad75-9611e0fcc33c", ListOptions::default(), ) .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); ListAttachmentsResponse response = resend.receiving().listAttachments( "4ef9a417-02e9-4d39-ad75-9611e0fcc33c" ); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.ReceivedEmailAttachmentListAsync( new Guid( "4ef9a417-02e9-4d39-ad75-9611e0fcc33c" )); Console.WriteLine( "Nr Attachments={0}", resp.Content.Data.Count ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X GET 'https://api.resend.com/emails/receiving/4ef9a417-02e9-4d39-ad75-9611e0fcc33c/attachments' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "list", "has_more": false, "data": [ { "id": "2a0c9ce0-3112-4728-976e-47ddcd16a318", "filename": "avatar.png", "size": 4096, "content_type": "image/png", "content_disposition": "inline", "content_id": "img001", "download_url": "https://inbound-cdn.resend.com/4ef9a417-02e9-4d39-ad75-9611e0fcc33c/attachments/2a0c9ce0-3112-4728-976e-47ddcd16a318?some-params=example&signature=sig-123", "expires_at": "2025-10-17T14:29:41.521Z" } ] } ``` # List Received Emails Source: https://resend.com/docs/api-reference/emails/list-received-emails GET /emails/receiving Retrieve a list of received emails for the authenticated user. You can list all emails received by your team. The list returns references to individual emails. If needed, you can use the `id` of an email to retrieve the email HTML to plain text using the [Retrieve Received Email](/api-reference/emails/retrieve-received-email) endpoint or the [Retrieve Received Attachment](/api-reference/emails/retrieve-received-email-attachment) endpoint to get an email's attachments. This endpoint only returns emails received by your team. If you need to list emails sent by your team, use the [List Sent Emails](/api-reference/emails/list-emails) endpoint. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.emails.receiving.list(); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->emails->receiving->list(); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" resend.Emails.Receiving.list() ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::Emails::Receiving.list() ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} import ( "context" "github.com/resend/resend-go/v3" ) func main() { client := resend.NewClient("re_xxxxxxxxx") client.Emails.Receiving.ListWithContext(context.TODO()) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{list_opts::ListOptions, Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _email = resend.receiving.list(ListOptions::default()).await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); ListReceivedEmailsResponse response = resend.receiving().list(); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.ReceivedEmailListAsync(); Console.WriteLine( "Nr Received={0}", resp.Content.Data.Count ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X GET 'https://api.resend.com/emails/receiving' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "list", "has_more": true, "data": [ { "id": "a39999a6-88e3-48b1-888b-beaabcde1b33", "to": ["recipient@example.com"], "from": "sender@example.com", "created_at": "2025-10-09 14:37:40.951732+00", "subject": "Hello World", "bcc": [], "cc": [], "reply_to": [], "message_id": "<111-222-333@email.provider.example.com>", "attachments": [ { "filename": "example.txt", "content_type": "text/plain", "content_id": null, "content_disposition": "attachment", "id": "47e999c7-c89c-4999-bf32-aaaaa1c3ff21", "size": 13 } ] } ] } ``` # Retrieve Email Source: https://resend.com/docs/api-reference/emails/retrieve-email GET /emails/:email_id Retrieve a single email. ## Path Parameters The Email ID. See all available `last_event` types in [the Email Events overview](/dashboard/emails/introduction#understand-email-events). ```js Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.emails.get( '37e4414c-5e25-4dbc-a071-43552a4bd53b', ); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->emails->get('37e4414c-5e25-4dbc-a071-43552a4bd53b'); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" resend.Emails.get(email_id="4ef9a417-02e9-4d39-ad75-9611e0fcc33c") ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} Resend.api_key = "re_xxxxxxxxx" email = Resend::Emails.get("4ef9a417-02e9-4d39-ad75-9611e0fcc33c") puts email ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import "github.com/resend/resend-go/v3" func main() { client := resend.NewClient("re_xxxxxxxxx") client.Emails.Get("4ef9a417-02e9-4d39-ad75-9611e0fcc33c") } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _email = resend .emails .get("4ef9a417-02e9-4d39-ad75-9611e0fcc33c") .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); Email email = resend.emails().get("4ef9a417-02e9-4d39-ad75-9611e0fcc33c"); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.EmailRetrieveAsync( new Guid( "4ef9a417-02e9-4d39-ad75-9611e0fcc33c" ) ); Console.WriteLine( "Subject={0}", resp.Content.Subject ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X GET 'https://api.resend.com/emails/4ef9a417-02e9-4d39-ad75-9611e0fcc33c' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "email", "id": "4ef9a417-02e9-4d39-ad75-9611e0fcc33c", "to": ["delivered@resend.dev"], "from": "Acme ", "created_at": "2023-04-03T22:13:42.674981+00:00", "subject": "Hello World", "html": "Congrats on sending your first email!", "text": null, "bcc": [], "cc": [], "reply_to": [], "last_event": "delivered", "scheduled_at": null, "tags": [ { "name": "category", "value": "confirm_email" } ] } ``` # Retrieve Attachment Source: https://resend.com/docs/api-reference/emails/retrieve-email-attachment GET /emails/:email_id/attachments/:attachment_id Retrieve a single attachment from a sent email. ## Path Parameters The Attachment ID. The Email ID. ```js Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.emails.attachments.get({ id: '2a0c9ce0-3112-4728-976e-47ddcd16a318', emailId: '4ef9a417-02e9-4d39-ad75-9611e0fcc33c', }); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->emails->attachments->get( id: '2a0c9ce0-3112-4728-976e-47ddcd16a318', emailId: '4ef9a417-02e9-4d39-ad75-9611e0fcc33c' ); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = 're_xxxxxxxxx' attachment = resend.Emails.Attachments.get( email_id='4ef9a417-02e9-4d39-ad75-9611e0fcc33c', attachment_id='2a0c9ce0-3112-4728-976e-47ddcd16a318' ) ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require 'resend' Resend.api_key = 're_xxxxxxxxx' Resend::Emails::Attachments.get( id: "2a0c9ce0-3112-4728-976e-47ddcd16a318", email_id: "4ef9a417-02e9-4d39-ad75-9611e0fcc33c" ) ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} import ( "context" "github.com/resend/resend-go/v3" ) func main() { client := resend.NewClient("re_xxxxxxxxx") client.Emails.GetAttachmentWithContext( context.TODO(), "4ef9a417-02e9-4d39-ad75-9611e0fcc33c", "2a0c9ce0-3112-4728-976e-47ddcd16a318", ) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _email = resend .emails .get_attachment( "2a0c9ce0-3112-4728-976e-47ddcd16a318", "4ef9a417-02e9-4d39-ad75-9611e0fcc33c", ) .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); AttachmentResponse attachment = resend.emails().getAttachment( "4ef9a417-02e9-4d39-ad75-9611e0fcc33c", "2a0c9ce0-3112-4728-976e-47ddcd16a318" ); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.EmailAttachmentRetrieveAsync( emailId: new Guid( "4ef9a417-02e9-4d39-ad75-9611e0fcc33c" ), attachmentId: new Guid( "2a0c9ce0-3112-4728-976e-47ddcd16a318" ) ); Console.WriteLine( "URL={0}", resp.Content.DownloadUrl ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X GET 'https://api.resend.com/emails/4ef9a417-02e9-4d39-ad75-9611e0fcc33c/attachments/2a0c9ce0-3112-4728-976e-47ddcd16a318' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "attachment", "id": "2a0c9ce0-3112-4728-976e-47ddcd16a318", "filename": "avatar.png", "size": 4096, "content_type": "image/png", "content_disposition": "inline", "content_id": "img001", "download_url": "https://outbound-cdn.resend.com/4ef9a417-02e9-4d39-ad75-9611e0fcc33c/attachments/2a0c9ce0-3112-4728-976e-47ddcd16a318?some-params=example&signature=sig-123", "expires_at": "2025-10-17T14:29:41.521Z" } ``` # Retrieve Received Email Source: https://resend.com/docs/api-reference/emails/retrieve-received-email GET /emails/receiving/:email_id Retrieve a single received email. ## Path Parameters The ID for the received email. ## Response Parameters Raw email content download information. Contains a signed URL to download the original email file including all attachments. Signed CloudFront URL to download the raw email file. ISO 8601 timestamp indicating when the download URL expires. ```js Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.emails.receiving.get( '37e4414c-5e25-4dbc-a071-43552a4bd53b', ); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->emails->receiving->get('37e4414c-5e25-4dbc-a071-43552a4bd53b'); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" resend.Emails.Receiving.get(email_id="37e4414c-5e25-4dbc-a071-43552a4bd53b") ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::Emails::Receiving.get("37e4414c-5e25-4dbc-a071-43552a4bd53b") ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} import ( "context" "github.com/resend/resend-go/v3" ) func main() { client := resend.NewClient("re_xxxxxxxxx") client.Emails.Receiving.GetWithContext( context.TODO(), "37e4414c-5e25-4dbc-a071-43552a4bd53b", ) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _email = resend .receiving .get("37e4414c-5e25-4dbc-a071-43552a4bd53b") .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); ReceivedEmail email = resend.receiving().get("37e4414c-5e25-4dbc-a071-43552a4bd53b"); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.ReceivedEmailRetrieveAsync( new Guid( "4ef9a417-02e9-4d39-ad75-9611e0fcc33c" ) ); Console.WriteLine( "Subject={0}", resp.Content.Subject ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X GET 'https://api.resend.com/emails/receiving/4ef9a417-02e9-4d39-ad75-9611e0fcc33c' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "email", "id": "4ef9a417-02e9-4d39-ad75-9611e0fcc33c", "to": ["delivered@resend.dev"], "from": "Acme ", "created_at": "2023-04-03T22:13:42.674981+00:00", "subject": "Hello World", "html": "Congrats on sending your first email!", "text": null, "headers": { "return-path": "lucas.costa@resend.com", "mime-version": "1.0" }, "bcc": [], "cc": [], "reply_to": [], "message_id": "", "raw": { "download_url": "https://example.resend.com/receiving/raw/054da427-439a-4e91-b785-e4fb1966285f?Signature=...", "expires_at": "2023-04-03T23:13:42.674981+00:00" }, "attachments": [ { "id": "2a0c9ce0-3112-4728-976e-47ddcd16a318", "filename": "avatar.png", "content_type": "image/png", "content_disposition": "inline", "content_id": "img001" }, { "id": "3b1d0df1-4223-5839-087f-54eedd27b419", "filename": "document.pdf", "content_type": "application/pdf", "content_disposition": null, "content_id": null } ] } ``` # Retrieve Attachment Source: https://resend.com/docs/api-reference/emails/retrieve-received-email-attachment GET /emails/receiving/:email_id/attachments/:attachment_id Retrieve a single attachment from a received email. ## Path Parameters The Attachment ID. The Email ID. ```js Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.emails.receiving.attachments.get({ id: '2a0c9ce0-3112-4728-976e-47ddcd16a318', emailId: '4ef9a417-02e9-4d39-ad75-9611e0fcc33c', }); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->emails->receiving->attachments->get( id: '2a0c9ce0-3112-4728-976e-47ddcd16a318', emailId: '4ef9a417-02e9-4d39-ad75-9611e0fcc33c' ); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = 're_xxxxxxxxx' attachment = resend.Emails.Receiving.Attachments.get( email_id='4ef9a417-02e9-4d39-ad75-9611e0fcc33c', attachment_id='2a0c9ce0-3112-4728-976e-47ddcd16a318' ) ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require 'resend' Resend.api_key = 're_xxxxxxxxx' attachment = Resend::Emails::Receiving::Attachments.get( id: '2a0c9ce0-3112-4728-976e-47ddcd16a318', email_id: '4ef9a417-02e9-4d39-ad75-9611e0fcc33c' ) ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} import ( "context" "github.com/resend/resend-go/v3" ) func main() { client := resend.NewClient("re_xxxxxxxxx") client.Emails.Receiving.GetAttachmentWithContext( context.TODO(), "4ef9a417-02e9-4d39-ad75-9611e0fcc33c", "2a0c9ce0-3112-4728-976e-47ddcd16a318", ) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _email = resend .receiving .get_attachment( "2a0c9ce0-3112-4728-976e-47ddcd16a318", "4ef9a417-02e9-4d39-ad75-9611e0fcc33c", ) .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); AttachmentDetails attachment = resend.receiving().getAttachment( "4ef9a417-02e9-4d39-ad75-9611e0fcc33c", "2a0c9ce0-3112-4728-976e-47ddcd16a318" ); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.ReceivedEmailAttachmentRetrieveAsync( emailId: new Guid( "4ef9a417-02e9-4d39-ad75-9611e0fcc33c" ), attachmentId: new Guid( "2a0c9ce0-3112-4728-976e-47ddcd16a318" ) ); Console.WriteLine( "URL={0}", resp.Content.DownloadUrl ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X GET 'https://api.resend.com/emails/receiving/4ef9a417-02e9-4d39-ad75-9611e0fcc33c/attachments/2a0c9ce0-3112-4728-976e-47ddcd16a318' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "attachment", "id": "2a0c9ce0-3112-4728-976e-47ddcd16a318", "filename": "avatar.png", "size": 4096, "content_type": "image/png", "content_disposition": "inline", "content_id": "img001", "download_url": "https://inbound-cdn.resend.com/4ef9a417-02e9-4d39-ad75-9611e0fcc33c/attachments/2a0c9ce0-3112-4728-976e-47ddcd16a318?some-params=example&signature=sig-123", "expires_at": "2025-10-17T14:29:41.521Z" } ``` # Send Batch Emails Source: https://resend.com/docs/api-reference/emails/send-batch-emails POST /emails/batch Trigger up to 100 batch emails at once. Instead of sending one email per HTTP request, we provide a batching endpoint that permits you to send up to 100 emails in a single API call. ## Body Parameters Sender email address. To include a friendly name, use the format `"Your Name "`. Recipient email address. For multiple addresses, send as an array of strings. Max 50. Email subject. Bcc recipient email address. For multiple addresses, send as an array of strings. Cc recipient email address. For multiple addresses, send as an array of strings. Reply-to email address. For multiple addresses, send as an array of strings. The HTML version of the message. The plain text version of the message. If not provided, the HTML will be used to generate a plain text version. You can opt out of this behavior by setting value to an empty string. The React component used to write the message. *Only available in the Node.js SDK.* Custom headers to add to the email. The topic ID to receive the email. * If the recipient is a contact and has opted-in to the topic, the email is sent. * If the recipient is a contact and has opted-out of the topic, the email is not sent and will be marked as failed. * If the recipient is not a contact, the email is sent if the topic default subscription value is set to `opt-in`. Each email address (to, cc, bcc) is checked and handled separately. Custom data passed in key/value pairs. [See examples](/dashboard/emails/tags). The name of the email tag. It can only contain ASCII letters (a–z, A–Z), numbers (0–9), underscores (\_), or dashes (-). It can contain no more than 256 characters. The value of the email tag. It can only contain ASCII letters (a–z, A–Z), numbers (0–9), underscores (\_), or dashes (-). It can contain no more than 256 characters. To send using a template, provide a `template` object with: * `id`: the id *or* the alias of the published template * `variables`: an object with a key for each variable (if applicable) If a `template` is provided, you cannot send `html`, `text`, or `react` in the payload, otherwise the API will return a validation error. When sending a template, the payload for `from`, `subject`, and `reply_to` take precedence over the template's defaults for these fields. If the template does not provide a default value for these fields, you must provide them in the payload. The id of the published email template. Required if `template` is provided. Only published templates can be used when sending emails. Template variables object with key/value pairs. ```ts theme={"theme":{"light":"github-light","dark":"vesper"}} variables: { CTA: 'Sign up now', CTA_LINK: 'https://example.com/signup' } ``` When sending the template, the HTML will be parsed. If all the variables used in the template were provided, the email will be sent. If not, the call will throw a validation error. See the [errors reference](/api-reference/errors) for more details or [learn more about templates](/dashboard/templates/introduction). The key of the variable. May only contain ASCII letters (a–z, A–Z), numbers (0–9), and underscores (\_). The following variable names are reserved and cannot be used: `FIRST_NAME`, `LAST_NAME`, `EMAIL`, `UNSUBSCRIBE_URL`. It can contain no more than 50 characters. The value of the variable. Observe these technical limitations: * `string`: maximum length of 2,000 characters * `number`: not greater than 2^53 - 1 ## Headers Add an idempotency key to prevent duplicated emails. * Should be **unique per API request** * Idempotency keys expire after **24 hours** * Have a maximum length of **256 characters** [Learn more about idempotency keys →](/dashboard/emails/idempotency-keys) ## Limitations The `attachments` and `scheduled_at` fields are not supported yet. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.batch.send([ { from: 'Acme ', to: ['foo@gmail.com'], subject: 'hello world', html: '

it works!

', }, { from: 'Acme ', to: ['bar@outlook.com'], subject: 'world hello', html: '

it works!

', }, ]); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->batch->send([ [ 'from' => 'Acme ', 'to' => ['foo@gmail.com'], 'subject' => 'hello world', 'html' => '

it works!

', ], [ 'from' => 'Acme ', 'to' => ['bar@outlook.com'], 'subject' => 'world hello', 'html' => '

it works!

', ] ]); ``` ```py Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend from typing import List resend.api_key = "re_xxxxxxxxx" params: List[resend.Emails.SendParams] = [ { "from": "Acme ", "to": ["foo@gmail.com"], "subject": "hello world", "html": "

it works!

", }, { "from": "Acme ", "to": ["bar@outlook.com"], "subject": "world hello", "html": "

it works!

", } ] resend.Batch.send(params) ``` ```rb Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = 're_xxxxxxxxx' params = [ { "from": "Acme ", "to": ["foo@gmail.com"], "subject": "hello world", "html": "

it works!

", }, { "from": "Acme ", "to": ["bar@outlook.com"], "subject": "world hello", "html": "

it works!

", } ] Resend::Batch.send(params) ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import ( "fmt" "os" "github.com/resend/resend-go/v3" ) func main() { ctx := context.TODO() client := resend.NewClient("re_xxxxxxxxx") var batchEmails = []*resend.SendEmailRequest{ { From: "Acme ", To: []string{"foo@gmail.com"}, Subject: "hello world", Html: "

it works!

", }, { From: "Acme ", To: []string{"bar@outlook.com"}, Subject: "world hello", Html: "

it works!

", }, } sent, err := client.Batch.SendWithContext(ctx, batchEmails) if err != nil { panic(err) } fmt.Println(sent.Data) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::types::CreateEmailBaseOptions; use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let emails = vec![ CreateEmailBaseOptions::new( "Acme ", vec!["foo@gmail.com"], "hello world", ) .with_html("

it works!

"), CreateEmailBaseOptions::new( "Acme ", vec!["bar@outlook.com"], "world hello", ) .with_html("

it works!

"), ]; let _emails = resend.batch.send(emails).await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); CreateEmailOptions firstEmail = CreateEmailOptions.builder() .from("Acme ") .to("foo@gmail.com") .subject("hello world") .html("

it works!

") .build(); CreateEmailOptions secondEmail = CreateEmailOptions.builder() .from("Acme ") .to("bar@outlook.com") .subject("world hello") .html("

it works!

") .build(); CreateBatchEmailsResponse data = resend.batch().send( Arrays.asList(firstEmail, secondEmail) ); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var mail1 = new EmailMessage() { From = "Acme ", To = "foo@gmail.com", Subject = "hello world", HtmlBody = "

it works!

", }; var mail2 = new EmailMessage() { From = "Acme ", To = "bar@outlook.com", Subject = "hello world", HtmlBody = "

it works!

", }; var resp = await resend.EmailBatchAsync( [ mail1, mail2 ] ); Console.WriteLine( "Nr Emails={0}", resp.Content.Count ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X POST 'https://api.resend.com/emails/batch' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'[ { "from": "Acme ", "to": ["foo@gmail.com"], "subject": "hello world", "html": "

it works!

" }, { "from": "Acme ", "to": ["bar@outlook.com"], "subject": "world hello", "html": "

it works!

" } ]' ```
```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "data": [ { "id": "ae2014de-c168-4c61-8267-70d2662a1ce1" }, { "id": "faccb7a5-8a28-4e9a-ac64-8da1cc3bc1cb" } ] } ``` # Send Email Source: https://resend.com/docs/api-reference/emails/send-email POST /emails Start sending emails through the Resend Email API. ## Body Parameters Sender email address. To include a friendly name, use the format `"Your Name "`. Recipient email address. For multiple addresses, send as an array of strings. Max 50. Email subject. Bcc recipient email address. For multiple addresses, send as an array of strings. Cc recipient email address. For multiple addresses, send as an array of strings. Schedule email to be sent later. The date should be in natural language (e.g.: `in 1 min`) or ISO 8601 format (e.g: `2024-08-05T11:52:01.858Z`). [See examples](/dashboard/emails/schedule-email) Reply-to email address. For multiple addresses, send as an array of strings. The HTML version of the message. The plain text version of the message. If not provided, the HTML will be used to generate a plain text version. You can opt out of this behavior by setting value to an empty string. The React component used to write the message. *Only available in the Node.js SDK.* Custom headers to add to the email. The topic ID to receive the email. * If the recipient is a contact and has opted-in to the topic, the email is sent. * If the recipient is a contact and has opted-out of the topic, the email is not sent and will be marked as failed. * If the recipient is not a contact, the email is sent if the topic default subscription value is set to `opt-in`. Each email address (to, cc, bcc) is checked and handled separately. Filename and content of attachments (max 40MB per email, after Base64 encoding of the attachments). [See examples](/dashboard/emails/attachments) Content of an attached file, passed as a buffer or Base64 string. Name of attached file. Path where the attachment file is hosted Content type for the attachment, if not set will be derived from the filename property You can embed images using the content id parameter for the attachment. To show the image, you need to include the ID in the `src` attribute of the `img` tag (e.g., ``) of your HTML. [Learn about inline images](/dashboard/emails/embed-inline-images). Custom data passed in key/value pairs. [See examples](/dashboard/emails/tags). The name of the email tag. It can only contain ASCII letters (a–z, A–Z), numbers (0–9), underscores (\_), or dashes (-). It can contain no more than 256 characters. The value of the email tag. It can only contain ASCII letters (a–z, A–Z), numbers (0–9), underscores (\_), or dashes (-). It can contain no more than 256 characters. To send using a template, provide a `template` object with: * `id`: the id *or* the alias of the published template * `variables`: an object with a key for each variable (if applicable) If a `template` is provided, you cannot send `html`, `text`, or `react` in the payload, otherwise the API will return a validation error. When sending a template, the payload for `from`, `subject`, and `reply_to` take precedence over the template's defaults for these fields. If the template does not provide a default value for these fields, you must provide them in the payload. The id of the published email template. Required if `template` is provided. Only published templates can be used when sending emails. Template variables object with key/value pairs. ```ts theme={"theme":{"light":"github-light","dark":"vesper"}} variables: { CTA: 'Sign up now', CTA_LINK: 'https://example.com/signup' } ``` When sending the template, the HTML will be parsed. If all the variables used in the template were provided, the email will be sent. If not, the call will throw a validation error. See the [errors reference](/api-reference/errors) for more details or [learn more about templates](/dashboard/templates/introduction). The key of the variable. May only contain ASCII letters (a–z, A–Z), numbers (0–9), and underscores (\_). The following variable names are reserved and cannot be used: `FIRST_NAME`, `LAST_NAME`, `EMAIL`, `UNSUBSCRIBE_URL`. It can contain no more than 50 characters. The value of the variable. Observe these technical limitations: * `string`: maximum length of 2,000 characters * `number`: not greater than 2^53 - 1 ## Headers Add an idempotency key to prevent duplicated emails. * Should be **unique per API request** * Idempotency keys expire after **24 hours** * Have a maximum length of **256 characters** [Learn more](/dashboard/emails/idempotency-keys) ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.emails.send({ from: 'Acme ', to: ['delivered@resend.dev'], subject: 'hello world', html: '

it works!

', replyTo: 'onboarding@resend.dev', }); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->emails->send([ 'from' => 'Acme ', 'to' => ['delivered@resend.dev'], 'subject' => 'hello world', 'html' => '

it works!

', 'reply_to': 'onboarding@resend.dev' ]); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" params: resend.Emails.SendParams = { "from": "Acme ", "to": ["delivered@resend.dev"], "subject": "hello world", "html": "

it works!

", "reply_to": "onboarding@resend.dev" } email = resend.Emails.send(params) print(email) ``` ```rb Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" params = { "from": "Acme ", "to": ["delivered@resend.dev"], "subject": "hello world", "html": "

it works!

", "reply_to": "onboarding@resend.dev" } sent = Resend::Emails.send(params) puts sent ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import ( "context" "fmt" "github.com/resend/resend-go/v3" ) func main() { ctx := context.TODO() client := resend.NewClient("re_xxxxxxxxx") params := &resend.SendEmailRequest{ From: "Acme ", To: []string{"delivered@resend.dev"}, Subject: "hello world", Html: "

it works!

", ReplyTo: "onboarding@resend.dev" } sent, err := client.Emails.SendWithContext(ctx, params) if err != nil { panic(err) } fmt.Println(sent.Id) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::types::{CreateEmailBaseOptions}; use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let from = "Acme "; let to = ["delivered@resend.dev"]; let subject = "hello world"; let html = "

it works!

"; let reply_to = "onboarding@resend.dev"; let email = CreateEmailBaseOptions::new(from, to, subject) .with_html(html); let _email = resend.emails.send(email).await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); CreateEmailOptions params = CreateEmailOptions.builder() .from("Acme ") .to("delivered@resend.dev") .subject("hello world") .html("

it works!

") .replyTo("onboarding@resend.dev") .build(); CreateEmailResponse data = resend.emails().send(params); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.EmailSendAsync( new EmailMessage() { From = "Acme ", To = "delivered@resend.dev", Subject = "hello world", HtmlBody = "

it works!

", ReplyTo = "onboarding@resend.dev", } ); Console.WriteLine( "Email Id={0}", resp.Content ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X POST 'https://api.resend.com/emails' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'{ "from": "Acme ", "to": ["delivered@resend.dev"], "subject": "hello world", "html": "

it works!

", "reply_to": "onboarding@resend.dev" }' ```
```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "id": "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794" } ``` # Update Email Source: https://resend.com/docs/api-reference/emails/update-email PATCH /emails/:email_id Update a scheduled email. ## Path Parameters The Email ID. ## Body Parameters Schedule email to be sent later. The date should be in ISO 8601 format (e.g: 2024-08-05T11:52:01.858Z). ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const oneMinuteFromNow = new Date(Date.now() + 1000 * 60).toISOString(); const { data, error } = await resend.emails.update({ id: '49a3999c-0ce1-4ea6-ab68-afcd6dc2e794', scheduledAt: oneMinuteFromNow, }); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $oneMinuteFromNow = (new DateTime())->modify('+1 minute')->format(DateTime::ISO8601); $resend->emails->update('49a3999c-0ce1-4ea6-ab68-afcd6dc2e794', [ 'scheduled_at' => $oneMinuteFromNow ]); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend from datetime import datetime, timedelta resend.api_key = "re_xxxxxxxxx" one_minute_from_now = (datetime.now() + timedelta(minutes=1)).isoformat() update_params: resend.Emails.UpdateParams = { "id": "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794", "scheduled_at": one_minute_from_now } resend.Emails.update(params=update_params) ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" one_minute_from_now = (Time.now + 1 * 60).strftime("%Y-%m-%dT%H:%M:%S.%L%z") update_params = { "email_id": "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794", "scheduled_at": one_minute_from_now } Resend::Emails.update(update_params) ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import ( "time" "github.com/resend/resend-go/v3" ) func main() { client := resend.NewClient("re_xxxxxxxxx") oneMinuteFromNow := time.Now().Add(time.Minute * time.Duration(1)) oneMinuteFromNowIso := oneMinuteFromNow.Format("2006-01-02T15:04:05-0700") updateParams := &resend.UpdateEmailRequest{ Id: "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794", ScheduledAt: oneMinuteFromNowIso, } client.Emails.Update(updateParams) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use chrono::{Local, TimeDelta}; use resend_rs::types::UpdateEmailOptions; use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let one_minute_from_now = Local::now() .checked_add_signed(TimeDelta::minutes(1)) .unwrap() .to_rfc3339(); let update = UpdateEmailOptions::new() .with_scheduled_at(&one_minute_from_now); let _email = resend .emails .update("49a3999c-0ce1-4ea6-ab68-afcd6dc2e794", update) .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); String oneMinuteFromNow = Instant .now() .plus(1, ChronoUnit.MINUTES) .toString(); UpdateEmailOptions updateParams = UpdateEmailOptions.builder() .scheduledAt(oneMinuteFromNow) .build(); UpdateEmailResponse data = resend.emails().update("49a3999c-0ce1-4ea6-ab68-afcd6dc2e794", updateParams); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI await resend.EmailRescheduleAsync( new Guid( "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794" ), DateTime.UtcNow.AddMinutes( 1 ) ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X PATCH 'https://api.resend.com/emails/49a3999c-0ce1-4ea6-ab68-afcd6dc2e794' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'{ "scheduled_at": "2024-08-05T11:52:01.858Z" }' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "email", "id": "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794" } ``` # Errors Source: https://resend.com/docs/api-reference/errors Troubleshoot problems with this comprehensive breakdown of all error codes. ## Error schema We use standard HTTP response codes for success and failure notifications, and our errors are further classified by type. ### `invalid_idempotency_key` * **Status:** 400 * **Message:** The key must be between 1-256 chars. * **Suggested action:** Retry with a valid idempotency key. ### `validation_error` * **Status:** 400 * **Message:** We found an error with one or more fields in the request. * **Suggested action:** The message will contain more details about what field and error were found. ### `missing_api_key` * **Status:** 401 * **Message:** Missing API key in the authorization header. * **Suggested action:** Include the following header in the request: `Authorization: Bearer YOUR_API_KEY`. ### `restricted_api_key` * **Status:** 401 * **Message:** This API key is restricted to only send emails. * **Suggested action:** Make sure the API key has `Full access` to perform actions other than sending emails. ### `invalid_api_key` * **Status:** 403 * **Message:** API key is invalid. * **Suggested action:** Make sure the API key is correct or generate a new [API key in the dashboard](https://resend.com/api-keys). ### `validation_error` * **Status:** 403 * **Message:** You can only send testing emails to your own email address (`youremail@domain.com`). To send emails to other recipients, please verify a domain at resend.com/domains, and change the `from` address to an email using this domain. * **Suggested action:** In [Resend's Domain page](https://resend.com/domains), add and verify a domain for which you have DNS access. This allows you to send emails to addresses beyond your own. [Learn more about resolving this error](/knowledge-base/403-error-resend-dev-domain). ### `validation_error` * **Status:** 403 * **Message:** The `domain.com` domain is not verified. Please, add and verify your domain. * **Suggested action:** Make sure the domain in your API request's `from` field matches a domain you've verified in Resend. Update your API request to use your verified domain, or add and verify the domain you're trying to use. [Learn more about resolving this error](/knowledge-base/403-error-domain-mismatch). ### `validation_error` * **Status:** 403 * **Message:** The `example.com` domain has been registered already. * **Suggested action:** Verify you are signed in to the correct Resend account and check whether a teammate already added the domain. If you still cannot access it, [contact support](https://resend.com/help). [Learn more about resolving this error](/knowledge-base/domain-already-registered). ### `not_found` * **Status:** 404 * **Message:** The requested endpoint does not exist. * **Suggested action:** Change your request URL to match a valid API endpoint. ### `method_not_allowed` * **Status:** 405 * **Message:** Method is not allowed for the requested path. * **Suggested action:** Change your API endpoint to use a valid method. ### `invalid_idempotent_request` * **Status:** 409 * **Message:** Same idempotency key used with a different request payload. * **Suggested action:** Change your idempotency key or payload. ### `concurrent_idempotent_requests` * **Status:** 409 * **Message:** Same idempotency key used while original request is still in progress. * **Suggested action:** Try the request again later. ### `invalid_attachment` * **Status:** 422 * **Message:** Attachment must have either a `content` or `path`. * **Suggested action:** Attachments must either have a `content` (strings, Buffer, or Stream contents) or `path` to a remote resource (better for larger attachments). ### `invalid_from_address` * **Status:** 422 * **Message:** Invalid `from` field. * **Suggested action:** Make sure the `from` field is valid. The email address needs to follow the `email@example.com` or `Name ` format. ### `invalid_access` * **Status:** 422 * **Message:** Access must be "full\_access" | "sending\_access". * **Suggested action:** Make sure the API key has necessary permissions. ### `invalid_parameter` * **Status:** 422 * **Message:** The `parameter` must be a valid UUID. * **Suggested action:** Check the value and make sure it's valid. ### `invalid_region` * **Status:** 422 * **Message:** Region must be "us-east-1" | "eu-west-1" | "sa-east-1". * **Suggested action:** Make sure the correct region is selected. ### `missing_required_field` * **Status:** 422 * **Message:** The request body is missing one or more required fields. * **Suggested action:** Check the error message to see the list of missing fields. ### `monthly_quota_exceeded` * **Status:** 429 * **Message:** You have reached your monthly email quota. * **Suggested action:** [Upgrade your plan](https://resend.com/settings/billing) to increase the monthly email quota. Both sent and received emails count towards this quota. ### `daily_quota_exceeded` * **Status:** 429 * **Message:** You have reached your daily email quota. * **Suggested action:** [Upgrade your plan](https://resend.com/settings/billing) to remove the daily quota limit or wait until 24 hours have passed. Both sent and received emails count towards this quota. ### `rate_limit_exceeded` * **Status:** 429 * **Message:** Too many requests. Please limit the number of requests per second. Or [contact support](https://resend.com/contact) to increase rate limit. * **Suggested action:** You should read the [response headers](./introduction#rate-limit) and reduce the rate at which you request the API. This can be done by introducing a queue mechanism or reducing the number of concurrent requests per second. If you have specific requirements, [contact support](https://resend.com/contact) to request a rate increase. ### `security_error` * **Status:** 451 * **Message:** We may have found a security issue with the request. * **Suggested action:** The message will contain more details. [Contact support](https://resend.com/contact) for more information. ### `application_error` * **Status:** 500 * **Message:** An unexpected error occurred. * **Suggested action:** Try the request again later. If the error does not resolve, check our [status page](https://resend-status.com) for service updates. ### `internal_server_error` * **Status:** 500 * **Message:** An unexpected error occurred. * **Suggested action:** Try the request again later. If the error does not resolve, check our [status page](https://resend-status.com) for service updates. # Introduction Source: https://resend.com/docs/api-reference/introduction Understand general concepts, response codes, and authentication strategies. ## Base URL The Resend API is built on **REST** principles. We enforce **HTTPS** in every request to improve data security, integrity, and privacy. The API does not support **HTTP**. All requests contain the following base URL: ``` https://api.resend.com ``` ## Authentication To authenticate you need to add an *Authorization* header with the contents of the header being `Bearer re_xxxxxxxxx` where `re_xxxxxxxxx` is your [API Key](https://resend.com/api-keys). ``` Authorization: Bearer re_xxxxxxxxx ``` ## User-Agent All API requests must include a `User-Agent` header. Requests without this header will be rejected with a `403` status code. Most HTTP clients and all [Resend SDKs](/sdks) include this header automatically, but if you're making direct HTTP requests, make sure to set it: ``` User-Agent: my-app/1.0 ``` If you're getting a `403` error with error code `1010` despite having a valid API key, a missing `User-Agent` header is likely the cause. See [Error 1010](/knowledge-base/403-error-1010) for more details. ## Response codes Resend uses standard HTTP codes to indicate the success or failure of your requests. In general, `2xx` HTTP codes correspond to success, `4xx` codes are for user-related failures, and `5xx` codes are for infrastructure issues. | Status | Description | | ------ | --------------------------------------- | | `200` | Successful request. | | `400` | Check that the parameters were correct. | | `401` | The API key used was missing. | | `403` | The API key used was invalid. | | `404` | The resource was not found. | | `429` | The rate limit was exceeded. | | `5xx` | Indicates an error with Resend servers. | Check [Error Codes](/api-reference/errors) for a comprehensive breakdown of all possible API errors. ## Rate limit The default maximum rate limit is **2 requests per second per team**. This limit applies across all API keys associated with your team. This number can be increased for trusted senders by request. You can view your team's current rate limit on the [Settings Usage page](https://resend.com/settings/usage). After that, you'll hit the rate limit and receive a `429` response error code. Learn more about our [rate limits](/api-reference/rate-limit). ## FAQ Some endpoints support cursor-based pagination to help you browse through large datasets efficiently. Check our [pagination guide](/api-reference/pagination) for detailed information on how to use pagination parameters. Currently, there's no versioning system in place. We plan to add versioning via calendar-based headers in the future. # Pagination Source: https://resend.com/docs/api-reference/pagination Learn how pagination works in the Resend API. ## Overview Several Resend API endpoints support **cursor-based pagination** to help you efficiently browse through large datasets. You can safely navigate lists with guaranteed stability, even if new objects are created or deleted while you're still requesting pages. Paginated endpoints responses include: * `object`: always set to `list`. * `has_more`: indicates whether there are more elements available. * `data`: the list of returned items. You can navigate through the results using the following parameters: * `limit`: the number of items to return per page. * `after`: the cursor to use to get the next page of results. * `before`: the cursor to use to get the previous page of results. Use the `id` of objects as the cursor for pagination. The cursor itself is *excluded* from the results. For an example, see [pagination strategies below](#strategies). ## Currently-supported endpoints Existing list endpoints can optionally return paginated results: * [List Domains](/api-reference/domains/list-domains) * [List API Keys](/api-reference/api-keys/list-api-keys) * [List Broadcasts](/api-reference/broadcasts/list-broadcasts) * [List Segments](/api-reference/segments/list-segments) * [List Contacts](/api-reference/contacts/list-contacts) * [List Receiving Emails](/api-reference/emails/list-received-emails) * [List Receiving Email Attachments](/api-reference/emails/list-received-email-attachments) Note that for these endpoints, the `limit` parameter is optional. If you do not provide a `limit`, all items will be returned in a single response. Newer list endpoints always return paginated results: * [List Emails](/api-reference/emails/list-emails) * [List Templates](/api-reference/templates/list-templates) * [List Topics](/api-reference/topics/list-topics) ## Parameters All paginated endpoints support the following query parameters: The number of items to return per page. Default is `20`, maximum is `100`, and minimum is `1`. The cursor after which to start retrieving items. To get the next page, use the ID of the last item from the current page. This will return the page that **starts after** the object with this ID (excluding the passed ID itself). The cursor before which to start retrieving items. To get the previous page, use the ID of the first item from the current page. This will return the page that **ends before** the object with this ID (excluding the passed ID itself). You can only use either `after` or `before`, not both simultaneously. ## Response Format Paginated endpoints return responses in the following format: ```json Response Format theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "list", "has_more": true, "data": [ /* Array of resources */ ] } ``` Always set to `list` for paginated responses. Indicates whether there are more items available beyond the current page. An array containing the actual resources for the current page. ## Strategies ### Forward Pagination To paginate forward through results (newer to older items), use the `after` parameter with the ID of the **last item** from the current page: ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} const resend = new Resend('re_xxxxxxxxx'); // First page const { data: firstPage } = await resend.contacts.list({ limit: 50 }); // Second page (if has_more is true) if (firstPage.has_more) { const lastId = firstPage.data[firstPage.data.length - 1].id; const { data: secondPage } = await resend.contacts.list({ limit: 50, after: lastId, }); } ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); // First page $firstPage = $resend->contacts->list(['limit' => 50]); // Second page (if has_more is true) if ($firstPage['has_more']) { $lastId = end($firstPage['data'])['id']; $secondPage = $resend->contacts->list([ 'limit' => 50, 'after' => $lastId ]); } ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" # First page first_page = resend.Contacts.list(limit=50) # Second page (if has_more is true) if first_page['has_more']: last_id = first_page['data'][-1]['id'] second_page = resend.Contacts.list(limit=50, after=last_id) ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} Resend.api_key = "re_xxxxxxxxx" # First page first_page = Resend::Contacts.list(limit: 50) # Second page (if has_more is true) if first_page['has_more'] last_id = first_page['data'].last['id'] second_page = Resend::Contacts.list(limit: 50, after: last_id) end ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import "github.com/resend/resend-go/v3" func main() { client := resend.NewClient("re_xxxxxxxxx") // First page firstPage, err := client.Contacts.List(&resend.ListContactsRequest{ Limit: 50, }) // Second page (if has_more is true) if firstPage.HasMore { lastId := firstPage.Data[len(firstPage.Data)-1].ID client.Contacts.List(&resend.ListContactsRequest{ Limit: 50, After: lastId, }) } } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result, types::ListContactOptions}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); // First page let list_opts = ListContactOptions::default().with_limit(50); let first_page = resend.emails.list(list_opts).await?; // Second page (if has_more is true) if first_page.has_more { let last_id = &first_page.data.last().unwrap().id; let list_opts = ListContactOptions::default() .with_limit(10) .list_after(last_id); let second_page = resend.contacts.list(list_opts).await?; } Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); // First page ListEmailsResponse firstPage = resend.emails().list(10); // Second page (if has_more is true) if (firstPage.getHasMore()) { String lastId = firstPage.getData().get(firstPage.getData().size() - 1).getId(); ListContactsResponse secondPage = resend.contacts().list(50, lastId, null); } } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; using System.Linq; IResend resend = ResendClient.Create("re_xxxxxxxxx"); // First page var firstPage = await resend.EmailListAsync( new PaginatedQuery() { Limit = 50, }); // Second page (if has_more is true) if (firstPage.Content.HasMore) { var lastId = firstPage.Content.Data.Last().Id; var secondPage = await resend.EmailListAsync( new PaginatedQuery() { Limit = 50, After = lastId.ToString(), }); } ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} # First page curl -X GET 'https://api.resend.com/contacts?limit=50' \ -H 'Authorization: Bearer re_xxxxxxxxx' # Second page curl -X GET 'https://api.resend.com/contacts?limit=50&after=LAST_ID_FROM_PREVIOUS_PAGE' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ### Backward Pagination To paginate backward through results (older to newer items), use the `before` parameter with the ID of the **first item** from the current page (or the most recent ID you have in your system): ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} const resend = new Resend('re_xxxxxxxxx'); // Start from a specific point and go backward const page = await resend.contacts.list({ limit: 50, before: 'some-contact-id', }); if (page.data.has_more) { const firstId = page.data.data[0].id; const previousPage = await resend.contacts.list({ limit: 50, before: firstId, }); } ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); // Start from a specific point and go backward $page = $resend->contacts->list([ 'limit' => 50, 'before' => 'some-contact-id' ]); if ($page['has_more']) { $firstId = $page['data'][0]['id']; $previousPage = $resend->contacts->list([ 'limit' => 50, 'before' => $firstId ]); } ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" # Start from a specific point and go backward page = resend.Contacts.list(limit=50, before="some-contact-id") if page["has_more"]: first_id = page["data"][0]["id"] previous_page = resend.Contacts.list(limit=50, before=first_id) ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} Resend.api_key = "re_xxxxxxxxx" # Start from a specific point and go backward page = Resend::Contacts.list(limit: 50, before: 'some-contact-id') if page['has_more'] first_id = page['data'].first['id'] previous_page = Resend::Contacts.list(limit: 50, before: first_id) end ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import "github.com/resend/resend-go/v3" func main() { client := resend.NewClient("re_xxxxxxxxx") // Start from a specific point and go backward page, err := client.Contacts.List(&resend.ListContactsRequest{ Limit: resend.Int(50), Before: resend.String("some-contact-id"), }) if page.HasMore { firstId := page.Data[0].ID client.Contacts.List(&resend.ListContactsRequest{ Limit: resend.Int(50), Before: resend.String(firstId), }) } } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result, types::ListContactOptions}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); // Start from a specific point and go backward let list_opts = ListContactOptions::default() .with_limit(50) .list_before("some-email-id"); let page = resend.contacts.list(list_opts).await?; if page.has_more { let first_id = &page.data.first().unwrap().id; let list_opts = ListContactOptions::default() .with_limit(10) .list_before(first_id); let previous_page = resend.contacts.list(list_opts).await?; } Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); // Start from a specific point and go backward ListContactsResponse page = resend.contacts().list(50, null, "some-contact-id"); if (page.getHasMore()) { String firstId = page.getData().get(0).getId(); ListContactsResponse previousPage = resend.contacts().list(50, null, firstId); } } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; using System.Linq; IResend resend = ResendClient.Create("re_xxxxxxxxx"); // Start from a specific point and go backward var page = await resend.EmailListAsync( new PaginatedQuery() { Limit = 50, Before = "some-email-id", }); if (page.Content.HasMore) { var firstId = page.Content.Data.First().Id; var prevPage = await resend.EmailListAsync( new PaginatedQuery() { Limit = 50, Before = firstId.ToString(), }); } ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X GET 'https://api.resend.com/contacts?limit=50&before=some-contact-id' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ## Best Practices Choose a `limit` that balances performance and usability. Smaller pages are good for real-time applications, while larger pages (hundreds of items) work better for bulk processing. Always check the `has_more` field before attempting to fetch additional pages. This prevents unnecessary API calls when you've reached the end of the dataset. Be mindful of API rate limits when paginating through large datasets. Implement appropriate delays or batching strategies if processing many pages. ## Error Handling Pagination requests may return the following validation errors: | Error | Description | | ------------------ | --------------------------------------------------- | | `validation_error` | Invalid cursor format or limit out of range (1-100) | | `validation_error` | Both `before` and `after` parameters provided | Example error response: ```json Error Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "name": "validation_error", "statusCode": 422, "message": "The pagination limit must be a number between 1 and 100. See https://resend.com/docs/pagination for more information." } ``` # Usage Limits Source: https://resend.com/docs/api-reference/rate-limit Learn about API rate limits, email sending quotas, and contact quotas. The Resend API enforces three types of limits: **rate limits** control how many API requests you can make per second, **email quotas** control the total number of emails you can send per day and month, and **contact quotas** control how many marketing contacts you can store. ## Rate Limits ### Response Headers The response headers describe your current rate limit following every request in conformance with the [sixth IETF standard draft](https://datatracker.ietf.org/doc/html/draft-ietf-httpapi-ratelimit-headers-06): | Header name | Description | | --------------------- | ------------------------------------------------------------------- | | `ratelimit-limit` | Maximum number of requests allowed within a window. | | `ratelimit-remaining` | How many requests you have left within the current window. | | `ratelimit-reset` | How many seconds until the limits are reset. | | `retry-after` | How many seconds you should wait before making a follow-up request. | The default maximum rate limit is **2 requests per second per team**. This limit applies across all API keys associated with your team. This number can be increased for trusted senders upon request. You can view your team's current rate limit on the [Settings Usage page](https://resend.com/settings/usage). After that, you'll hit the rate limit and receive a `429` response error code. You can find all 429 responses by filtering for 429 at the [Resend Logs page](https://resend.com/logs?status=429). To prevent this, we recommend reducing the rate at which you request the API. This can be done by introducing a queue mechanism or reducing the number of concurrent requests per second. If you have specific requirements, [contact support](https://resend.com/contact) to request a rate increase. ## Email Quotas ### Response Headers In addition to rate limits, the API returns headers that track your email sending quotas: | Header name | Description | | ------------------------ | ------------------------------------------------------------------ | | `x-resend-daily-quota` | Your used daily email sending quota. Only sent to free plan users. | | `x-resend-monthly-quota` | Your used monthly email sending quota. | These headers help you monitor your usage and avoid hitting quota limits. When you exceed your quota limits, you'll receive a `429` response error code with one of the following error types: * **`daily_quota_exceeded`** - You have reached your daily email quota. [Upgrade your plan](https://resend.com/settings/billing) to remove the daily quota limit or wait until 24 hours have passed. * **`monthly_quota_exceeded`** - You have reached your monthly email quota. [Upgrade your plan](https://resend.com/settings/billing) to increase the monthly email quota. Both sent and received emails count towards these quotas. See the full list of [error codes](/api-reference/errors) for more details. ## Contact Quotas Contact quotas restrict the number of contacts you can store for marketing emails and broadcasts. You can add more contacts beyond your plan's limit, but you won't be able to send broadcasts until you upgrade your plan. When you attempt to send a broadcast after reaching your contact limit, you'll receive a `403` response error code with a `validation_error` type and the message: "You have reached your contacts quota. Please upgrade your plan to send more emails." To increase your contact limit, [upgrade your Marketing plan](https://resend.com/settings/billing). # Create Segment Source: https://resend.com/docs/api-reference/segments/create-segment POST /segments Create a new segment for contacts to be added to. ## Body Parameters The name of the segment you want to create. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.segments.create({ name: 'Registered Users', }); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->segments->create([ 'name' => 'Registered Users', ]); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = 're_xxxxxxxxx' params = { "name": "Registered Users", } segment = resend.Segments.create(params) ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" params = { name: "Registered Users", } segment = Resend::Segments.create(params) ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import ( "context" "fmt" "github.com/resend/resend-go/v3" ) func main() { ctx := context.TODO() client := resend.NewClient("re_xxxxxxxxx") params := &resend.CreateSegmentRequest{ Name: "Registered Users", } segment, err := client.Segments.CreateWithContext(ctx, params) if err != nil { panic(err) } fmt.Println(segment) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _segment = resend.segments.create("Registered Users").await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); CreateSegmentOptions options = CreateSegmentOptions.builder() .name("Registered Users") .build(); CreateSegmentResponseSuccess response = resend.segments().create(options); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.SegmentCreateAsync( new SegmentData() { Name = "Registered Users", } ); Console.WriteLine( "Segment Id={0}", resp.Content ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X POST 'https://api.resend.com/segments' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'{ "name": "Registered Users" }' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "segment", "id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", "name": "Registered Users" } ``` # Delete Segment Source: https://resend.com/docs/api-reference/segments/delete-segment DELETE /segments/:segment_id Remove an existing segment. ## Path Parameters The Segment ID. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.segments.remove( '78261eea-8f8b-4381-83c6-79fa7120f1cf', ); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->segments->remove('78261eea-8f8b-4381-83c6-79fa7120f1cf'); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = 're_xxxxxxxxx' segment = resend.Segments.remove(id='78261eea-8f8b-4381-83c6-79fa7120f1cf') ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::Segments.remove("78261eea-8f8b-4381-83c6-79fa7120f1cf") ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import ( "context" "fmt" "github.com/resend/resend-go/v3" ) func main() { ctx := context.TODO() client := resend.NewClient("re_xxxxxxxxx") segment, err := client.Segments.RemoveWithContext(ctx, "78261eea-8f8b-4381-83c6-79fa7120f1cf") if err != nil { panic(err) } fmt.Println(segment) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _segment = resend .segments .delete("78261eea-8f8b-4381-83c6-79fa7120f1cf") .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); RemoveSegmentResponseSuccess response = resend.segments().remove("78261eea-8f8b-4381-83c6-79fa7120f1cf"); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.SegmentDeleteAsync( new Guid( "b6d24b8e-af0b-4c3c-be0c-359bbd97381e" ) ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X DELETE 'https://api.resend.com/segments/78261eea-8f8b-4381-83c6-79fa7120f1cf' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "segment", "id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", "deleted": true } ``` # Retrieve Segment Source: https://resend.com/docs/api-reference/segments/get-segment GET /segments/:segment_id Retrieve a single segment. ## Path Parameters The Segment ID. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.segments.get( '78261eea-8f8b-4381-83c6-79fa7120f1cf', ); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->segments->get('78261eea-8f8b-4381-83c6-79fa7120f1cf'); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = 're_xxxxxxxxx' segment = resend.Segments.get('78261eea-8f8b-4381-83c6-79fa7120f1cf') ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" segment = Resend::Segments.get("78261eea-8f8b-4381-83c6-79fa7120f1cf") ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import ( "context" "fmt" "github.com/resend/resend-go/v3" ) func main() { ctx := context.TODO() client := resend.NewClient("re_xxxxxxxxx") segment, err := client.Segments.GetWithContext(ctx, "78261eea-8f8b-4381-83c6-79fa7120f1cf") if err != nil { panic(err) } fmt.Println(segment) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _segment = resend .segments .get("78261eea-8f8b-4381-83c6-79fa7120f1cf") .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); GetSegmentResponseSuccess response = resend.segments().get("78261eea-8f8b-4381-83c6-79fa7120f1cf"); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.SegmentRetrieveAsync( new Guid( "b6d24b8e-af0b-4c3c-be0c-359bbd97381e" ) ); Console.WriteLine( "Segment Id={0}", resp.Content.Id ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X GET 'https://api.resend.com/segments/78261eea-8f8b-4381-83c6-79fa7120f1cf' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "segment", "id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", "name": "Registered Users", "created_at": "2023-10-06T22:59:55.977Z" } ``` # List Segments Source: https://resend.com/docs/api-reference/segments/list-segments GET /segments Retrieve a list of segments. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.segments.list(); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->segments->list(); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = 're_xxxxxxxxx' segments = resend.Segments.list() ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" segments = Resend::Segments.list ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import ( "context" "fmt" "github.com/resend/resend-go/v3" ) func main() { ctx := context.TODO() client := resend.NewClient("re_xxxxxxxxx") segments, err := client.Segments.ListWithContext(ctx) if err != nil { panic(err) } fmt.Println(segments) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{list_opts::ListOptions, Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _segments = resend.segments.list(ListOptions::default()).await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); ListSegmentsResponseSuccess response = resend.segments().list(); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.SegmentListAsync(); Console.WriteLine( "Nr Segments={0}", resp.Content.Data.Count ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X GET 'https://api.resend.com/segments' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "list", "has_more": false, "data": [ { "id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", "name": "Registered Users", "created_at": "2023-10-06T22:59:55.977Z" } ] } ``` # Create Template Source: https://resend.com/docs/api-reference/templates/create-template POST /templates Create a new template with optional variables. ## Body Parameters The name of the template. The HTML version of the template. The alias of the template. Sender email address. To include a friendly name, use the format `"Your Name "`. If provided, this value can be overridden when sending an email using the template. Default email subject. This value can be overridden when sending an email using the template. Default Reply-to email address. For multiple addresses, send as an array of strings. This value can be overridden when sending an email using the template. The plain text version of the message. If not provided, the HTML will be used to generate a plain text version. You can opt out of this behavior by setting value to an empty string. The React component used to write the template. *Only available in the Node.js SDK.* The array of variables used in the template. Each template may contain up to 50 variables. Each variable is an object with the following properties: The key of the variable. We recommend capitalizing the key (e.g. `PRODUCT_NAME`). The following variable names are reserved and cannot be used: `FIRST_NAME`, `LAST_NAME`, `EMAIL`, `RESEND_UNSUBSCRIBE_URL`, `contact`, and `this`. The type of the variable. Can be `'string'` or `'number'` The fallback value of the variable. The value must match the type of the variable. If no fallback value is provided, you must provide a value for the variable when sending an email using the template. Before you can use a template, you must publish it first. To publish a template, use the [Templates dashboard](https://resend.com/templates) or [publish template API](/api-reference/templates/publish-template). [Learn more about Templates](/dashboard/templates/introduction). ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.templates.create({ name: 'order-confirmation', html: '

Name: {{{PRODUCT}}}

Total: {{{PRICE}}}

', variables: [ { key: 'PRODUCT', type: 'string', fallbackValue: 'item', }, { key: 'PRICE', type: 'number', fallbackValue: 25, } ], }); // Or create and publish a template in one step await resend.templates.create({ ... }).publish(); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->templates->create([ 'name' => 'order-confirmation', 'html' => '

Name: {{{PRODUCT}}}

Total: {{{PRICE}}}

', 'variables' => [ [ 'key' => 'PRODUCT', 'type' => 'string', 'fallback_value' => 'item', ], [ 'key' => 'PRICE', 'type' => 'number', 'fallback_value' => 25, ] ], ]); ``` ```py Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" resend.Templates.create({ "name": "order-confirmation", "html": "

Name: {{{PRODUCT}}}

Total: {{{PRICE}}}

", "variables": [ { "key": "PRODUCT", "type": "string", "fallback_value": "item", }, { "key": "PRICE", "type": "number", "fallback_value": 25, } ], }) ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::Templates.create( name: "order-confirmation", html: "

Name: {{{PRODUCT}}}

Total: {{{PRICE}}}

", variables: [ { key: "PRODUCT", type: "string", fallback_value: "item" }, { key: "PRICE", type: "number", fallback_value: 25 } ] ) ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import ( "context" "github.com/resend/resend-go/v3" ) func main() { client := resend.NewClient("re_xxxxxxxxx") client.Templates.CreateWithContext(context.TODO(), &resend.CreateTemplateRequest{ Name: "order-confirmation", Html: "

Name: {{{PRODUCT}}}

Total: {{{PRICE}}}

", Variables: []*resend.TemplateVariable{ { Key: "PRODUCT", Type: resend.VariableTypeString, FallbackValue: "item", }, { Key: "PRICE", Type: resend.VariableTypeNumber, FallbackValue: 25, }, }, }) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{ types::{CreateTemplateOptions, Variable, VariableType}, Resend, Result, }; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let name = "order-confirmation"; let html = "

Name: {{{PRODUCT}}}

Total: {{{PRICE}}}

"; let variables = [ Variable::new("PRODUCT", VariableType::String).with_fallback("item"), Variable::new("PRICE", VariableType::Number).with_fallback(25) ]; let opts = CreateTemplateOptions::new(name, html).with_variables(&variables); let template = resend.templates.create(opts).await?; let _published = resend.templates.publish(&template.id).await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); CreateTemplateOptions params = CreateTemplateOptions.builder() .name("order-confirmation") .html("

Name: {{{PRODUCT}}}

Total: {{{PRICE}}}

") .addVariable(new Variable("PRODUCT", VariableType.STRING, "item")) .addVariable(new Variable("PRICE", VariableType.NUMBER, 25)) .build(); CreateTemplateResponseSuccess data = resend.templates().create(params); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create("re_xxxxxxxxx"); var variables = new List() { new TemplateVariable() { Key = "PRODUCT", Type = TemplateVariableType.String, Default = "item", }, new TemplateVariable() { Key = "PRICE", Type = TemplateVariableType.Number, Default = 25, } }; var resp = await resend.TemplateCreateAsync( new TemplateData() { Name = "welcome-email", HtmlBody = "Hey, {{{PRODUCT}}}, you are {{{PRICE}}} years old.", Variables = variables, } ); Console.WriteLine($"Template Id={resp.Content}"); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X POST 'https://api.resend.com/templates' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'{ "name": "order-confirmation", "html": "

Name: {{{PRODUCT}}}

Total: {{{PRICE}}}

", "variables": [ { "key": "PRODUCT", "type": "string", "fallback_value": "item" }, { "key": "PRICE", "type": "number", "fallback_value": 25 } ] }' ```
```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "id": "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794", "object": "template" } ``` # Delete Template Source: https://resend.com/docs/api-reference/templates/delete-template DELETE /templates/:template_id Delete a template. ## Path Parameters The ID or alias of the template to delete. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.templates.remove( '34a080c9-b17d-4187-ad80-5af20266e535', ); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->templates->remove('34a080c9-b17d-4187-ad80-5af20266e535'); ``` ```py Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" resend.Templates.remove("34a080c9-b17d-4187-ad80-5af20266e535") ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::Templates.remove("34a080c9-b17d-4187-ad80-5af20266e535") ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} import ( "context" "github.com/resend/resend-go/v3" ) func main() { client := resend.NewClient("re_xxxxxxxxx") client.Templates.RemoveWithContext( context.TODO(), "34a080c9-b17d-4187-ad80-5af20266e535", ) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _deleted = resend .templates .delete("34a080c9-b17d-4187-ad80-5af20266e535") .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); DeleteTemplateResponseSuccess data = resend.templates().remove("34a080c9-b17d-4187-ad80-5af20266e535"); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI await resend.TemplateDeleteAsync( new Guid( "34a080c9-b17d-4187-ad80-5af20266e535" ) ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X DELETE 'https://api.resend.com/templates/34a080c9-b17d-4187-ad80-5af20266e535' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "template", "id": "34a080c9-b17d-4187-ad80-5af20266e535", "deleted": true } ``` # Duplicate Template Source: https://resend.com/docs/api-reference/templates/duplicate-template POST /templates/:template_id/duplicate Duplicate a template. ## Path Parameters The ID or alias of the template to duplicate. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.templates.duplicate( '34a080c9-b17d-4187-ad80-5af20266e535', ); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->templates->duplicate('34a080c9-b17d-4187-ad80-5af20266e535'); ``` ```py Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" resend.Templates.duplicate("34a080c9-b17d-4187-ad80-5af20266e535") ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::Templates.duplicate("34a080c9-b17d-4187-ad80-5af20266e535") ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} import ( "context" "github.com/resend/resend-go/v3" ) func main() { client := resend.NewClient("re_xxxxxxxxx") client.Templates.DuplicateWithContext( context.TODO(), "34a080c9-b17d-4187-ad80-5af20266e535", ) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _duplicated = resend .templates .duplicate("34a080c9-b17d-4187-ad80-5af20266e535") .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); DuplicateTemplateResponseSuccess data = resend.templates().duplicate("34a080c9-b17d-4187-ad80-5af20266e535"); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI await resend.TemplateDuplicateAsync( new Guid( "34a080c9-b17d-4187-ad80-5af20266e535" ) ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X POST 'https://api.resend.com/templates/34a080c9-b17d-4187-ad80-5af20266e535/duplicate' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "template", "id": "e169aa45-1ecf-4183-9955-b1499d5701d3" } ``` # Get Template Source: https://resend.com/docs/api-reference/templates/get-template GET /templates/:template_id Get a template by ID. ## Path Parameters The ID or alias of the template to get. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.templates.get( '34a080c9-b17d-4187-ad80-5af20266e535', ); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->templates->get('34a080c9-b17d-4187-ad80-5af20266e535'); ``` ```py Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" resend.Templates.get("34a080c9-b17d-4187-ad80-5af20266e535") ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::Templates.get("34a080c9-b17d-4187-ad80-5af20266e535") ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} import ( "context" "github.com/resend/resend-go/v3" ) func main() { client := resend.NewClient("re_xxxxxxxxx") client.Templates.GetWithContext( context.TODO(), "34a080c9-b17d-4187-ad80-5af20266e535", ) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _template = resend .templates .get("34a080c9-b17d-4187-ad80-5af20266e535") .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); GetTemplateResponseSuccess data = resend.templates().get("34a080c9-b17d-4187-ad80-5af20266e535"); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var res = await resend.TemplateRetrieveAsync( new Guid( "34a080c9-b17d-4187-ad80-5af20266e535" ) ); Console.WriteLine( "Template Name={0}", res.Content.Name ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X GET 'https://api.resend.com/templates/34a080c9-b17d-4187-ad80-5af20266e535' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "template", "id": "34a080c9-b17d-4187-ad80-5af20266e535", "current_version_id": "b2693018-7abb-4b4b-b4cb-aadf72dc06bd", "alias": "reset-password", "name": "reset-password", "created_at": "2023-10-06T23:47:56.678Z", "updated_at": "2023-10-06T23:47:56.678Z", "status": "published", "published_at": "2023-10-06T23:47:56.678Z", "from": "John Doe ", "subject": "Hello, world!", "reply_to": null, "html": "

Hello, world!

", "text": "Hello, world!", "variables": [ { "id": "e169aa45-1ecf-4183-9955-b1499d5701d3", "key": "user_name", "type": "string", "fallback_value": "John Doe", "created_at": "2023-10-06T23:47:56.678Z", "updated_at": "2023-10-06T23:47:56.678Z" } ], "has_unpublished_versions": true } ```
# List Templates Source: https://resend.com/docs/api-reference/templates/list-templates GET /templates List all templates. By default, the API will return the most recent 20 templates. You can optionally use the `limit` parameter to return a different number of templates or control the pagination of the results with the `after` or `before` parameters. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.templates.list({ limit: 2, after: '34a080c9-b17d-4187-ad80-5af20266e535', }); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->templates->list([ 'limit' => 2, 'after' => '34a080c9-b17d-4187-ad80-5af20266e535' ]); ``` ```py Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" resend.Templates.list({ "limit": 2, "after": "34a080c9-b17d-4187-ad80-5af20266e535", }) ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::Templates.list( limit: 2, after: "34a080c9-b17d-4187-ad80-5af20266e535" ) ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} import ( "context" "github.com/resend/resend-go/v3" ) func main() { client := resend.NewClient("re_xxxxxxxxx") client.Templates.ListWithContext(context.TODO(), &resend.ListOptions{ Limit: 2, After: "34a080c9-b17d-4187-ad80-5af20266e535", }) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{list_opts::ListOptions, Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let list_opts = ListOptions::default() .with_limit(2) .list_after("34a080c9-b17d-4187-ad80-5af20266e535"); let _list = resend.templates.list(list_opts).await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); ListParams params = ListParams.builder() .limit(2) .after("34a080c9-b17d-4187-ad80-5af20266e535") .build(); ListTemplatesResponseSuccess data = resend.templates().list(params); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.TemplateListAsync(); Console.WriteLine( "Nr Templates={0}", resp.Content.Data.Count ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X GET 'https://api.resend.com/templates?limit=2&after=34a080c9-b17d-4187-ad80-5af20266e535' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "list", "data": [ { "id": "e169aa45-1ecf-4183-9955-b1499d5701d3", "name": "reset-password", "status": "draft", "published_at": null, "created_at": "2023-10-06T23:47:56.678Z", "updated_at": "2023-10-06T23:47:56.678Z", "alias": "reset-password" }, { "id": "b7f9c2e1-1234-4abc-9def-567890abcdef", "name": "welcome-message", "status": "published", "published_at": "2023-10-06T23:47:56.678Z", "created_at": "2023-10-06T23:47:56.678Z", "updated_at": "2023-10-06T23:47:56.678Z", "alias": "welcome-message" } ], "has_more": false } ``` # Publish Template Source: https://resend.com/docs/api-reference/templates/publish-template POST /templates/:template_id/publish Publish a template. ## Path Parameters The ID or alias of the template to publish. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.templates.publish( '34a080c9-b17d-4187-ad80-5af20266e535', ); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->templates->publish('34a080c9-b17d-4187-ad80-5af20266e535'); ``` ```py Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" resend.Templates.publish("34a080c9-b17d-4187-ad80-5af20266e535") ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::Templates.publish("34a080c9-b17d-4187-ad80-5af20266e535") ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} import ( "context" "github.com/resend/resend-go/v3" ) func main() { client := resend.NewClient("re_xxxxxxxxx") client.Templates.PublishWithContext( context.TODO(), "34a080c9-b17d-4187-ad80-5af20266e535", ) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _published = resend .templates .publish("34a080c9-b17d-4187-ad80-5af20266e535") .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); PublishTemplateResponseSuccess data = resend.templates().publish("34a080c9-b17d-4187-ad80-5af20266e535"); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI await resend.TemplatePublishAsync( new Guid( "34a080c9-b17d-4187-ad80-5af20266e535" ) ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X POST 'https://api.resend.com/templates/34a080c9-b17d-4187-ad80-5af20266e535/publish' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "id": "34a080c9-b17d-4187-ad80-5af20266e535", "object": "template" } ``` # Update Template Source: https://resend.com/docs/api-reference/templates/update-template PATCH /templates/:template_id Update a template. ## Path Parameters The ID or alias of the template to duplicate. ## Body Parameters The name of the template. The HTML version of the template. The alias of the template. Sender email address. To include a friendly name, use the format `"Your Name "`. If provided, this value can be overridden when sending an email using the template. Default email subject. This value can be overridden when sending an email using the template. Default Reply-to email address. For multiple addresses, send as an array of strings. This value can be overridden when sending an email using the template. The plain text version of the message. If not provided, the HTML will be used to generate a plain text version. You can opt out of this behavior by setting value to an empty string. The React component used to write the template. *Only available in the Node.js SDK.* The array of variables used in the template. Each template may contain up to 50 variables. Each variable is an object with the following properties: The key of the variable. We recommend capitalizing the key (e.g. `PRODUCT_NAME`). The following variable names are reserved and cannot be used: `FIRST_NAME`, `LAST_NAME`, `EMAIL`, `RESEND_UNSUBSCRIBE_URL`, `contact`, and `this`. The type of the variable. Can be `'string'` or `'number'` The fallback value of the variable. The value must match the type of the variable. If no fallback value is provided, you must provide a value for the variable when sending an email using the template. Before you can use a template, you must publish it first. To publish a template, use the [Templates dashboard](https://resend.com/templates) or [publish template API](/api-reference/templates/publish-template). [Learn more about Templates](/dashboard/templates/introduction). ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.templates.update( '34a080c9-b17d-4187-ad80-5af20266e535', { name: 'order-confirmation', html: '

Total: {{{PRICE}}}

Name: {{{PRODUCT}}}

', }, ); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->templates->update('34a080c9-b17d-4187-ad80-5af20266e535', [ 'name' => 'order-confirmation', 'html' => '

Total: {{{PRICE}}}

Name: {{{PRODUCT}}}

', ]); ``` ```py Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" resend.Templates.update({ "id": "34a080c9-b17d-4187-ad80-5af20266e535", "name": "order-confirmation", "html": "

Total: {{{PRICE}}}

Name: {{{PRODUCT}}}

", }) ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::Templates.update("34a080c9-b17d-4187-ad80-5af20266e535", { name: "order-confirmation", html: "

Total: {{{PRICE}}}

Name: {{{PRODUCT}}}

" }) ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import ( "context" "github.com/resend/resend-go/v3" ) func main() { client := resend.NewClient("re_xxxxxxxxx") client.Templates.UpdateWithContext(context.TODO(), "34a080c9-b17d-4187-ad80-5af20266e535", &resend.UpdateTemplateRequest{ Name: "order-confirmation", Html: "

Total: {{{PRICE}}}

Name: {{{PRODUCT}}}

", }) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{ types::UpdateTemplateOptions, Resend, Result, }; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let name = "order-confirmation"; let html = "

Total: {{{PRICE}}}

Name: {{{PRODUCT}}}

"; let update = UpdateTemplateOptions::new(name, html); let _template = resend .templates .update("34a080c9-b17d-4187-ad80-5af20266e535", update) .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); UpdateTemplateOptions params = UpdateTemplateOptions.builder() .name("order-confirmation") .html("

Total: {{{PRICE}}}

Name: {{{PRODUCT}}}

") .build(); UpdateTemplateResponseSuccess data = resend.templates().update("34a080c9-b17d-4187-ad80-5af20266e535", params); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI await resend.TemplateUpdateAsync( templateId: new Guid( "e169aa45-1ecf-4183-9955-b1499d5701d3" ), new TemplateData() { HtmlBody = "

Total: {{{PRICE}}}

Name: {{{PRODUCT}}}

", } ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X PATCH 'https://api.resend.com/templates/34a080c9-b17d-4187-ad80-5af20266e535' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'{ "name": "order-confirmation", "html": "

Total: {{{PRICE}}}

Name: {{{PRODUCT}}}

" }' ```
```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "id": "34a080c9-b17d-4187-ad80-5af20266e535", "object": "template" } ``` # Create Topic Source: https://resend.com/docs/api-reference/topics/create-topic POST /topics Create and email topics to segment your audience. ## Body Parameters The topic name. Max length is `50` characters. The default subscription preference for new contacts. Possible values: `opt_in` or `opt_out`. This value cannot be changed later. The topic description. Max length is `200` characters. The visibility of the topic on the unsubscribe page. Possible values: `public` or `private`. * `private`: only contacts who are opted in to the topic can see it on the unsubscribe page. * `public`: all contacts can see the topic on the unsubscribe page. If not specified, defaults to `private`. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.topics.create({ name: 'Weekly Newsletter', defaultSubscription: 'opt_in', }); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->topics->create([ 'name' => 'Weekly Newsletter', 'default_subscription' => 'opt_in', ]); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" resend.Topics.create({ "name": "Weekly Newsletter", "default_subscription": "opt_in", "description": "Subscribe to our weekly newsletter for updates", }) ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::Topics.create( name: "Weekly Newsletter", default_subscription: "opt_in" ) ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} import ( "context" "github.com/resend/resend-go/v3" ) func main() { client := resend.NewClient("re_xxxxxxxxx") client.Topics.CreateWithContext(context.TODO(), &resend.CreateTopicRequest{ Name: "Weekly Newsletter", DefaultSubscription: resend.DefaultSubscriptionOptIn, }) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{ types::{CreateTopicOptions, SubscriptionType}, Resend, Result, }; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let opts = CreateTopicOptions::new("Weekly Newsletter", SubscriptionType::OptIn); let _topic = resend.topics.create(opts).await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); CreateTopicOptions createTopicOptions = CreateTopicOptions.builder() .name("Weekly Newsletter") .defaultSubscription("opt_in") .build(); CreateTopicResponseSuccess response = resend.topics().create(createTopicOptions); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.TopicCreateAsync( new TopicData() { Name = "Weekly Newsletter", Description = "Weekly newsletter for our subscribers", SubscriptionDefault = SubscriptionType.OptIn, } ); Console.WriteLine( "Topic Id={0}", resp.Content ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X POST 'https://api.resend.com/topics' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'{ "name": "Weekly Newsletter", "default_subscription": "opt_in" }' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "topic", "id": "b6d24b8e-af0b-4c3c-be0c-359bbd97381e" } ``` # Delete Topic Source: https://resend.com/docs/api-reference/topics/delete-topic DELETE /topics/:topic_id Remove an existing topic. ## Path Parameters The topic ID. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.topics.remove( 'b6d24b8e-af0b-4c3c-be0c-359bbd97381e', ); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->topics->remove('b6d24b8e-af0b-4c3c-be0c-359bbd97381e'); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" resend.Topics.remove(id="b6d24b8e-af0b-4c3c-be0c-359bbd97381e") ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::Topics.remove("b6d24b8e-af0b-4c3c-be0c-359bbd97381e") ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} import ( "context" "github.com/resend/resend-go/v3" ) func main() { client := resend.NewClient("re_xxxxxxxxx") client.Topics.RemoveWithContext( context.TODO(), "b6d24b8e-af0b-4c3c-be0c-359bbd97381e", ) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _deleted = resend.topics.delete("delete").await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); RemoveTopicResponseSuccess response = resend.topics().remove("b6d24b8e-af0b-4c3c-be0c-359bbd97381e"); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.TopicDeleteAsync( new Guid( "b6d24b8e-af0b-4c3c-be0c-359bbd97381e" ) ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X DELETE 'https://api.resend.com/topics/b6d24b8e-af0b-4c3c-be0c-359bbd97381e' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "topic", "id": "b6d24b8e-af0b-4c3c-be0c-359bbd97381e", "deleted": true } ``` # Retrieve Topic Source: https://resend.com/docs/api-reference/topics/get-topic GET /topics/:topic_id Retrieve a topic by its ID. ## Path Parameters The Topic ID. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.topics.get( 'b6d24b8e-af0b-4c3c-be0c-359bbd97381e', ); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->topics->get('b6d24b8e-af0b-4c3c-be0c-359bbd97381e'); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" resend.Topics.get("b6d24b8e-af0b-4c3c-be0c-359bbd97381e") ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::Topics.get("b6d24b8e-af0b-4c3c-be0c-359bbd97381e") ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} import ( "context" "github.com/resend/resend-go/v3" ) func main() { client := resend.NewClient("re_xxxxxxxxx") client.Topics.GetWithContext( context.TODO(), "b6d24b8e-af0b-4c3c-be0c-359bbd97381e", ) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _topic = resend .topics .get("b6d24b8e-af0b-4c3c-be0c-359bbd97381e") .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); GetTopicResponseSuccess topic = resend.topics().get("b6d24b8e-af0b-4c3c-be0c-359bbd97381e"); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.TopicRetrieveAsync( new Guid( "b6d24b8e-af0b-4c3c-be0c-359bbd97381e" ) ); Console.WriteLine( "Topic Id={0}", resp.Content.Id ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X GET 'https://api.resend.com/topics/b6d24b8e-af0b-4c3c-be0c-359bbd97381e' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "topic", "id": "b6d24b8e-af0b-4c3c-be0c-359bbd97381e", "name": "Weekly Newsletter", "description": "Weekly newsletter for our subscribers", "default_subscription": "opt_in", "visibility": "public", "created_at": "2023-04-08T00:11:13.110779+00:00" } ``` # List Topics Source: https://resend.com/docs/api-reference/topics/list-topics GET /topics Retrieve a list of topics for the authenticated user. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.topics.list(); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->topics->list(); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" resend.Topics.list() ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::Topics.list() ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} import ( "context" "github.com/resend/resend-go/v3" ) func main() { client := resend.NewClient("re_xxxxxxxxx") client.Topics.ListWithContext(context.TODO(), nil) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{list_opts::ListOptions, Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _list = resend.topics.list(ListOptions::default()).await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); ListTopicsResponseSuccess response = resend.topics().list(); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.TopicListAsync(); Console.WriteLine( "Nr Topics={0}", resp.Content.Data.Count ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X GET 'https://api.resend.com/topics' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "list", "has_more": false, "data": [ { "id": "b6d24b8e-af0b-4c3c-be0c-359bbd97381e", "name": "Weekly Newsletter", "description": "Weekly newsletter for our subscribers", "default_subscription": "opt_in", "visibility": "public", "created_at": "2023-04-08T00:11:13.110779+00:00" } ] } ``` # Update Topic Source: https://resend.com/docs/api-reference/topics/update-topic PATCH /topics/:topic_id Update an existing topic. ## Path Parameters The Topic ID. ## Body Parameters The topic name. Max length is `50` characters. The topic description. Max length is `200` characters. The visibility of the topic on the unsubscribe page. Possible values: `public` or `private`. * `private`: only contacts who are opted in to the topic can see it on the unsubscribe page. * `public`: all contacts can see the topic on the unsubscribe page. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.topics.update( 'b6d24b8e-af0b-4c3c-be0c-359bbd97381e', { name: 'Weekly Newsletter', description: 'Weekly newsletter for our subscribers', }, ); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->topics->update('b6d24b8e-af0b-4c3c-be0c-359bbd97381e', [ 'name' => 'Weekly Newsletter', 'description' => 'Weekly newsletter for our subscribers', ]); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = "re_xxxxxxxxx" resend.Topics.update( id="b6d24b8e-af0b-4c3c-be0c-359bbd97381e", params={ "name": "Monthly Newsletter", "description": "Subscribe to our monthly newsletter for updates", } ) ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::Topics.update( topic_id: "b6d24b8e-af0b-4c3c-be0c-359bbd97381e", name: "Weekly Newsletter", description: "Weekly newsletter for our subscribers" ) ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} import ( "context" "github.com/resend/resend-go/v3" ) func main() { client := resend.NewClient("re_xxxxxxxxx") client.Topics.UpdateWithContext(context.TODO(), "b6d24b8e-af0b-4c3c-be0c-359bbd97381e", &resend.UpdateTopicRequest{ Name: "Weekly Newsletter", Description: "Weekly newsletter for our subscribers", }) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{types::UpdateTopicOptions, Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let update = UpdateTopicOptions::new() .with_name("Weekly Newsletter") .with_description("Weekly newsletter for our subscribers"); let _topic = resend .topics .update("b6d24b8e-af0b-4c3c-be0c-359bbd97381e", update) .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); UpdateTopicOptions updateTopicOptions = UpdateTopicOptions.builder() .name("Weekly Newsletter") .description("Weekly newsletter for our subscribers") .build(); UpdateTopicResponseSuccess response = resend.topics().update( "b6d24b8e-af0b-4c3c-be0c-359bbd97381e", updateTopicOptions ); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.TopicUpdateAsync( new Guid( "b6d24b8e-af0b-4c3c-be0c-359bbd97381e" ), new TopicData() { Name = "Weekly Newsletter", Description = "Weekly newsletter for our subscribers", SubscriptionDefault = SubscriptionType.OptIn, } ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X PATCH 'https://api.resend.com/topics/b6d24b8e-af0b-4c3c-be0c-359bbd97381e' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'{ "name": "Weekly Newsletter", "default_subscription": "opt_in" }' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "topic", "id": "b6d24b8e-af0b-4c3c-be0c-359bbd97381e" } ``` # Create Webhook Source: https://resend.com/docs/api-reference/webhooks/create-webhook POST /webhooks Create a webhook to receive real-time notifications about email events. ## Body Parameters The URL where webhook events will be sent. Array of event types to subscribe to. See [event types](/webhooks/event-types) for available options. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.webhooks.create({ endpoint: 'https://example.com/handler', events: ['email.sent'], }); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->webhooks->create([ 'endpoint' => 'https://example.com/handler', 'events' => ['email.sent'], ]); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = 're_xxxxxxxxx' params: resend.Webhooks.CreateParams = { "endpoint": "https://example.com/handler", "events": ["email.sent"], } webhook = resend.Webhooks.create(params=params) ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require 'resend' Resend.api_key = 're_xxxxxxxxx' params = { endpoint: 'https://example.com/handler', events: ['email.sent'] } webhook = Resend::Webhooks.create(params) ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import "github.com/resend/resend-go/v3" func main() { client := resend.NewClient("re_xxxxxxxxx") params := &resend.CreateWebhookRequest{ Endpoint: "https://example.com/handler", Events: []string{"email.sent"}, } client.Webhooks.Create(params) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{ events::EmailEventType::{EmailSent}, types::CreateWebhookOptions, Resend, Result, }; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let events = [EmailSent]; let opts = CreateWebhookOptions::new("https://example.com/handler", events); let _webhook = resend.webhooks.create(opts).await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; import static com.resend.services.webhooks.model.WebhookEvent.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); CreateWebhookOptions options = CreateWebhookOptions.builder() .endpoint("https://example.com/handler") .events(EMAIL_SENT) .build(); CreateWebhookResponseSuccess response = resend.webhooks().create(options); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var data = new WebhookData() { EndpointUrl = "https://example.com/handler", Events = [ WebhookEventType.EmailSent ], Status = WebhookStatus.Disabled, }; var resp = await resend.WebhookCreateAsync( data ); Console.WriteLine( "Webhook Id={0}", resp.Content.Id ); Console.WriteLine( "Signing secret={0}", resp.Content.SigningSecret ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X POST 'https://api.resend.com/webhooks' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d '{ "endpoint": "https://example.com/handler", "events": ["email.sent"] }' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "webhook", "id": "4dd369bc-aa82-4ff3-97de-514ae3000ee0", "signing_secret": "whsec_xxxxxxxxxx" } ``` # Delete Webhook Source: https://resend.com/docs/api-reference/webhooks/delete-webhook DELETE /webhooks/:webhook_id Remove an existing webhook. ## Path Parameters The Webhook ID. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.webhooks.remove( '4dd369bc-aa82-4ff3-97de-514ae3000ee0', ); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->webhooks->remove('4dd369bc-aa82-4ff3-97de-514ae3000ee0'); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = 're_xxxxxxxxx' webhook = resend.Webhooks.remove(webhook_id='4dd369bc-aa82-4ff3-97de-514ae3000ee0') ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require 'resend' Resend.api_key = 're_xxxxxxxxx' webhook = Resend::Webhooks.remove('4dd369bc-aa82-4ff3-97de-514ae3000ee0') ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import "github.com/resend/resend-go/v3" func main() { client := resend.NewClient("re_xxxxxxxxx") client.Webhooks.Remove("4dd369bc-aa82-4ff3-97de-514ae3000ee0") } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _deleted = resend .webhooks .delete("4dd369bc-aa82-4ff3-97de-514ae3000ee0") .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); RemoveWebhookResponseSuccess response = resend.webhooks().remove("4dd369bc-aa82-4ff3-97de-514ae3000ee0"); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI await resend.WebhookDeleteAsync( new Guid( "d91cd9bd-1176-453e-8fc1-35364d380206" ) ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X DELETE 'https://api.resend.com/webhooks/4dd369bc-aa82-4ff3-97de-514ae3000ee0' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "webhook", "id": "4dd369bc-aa82-4ff3-97de-514ae3000ee0", "deleted": true } ``` # Retrieve Webhook Source: https://resend.com/docs/api-reference/webhooks/get-webhook GET /webhooks/:webhook_id Retrieve a single webhook for the authenticated user. ## Path Parameters The Webhook ID. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.webhooks.get( '4dd369bc-aa82-4ff3-97de-514ae3000ee0', ); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->webhooks->get('4dd369bc-aa82-4ff3-97de-514ae3000ee0'); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = 're_xxxxxxxxx' webhook = resend.Webhooks.get(webhook_id='4dd369bc-aa82-4ff3-97de-514ae3000ee0') ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require 'resend' Resend.api_key = 're_xxxxxxxxx' webhook = Resend::Webhooks.get('4dd369bc-aa82-4ff3-97de-514ae3000ee0') ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import "github.com/resend/resend-go/v3" func main() { client := resend.NewClient("re_xxxxxxxxx") client.Webhooks.Get("4dd369bc-aa82-4ff3-97de-514ae3000ee0") } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _webhook = resend .webhooks .get("4dd369bc-aa82-4ff3-97de-514ae3000ee0") .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); GetWebhookResponseSuccess webhook = resend.webhooks().get("4dd369bc-aa82-4ff3-97de-514ae3000ee0"); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.WebhookRetrieveAsync( new Guid( "559ac32e-9ef5-46fb-82a1-b76b840c0f7b" ) ); Console.WriteLine( "Endpoint={0}", resp.Content.EndpointUrl ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X GET 'https://api.resend.com/webhooks/4dd369bc-aa82-4ff3-97de-514ae3000ee0' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "webhook", "id": "4dd369bc-aa82-4ff3-97de-514ae3000ee0", "created_at": "2023-08-22T15:28:00.000Z", "status": "enabled", "endpoint": "https://example.com/handler", "events": ["email.sent"], "signing_secret": "whsec_xxxxxxxxxx" } ``` # List Webhooks Source: https://resend.com/docs/api-reference/webhooks/list-webhooks GET /webhooks Retrieve a list of webhooks for the authenticated user. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.webhooks.list(); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->webhooks->list(); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = 're_xxxxxxxxx' webhooks = resend.Webhooks.list() ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require 'resend' Resend.api_key = 're_xxxxxxxxx' webhooks = Resend::Webhooks.list ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import "github.com/resend/resend-go/v3" func main() { client := resend.NewClient("re_xxxxxxxxx") client.Webhooks.List() } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{list_opts::ListOptions, Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _webhooks = resend.webhooks.list(ListOptions::default()).await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); ListWebhooksResponseSuccess response = resend.webhooks().list(); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.WebhookListAsync(); Console.WriteLine( "Nr Webhooks={0}", resp.Content.Data.Count ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X GET 'https://api.resend.com/webhooks' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "list", "has_more": false, "data": [ { "id": "7ab123cd-ef45-6789-abcd-ef0123456789", "created_at": "2023-09-10T10:15:30.000Z", "status": "disabled", "endpoint": "https://first-webhook.example.com/handler", "events": ["email.sent"] }, { "id": "4dd369bc-aa82-4ff3-97de-514ae3000ee0", "created_at": "2023-08-22T15:28:00.000Z", "status": "enabled", "endpoint": "https://second-webhook.example.com/receive", "events": ["email.received"] } ] } ``` # Update Webhook Source: https://resend.com/docs/api-reference/webhooks/update-webhook PATCH /webhooks/:webhook_id Update an existing webhook configuration. ## Path Parameters The Webhook ID. ## Body Parameters The URL where webhook events will be sent. Array of event types to subscribe to. See [event types](/webhooks/event-types) for available options. The webhook status. Can be either `enabled` or `disabled`. ```ts Node.js theme={"theme":{"light":"github-light","dark":"vesper"}} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.webhooks.update( '430eed87-632a-4ea6-90db-0aace67ec228', { endpoint: 'https://new-webhook.example.com/handler', events: ['email.sent', 'email.delivered'], status: 'enabled', }, ); ``` ```php PHP theme={"theme":{"light":"github-light","dark":"vesper"}} $resend = Resend::client('re_xxxxxxxxx'); $resend->webhooks->update('430eed87-632a-4ea6-90db-0aace67ec228', [ 'endpoint' => 'https://new-webhook.example.com/handler', 'events' => ['email.sent', 'email.delivered'], 'status' => 'enabled', ]); ``` ```python Python theme={"theme":{"light":"github-light","dark":"vesper"}} import resend resend.api_key = 're_xxxxxxxxx' params: resend.Webhooks.UpdateParams = { "webhook_id": "430eed87-632a-4ea6-90db-0aace67ec228", "endpoint": "https://new-webhook.example.com/handler", "events": ["email.sent", "email.delivered"], "status": "enabled", } webhook = resend.Webhooks.update(params) ``` ```ruby Ruby theme={"theme":{"light":"github-light","dark":"vesper"}} require 'resend' Resend.api_key = 're_xxxxxxxxx' params = { webhook_id: '430eed87-632a-4ea6-90db-0aace67ec228', endpoint: 'https://new-webhook.example.com/handler', events: ['email.sent', 'email.delivered'], status: 'enabled' } webhook = Resend::Webhooks.update(params) ``` ```go Go theme={"theme":{"light":"github-light","dark":"vesper"}} package main import "github.com/resend/resend-go/v3" func main() { client := resend.NewClient("re_xxxxxxxxx") endpoint := "https://new-webhook.example.com/handler" status := "enabled" params := &resend.UpdateWebhookRequest{ Endpoint: &endpoint, Events: []string{"email.sent", "email.delivered"}, Status: &status, } client.Webhooks.Update("430eed87-632a-4ea6-90db-0aace67ec228", params) } ``` ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}} use resend_rs::{ events::EmailEventType::{EmailDelivered, EmailSent}, types::{UpdateWebhookOptions, WebhookStatus}, Resend, Result, }; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let events = [EmailSent, EmailDelivered]; let opts = UpdateWebhookOptions::default() .with_endpoint("https://new-webhook.example.com/handler") .with_events(events) .with_status(WebhookStatus::Enabled); let _webhook = resend .webhooks .update("430eed87-632a-4ea6-90db-0aace67ec228", opts) .await?; Ok(()) } ``` ```java Java theme={"theme":{"light":"github-light","dark":"vesper"}} import com.resend.*; import static com.resend.services.webhooks.model.WebhookEvent.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); UpdateWebhookOptions options = UpdateWebhookOptions.builder() .endpoint("https://new-webhook.example.com/handler") .events(EMAIL_SENT, EMAIL_DELIVERED) .status(WebhookStatus.ENABLED) .build(); UpdateWebhookResponseSuccess response = resend.webhooks() .update("430eed87-632a-4ea6-90db-0aace67ec228", options); } } ``` ```csharp .NET theme={"theme":{"light":"github-light","dark":"vesper"}} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI await resend.WebhookUpdateAsync( new Guid( "430eed87-632a-4ea6-90db-0aace67ec228" ), new WebhookData() { EndpointUrl = "https://new-webhook.example.com/handler", Events = [ WebhookEventType.EmailSent ], Status = WebhookStatus.Disabled, } ); ``` ```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X PATCH 'https://api.resend.com/webhooks/430eed87-632a-4ea6-90db-0aace67ec228' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d '{ "endpoint": "https://new-webhook.example.com/handler", "events": ["email.sent", "email.delivered"], "status": "enabled" }' ``` ```json Response theme={"theme":{"light":"github-light","dark":"vesper"}} { "object": "webhook", "id": "430eed87-632a-4ea6-90db-0aace67ec228" } ``` # Send emails with Base44 and Resend Source: https://resend.com/docs/base44-integration Learn how to add the Resend integration to your Base44 project. [Base44](https://base44.com/) is a platform for building apps with AI. You can add Resend in a Base44 project by asking the chat to add email sending with Resend. This integration requires backend functions, a feature available only on Builder tier and above. Learn more about [Base44 pricing](https://base44.com/pricing). ## 1. Add the Resend integration in Base44 **If starting a new app:** 1. Click **Integration** in the top nav. 2. Search for **Resend**, select it, and choose **Use This Integration**. Resend Integration page **If adding Resend to an existing app:** 1. Enable backend functions. 2. Ask the chat: "Add the Resend email integration to my app. Prompt me to provide the API key and send a welcome email to new users." See the [Base44 documenation](https://docs.base44.com/Integrations/Resend-integration) for more information. ## 2. Add your Resend API key However you add Resend to your project, you'll need to add a Resend API key, which you can create in the [Resend Dashboard](https://resend.com/api-keys). Do not share your API key with others or expose it in the browser or other client-side code. Copy the API key and paste it into the **RESEND\_API\_KEY** field in Base44. Adding your Resend API key to Base44 ## 3. Add a custom domain to your Resend account By default, you can only send emails to your own email address. To send emails to other email addresses: 1. Add a [custom domain to your Resend account](https://resend.com/domains). 2. Add the custom domain to the `from` field in the `resend` function in the Base44 backend function (or ask the chat to update these fields). Get more help adding a custom domain in [Resend's documentation](/dashboard/domains/introduction). # Send emails with Bolt.new and Resend Source: https://resend.com/docs/bolt-new-integration Learn how to add the Resend integration to your Bolt.new project. [Bolt.new](https://bolt.new) is a platform for building full-stack web and mobile apps via chat. You can add Resend in a Bolt.new project by asking the chat to add email sending with Resend. adding the Resend integration to a Bolt.new chat ## 1. Add your Resend API key To use Resend with Bolt.new, you'll need to add a Resend API key, which you can create in the [Resend Dashboard](https://resend.com/api-keys). Do not share your API key with others or expose it in the browser or other client-side code. To safely store your Resend API key, use a `.env` file. You may need to include this instruction in your prompt to bolt.new. Learn more about [handling API keys](/knowledge-base/how-to-handle-api-keys). ## 2. Add a custom domain to your Resend account By default, you can only send emails to your own email address. To send emails to other email addresses: 1. Add a [custom domain to your Resend account](https://resend.com/domains). 2. Add the custom domain to the `from` field in the `resend` function in Bolt.new (or ask the chat to update these fields). Get more help adding a custom domain in [Resend's documentation](/dashboard/domains/introduction). # Chat SDK Source: https://resend.com/docs/chat-sdk Build conversational email experiences using the Vercel Chat SDK and Resend. # Resend Chat SDK Adapter **Purpose:** Instructions for building bidirectional email bots using the `@resend/chat-sdk-adapter` package with the Vercel Chat SDK. *** ## Setup ### Prerequisites * Resend API key stored in `RESEND_API_KEY` env var * Verified domain at [https://resend.com/domains](https://resend.com/domains) * Webhook configured for `email.received` events (see [https://resend.com/docs/webhooks/introduction](https://resend.com/docs/webhooks/introduction)) * Inbound email receiving enabled (see [https://resend.com/docs/dashboard/receiving/introduction](https://resend.com/docs/dashboard/receiving/introduction)) ### Install ```bash theme={"theme":{"light":"github-light","dark":"vesper"}} npm install @resend/chat-sdk-adapter chat @chat-adapter/state-memory # or: yarn add / pnpm add / bun add ``` ### Initialize ```typescript theme={"theme":{"light":"github-light","dark":"vesper"}} import { createResendAdapter } from '@resend/chat-sdk-adapter'; import { MemoryStateAdapter } from '@chat-adapter/state-memory'; import { Chat } from 'chat'; const resend = createResendAdapter({ fromAddress: 'bot@yourdomain.com', fromName: 'My Bot', // optional // apiKey: "re_...", // or set RESEND_API_KEY env var // webhookSecret: "whsec_..." // or set RESEND_WEBHOOK_SECRET env var }); const chat = new Chat({ userName: 'email-bot', adapters: { resend }, state: new MemoryStateAdapter(), }); ``` ### Handle Inbound Emails ```typescript theme={"theme":{"light":"github-light","dark":"vesper"}} // New email (new thread) chat.onNewMention(async (thread, message) => { await thread.subscribe(); await thread.post(`Got your email: ${message.text}`); }); // Follow-up email in a subscribed thread chat.onSubscribedMessage(async (thread, message) => { await thread.post(`Reply: ${message.text}`); }); ``` ### Forward Webhooks Point Resend webhooks to your server's `/webhook` endpoint. The adapter handles verification and parsing. ```typescript theme={"theme":{"light":"github-light","dark":"vesper"}} // Inside your HTTP server handler for POST /webhook const result = await chat.webhooks.resend(request); ``` `request` must be a Web `Request` object. If you're using Node.js `http`, convert `IncomingMessage` to a `Request` first. *** ## Configuration | Parameter | Type | Required | Description | | --------------- | -------- | -------- | --------------------------------------------------------------------- | | `fromAddress` | `string` | Yes | Sender email address | | `fromName` | `string` | No | Display name for the From header | | `apiKey` | `string` | No | Resend API key. Falls back to `RESEND_API_KEY` env var | | `webhookSecret` | `string` | No | Webhook signing secret. Falls back to `RESEND_WEBHOOK_SECRET` env var | *** ## Threading Threads are resolved automatically using `Message-ID`, `In-Reply-To`, and `References` headers. Reply chains are grouped into Chat SDK threads with no extra configuration. *** ## Card Emails Send rich HTML emails using Card elements: ```typescript theme={"theme":{"light":"github-light","dark":"vesper"}} await thread.post({ card: { type: 'card', title: 'Order Confirmed', children: [ { type: 'text', content: 'Your order #1234 has been shipped.' }, { type: 'divider' }, { type: 'link-button', label: 'Track Order', url: 'https://example.com/track/1234', }, ], }, fallbackText: 'Order #1234 confirmed', }); ``` Cards render to HTML via `@react-email/components`. Always include `fallbackText` for plain-text clients. *** ## Proactive Outreach Start a new email thread without waiting for inbound: ```typescript theme={"theme":{"light":"github-light","dark":"vesper"}} const threadId = await chat.adapters.resend.openDM('user@example.com'); const thread = await chat.thread('resend', threadId); await thread.post('Hello from the bot!'); ``` *** ## Attachments Inbound email attachments are available on `message.raw.attachments`: ```typescript theme={"theme":{"light":"github-light","dark":"vesper"}} chat.onNewMention(async (thread, message) => { const attachments = message.raw?.attachments ?? []; for (const file of attachments) { console.log(file.filename, file.contentType, file.url); } }); ``` *** ## Unsupported Operations Email is immutable. These operations throw `NotImplementedError`: * `editMessage` / `deleteMessage` * `addReaction` / `removeReaction` * `startTyping` *** ## AI Model Instructions 1. **Always** use `createResendAdapter` from `@resend/chat-sdk-adapter` 2. **Always** store API keys in env vars, never hardcode 3. **Always** call `thread.subscribe()` in `onNewMention` if you want to receive follow-ups 4. **Always** include `fallbackText` when sending card emails 5. **Never** attempt `editMessage`, `deleteMessage`, `addReaction`, `removeReaction`, or `startTyping` — email does not support these 6. The webhook handler expects a Web `Request` object — convert Node.js `IncomingMessage` if needed 7. The adapter name in Chat config must be `"resend"` for thread routing to work For the full Resend docs: [https://resend.com/docs/llms-full.txt](https://resend.com/docs/llms-full.txt) The `@resend/chat-sdk-adapter` package is a [Vercel Chat SDK](https://github.com/nichochar/chat) adapter that turns email into a two-way communication channel via Resend. Receive inbound emails through webhooks, reply through the Resend API, and let the adapter handle threading automatically. The adapter is open source and [available on GitHub](https://github.com/resend/resend-chat-sdk). ## Prerequisites To get started, you'll need to: * [Create an API key](https://resend.com/api-keys) * [Verify your domain](https://resend.com/domains) * [Set up webhooks](/webhooks/introduction) for `email.received` events * [Enable receiving](/dashboard/receiving/introduction) on your domain ## 1. Install ```bash npm theme={"theme":{"light":"github-light","dark":"vesper"}} npm install @resend/chat-sdk-adapter chat @chat-adapter/state-memory ``` ```bash yarn theme={"theme":{"light":"github-light","dark":"vesper"}} yarn add @resend/chat-sdk-adapter chat @chat-adapter/state-memory ``` ```bash pnpm theme={"theme":{"light":"github-light","dark":"vesper"}} pnpm add @resend/chat-sdk-adapter chat @chat-adapter/state-memory ``` ```bash bun theme={"theme":{"light":"github-light","dark":"vesper"}} bun add @resend/chat-sdk-adapter chat @chat-adapter/state-memory ``` ## 2. Configure the adapter Create a Resend adapter and pass it to the Chat SDK. ```ts theme={"theme":{"light":"github-light","dark":"vesper"}} import { createResendAdapter } from '@resend/chat-sdk-adapter'; import { MemoryStateAdapter } from '@chat-adapter/state-memory'; import { Chat } from 'chat'; const resend = createResendAdapter({ fromAddress: 'bot@yourdomain.com', fromName: 'My Bot', }); const chat = new Chat({ userName: 'email-bot', adapters: { resend }, state: new MemoryStateAdapter(), }); ``` Set `RESEND_API_KEY` and `RESEND_WEBHOOK_SECRET` as environment variables. You can also pass `apiKey` and `webhookSecret` directly in the config — explicit values take precedence over env vars. ### Configuration options | Parameter | Type | Required | Description | | --------------- | -------- | -------- | --------------------------------------------------------------------- | | `fromAddress` | `string` | Yes | Sender email address | | `fromName` | `string` | No | Display name for the From header | | `apiKey` | `string` | No | Resend API key. Falls back to `RESEND_API_KEY` env var | | `webhookSecret` | `string` | No | Webhook signing secret. Falls back to `RESEND_WEBHOOK_SECRET` env var | ## 3. Handle inbound emails Register handlers for incoming emails. `onNewMention` fires when a new thread starts, and `onSubscribedMessage` fires for follow-up emails in threads you've subscribed to. ```ts theme={"theme":{"light":"github-light","dark":"vesper"}} chat.onNewMention(async (thread, message) => { console.log(`New email from ${message.author.userId}: ${message.text}`); await thread.subscribe(); await thread.post(`Got your email: ${message.text}`); }); chat.onSubscribedMessage(async (thread, message) => { await thread.post(`Reply: ${message.text}`); }); ``` ## 4. Forward webhooks Point your Resend webhooks to your server's `/webhook` endpoint. The adapter verifies the signature and parses the payload. ```ts theme={"theme":{"light":"github-light","dark":"vesper"}} if (req.method === 'POST' && req.url === '/webhook') { const result = await chat.webhooks.resend(request); res.writeHead(result.status); res.end(); } ``` The handler expects a Web `Request` object. If you're using Node.js `http`, convert `IncomingMessage` to a `Request` first — see the [basic example](https://github.com/resend/resend-chat-sdk/tree/main/examples/basic) for a full working server. For webhook setup details, see [Managing Webhooks](/webhooks/introduction) and [Verify Webhook Requests](/webhooks/verify-webhooks-requests). ## How threading works The adapter resolves threads using standard `Message-ID`, `In-Reply-To`, and `References` email headers. Reply chains are automatically grouped into Chat SDK threads — no extra configuration needed. Email is immutable. The following operations throw `NotImplementedError`: `editMessage`, `deleteMessage`, `addReaction`, `removeReaction`, and `startTyping`. ## Features Send rich HTML emails with structured card elements. Handle inbound email attachments. Start new email threads without waiting for inbound. ## Examples Echo bot that replies to every email Styled card email on first contact Proactive outbound via openDM and HTTP POST Multi-turn conversations with subscribe/unsubscribe Detect attachments and reply with a summary # Chat SDK Attachments Source: https://resend.com/docs/chat-sdk-attachments Handle inbound email attachments with the Chat SDK adapter. When someone sends an email with file attachments, the adapter makes them available on `message.raw.attachments`. Each attachment includes the filename, MIME type, and a URL to download the content. ## Attachment shape ```ts theme={"theme":{"light":"github-light","dark":"vesper"}} interface ResendAttachment { filename: string; contentType: string; url?: string; } ``` | Field | Type | Description | | ------------- | -------- | ------------------------------------------------ | | `filename` | `string` | Original filename (e.g., `invoice.pdf`) | | `contentType` | `string` | MIME type (e.g., `application/pdf`) | | `url` | `string` | Optional download URL for the attachment content | ## Detecting and processing attachments ```ts theme={"theme":{"light":"github-light","dark":"vesper"}} chat.onNewMention(async (thread, message) => { const attachments = message.raw?.attachments ?? []; if (attachments.length === 0) { await thread.subscribe(); await thread.post('Got your email — no attachments found.'); return; } const summary = attachments .map((a) => `${a.filename} (${a.contentType})`) .join(', '); await thread.subscribe(); await thread.post(`Received ${attachments.length} attachment(s): ${summary}`); }); ``` For more on receiving email attachments outside the Chat SDK, see [Receiving Attachments](/dashboard/receiving/attachments). ## Try it yourself Detects attachments and replies with a summary # Chat SDK Card Emails Source: https://resend.com/docs/chat-sdk-card-emails Send rich HTML card emails using the Chat SDK and React Email. The Chat SDK adapter renders Card elements into styled HTML emails using `@react-email/components`. This lets you send structured, branded messages without writing raw HTML. ## Card structure A card has a `type`, `title`, optional `subtitle`, and `children` array. Children can be text blocks, dividers, link buttons, or action groups. ```ts theme={"theme":{"light":"github-light","dark":"vesper"}} import type { CardElement } from 'chat'; const card: CardElement = { type: 'card', title: 'Order Confirmed', subtitle: 'Order #1234', children: [ { type: 'text', content: 'Your order has been shipped.' }, { type: 'divider' }, { type: 'actions', children: [ { type: 'link-button', label: 'Track Order', url: 'https://example.com/track/1234', }, ], }, ], }; ``` ### Child element types | Type | Fields | Description | | ------------- | -------------- | --------------------------------- | | `text` | `content` | Plain text paragraph | | `divider` | — | Horizontal rule | | `link-button` | `label`, `url` | Clickable button that opens a URL | | `actions` | `children` | Container for link buttons | ## Sending a card Pass the card object and a `fallbackText` string to `thread.post()`. The fallback is used by email clients that don't render HTML. ```ts theme={"theme":{"light":"github-light","dark":"vesper"}} chat.onNewMention(async (thread, message) => { await thread.subscribe(); await thread.post({ card: { type: 'card', title: 'Welcome!', subtitle: 'Thanks for reaching out', children: [ { type: 'text', content: "Hi! Thanks for emailing us. We'll get back to you shortly.", }, { type: 'divider' }, { type: 'actions', children: [ { type: 'link-button', label: 'Visit our website', url: 'https://resend.com', }, ], }, ], }, fallbackText: 'Welcome! Thanks for reaching out.', }); }); ``` Always include `fallbackText`. Some email clients strip HTML entirely, and the fallback text is what recipients will see in that case. ## Try it yourself Full working example that sends a styled card on first contact # Chat SDK Proactive Outreach Source: https://resend.com/docs/chat-sdk-proactive-outreach Start new email conversations proactively with the Chat SDK adapter. By default, the Chat SDK adapter responds to inbound emails. With `openDM`, you can go the other way — start a new email thread with any address, without waiting for them to email you first. ## Sending a proactive email Call `openDM` on the adapter to create a new thread, then post a message to it. ```ts theme={"theme":{"light":"github-light","dark":"vesper"}} const threadId = await chat.adapters.resend.openDM('user@example.com'); const thread = await chat.thread('resend', threadId); await thread.post('Hello from the bot!'); ``` You can also send card emails in proactive threads — the same card structure from [Card Emails](/chat-sdk-card-emails) works here. ## Triggering via HTTP A common pattern is exposing an HTTP endpoint that triggers outbound emails. This lets external systems (cron jobs, webhooks from other services, admin dashboards) send emails through your bot. ```ts theme={"theme":{"light":"github-light","dark":"vesper"}} async function handleNotify(req, res) { const { to, message } = JSON.parse(await readBody(req)); const threadId = await chat.adapters.resend.openDM(to); const thread = await chat.thread('resend', threadId); await thread.post(message); res.writeHead(200, { 'Content-Type': 'application/json' }); res.end(JSON.stringify({ ok: true, threadId })); } ``` Then call it: ```bash theme={"theme":{"light":"github-light","dark":"vesper"}} curl -X POST http://localhost:3000/notify \ -H "Content-Type: application/json" \ -d '{"to": "user@example.com", "message": "Your order has shipped!"}' ``` ## When to use this * Welcome emails when a user signs up * Order confirmations and shipping updates * Alert notifications (monitoring, billing, security) * Scheduled digests or reminders If the recipient replies, the response arrives through the normal `onNewMention` or `onSubscribedMessage` handlers — the threading is handled automatically. ## Try it yourself Proactive outbound emails via openDM and an HTTP POST endpoint # Introduction Source: https://resend.com/docs/dashboard/api-keys/introduction Visualize all the API Keys on the Resend Dashboard. ## What is an API Key API Keys are secret tokens used to authenticate your requests. They are unique to your account and should be kept confidential. ## Add API Key You can create a new API Key from the [API Key Dashboard](https://resend.com/api-keys). 1. Click **Create API Key**. 2. Give your API Key a name (maximum 50 characters). 3. Select **Full access** or **Sending access** as the permission. 4. If you select **Sending access**, you can choose the domain you want to restrict access to. Add API Key For security reasons, you can only view the API Key once. Learn more about [API key best practices](/knowledge-base/how-to-handle-api-keys). ## Set API Key permissions There are two different permissions of API Keys: 1. **Full access**: grants access to create, delete, get, and update any resource. 2. **Sending access**: grants access only to send emails. With API Key permissions, you can isolate different application actions to different API Keys. Using multiple keys, you can view logs per key, detect possible abuse, and control the damage that may be done accidentally or maliciously. ## View all API Keys The [API Dashboard](https://resend.com/api-keys) shows you all the API Keys you have created along with their details, including the **last time you used** an API Key. Different color indicators let you quickly scan and detect which API Keys are being used and which are not. View All API Keys ## Edit API Key details After creating an API Key, you can edit the following details: * Name * Permission * Domain To edit an API Key, click the **More options** button and then **Edit API Key**. View Inactive API Key You cannot edit an API Key value after it has been created. ## Delete inactive API Keys If an API Key **hasn't been used in the last 30 days**, consider deleting it to keep your account secure. View Inactive API Key You can delete an API Key by clicking the **More options** button and then **Remove API Key**. Delete API Key ## View API Key logs When visualizing an active API Key, you can see the **total number of requests** made to the key. For more detailed logging information, select the underlined number of requests to view all logs for that API Key. View Active API Key ## Export your data Admins can download your data in CSV format for the following resources: * Emails * Broadcasts * Contacts * Segments * Domains * Logs * API keys Currently, exports are limited to admin users of your team. To start, apply filters to your data and click on the "Export" button. Confirm your filters before exporting your data.