# 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. export const ResendParamField = ({children, body, path, ...props}) => { const [lang, setLang] = useState(() => { return localStorage.getItem('code') || '"Node.js"'; }); useEffect(() => { const onStorage = event => { const key = event.detail.key; if (key === 'code') { setLang(event.detail.value); } }; document.addEventListener('mintlify-localstorage', onStorage); return () => { document.removeEventListener('mintlify-localstorage', onStorage); }; }, []); const toCamelCase = str => typeof str === 'string' ? str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase()) : str; const resolvedBody = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(body) : body; }, [body, lang]); const resolvedPath = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(path) : path; }, [path, lang]); return {children} ; }; ## Body Parameters The API key name. 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={null} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.apiKeys.create({ name: 'Production' }); ``` ```php PHP theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->apiKeys->create([ 'name' => 'Production' ]); ``` ```python Python theme={null} import resend resend.api_key = "re_xxxxxxxxx" params: resend.ApiKeys.CreateParams = { "name": "Production", } resend.ApiKeys.create(params) ``` ```ruby Ruby theme={null} require "resend" Resend.api_key = "re_xxxxxxxxx" params = { name: "Production" } Resend::ApiKeys.create(params) ``` ```go Go theme={null} import "github.com/resend/resend-go/v2" client := resend.NewClient("re_xxxxxxxxx") params := &resend.CreateApiKeyRequest{ Name: "Production", } apiKey, _ := client.ApiKeys.Create(params) ``` ```rust Rust theme={null} 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={null} 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={null} 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={null} 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={null} { "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. export const ResendParamField = ({children, body, path, ...props}) => { const [lang, setLang] = useState(() => { return localStorage.getItem('code') || '"Node.js"'; }); useEffect(() => { const onStorage = event => { const key = event.detail.key; if (key === 'code') { setLang(event.detail.value); } }; document.addEventListener('mintlify-localstorage', onStorage); return () => { document.removeEventListener('mintlify-localstorage', onStorage); }; }, []); const toCamelCase = str => typeof str === 'string' ? str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase()) : str; const resolvedBody = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(body) : body; }, [body, lang]); const resolvedPath = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(path) : path; }, [path, lang]); return {children} ; }; ## Path Parameters The API key ID. ```ts Node.js theme={null} 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={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->apiKeys->remove('b6d24b8e-af0b-4c3c-be0c-359bbd97381e'); ``` ```python Python theme={null} import resend resend.api_key = "re_xxxxxxxxx" resend.ApiKeys.remove(api_key_id="b6d24b8e-af0b-4c3c-be0c-359bbd97381e") ``` ```ruby Ruby theme={null} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::ApiKeys.remove "b6d24b8e-af0b-4c3c-be0c-359bbd97381e" ``` ```go Go theme={null} import "github.com/resend/resend-go/v2" client := resend.NewClient("re_xxxxxxxxx") client.ApiKeys.Remove("b6d24b8e-af0b-4c3c-be0c-359bbd97381e") ``` ```rust Rust theme={null} 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={null} 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={null} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI await resend.ApiKeyDeleteAsync( new Guid( "b6d24b8e-af0b-4c3c-be0c-359bbd97381e" ) ); ``` ```bash cURL theme={null} curl -X DELETE 'https://api.resend.com/api-keys/b6d24b8e-af0b-4c3c-be0c-359bbd97381e' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```text Response theme={null} 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. ## Query Parameters Note that the `limit` parameter is *optional*. If you do not provide a `limit`, all API keys will be returned in a single response. Number of API keys to retrieve. Maximum is `100`, and minimum is `1`. The ID *after* which we'll retrieve more API keys (for pagination). This ID will *not* be included in the returned list. Cannot be used with the `before` parameter. The ID *before* which we'll retrieve more API keys (for pagination). This ID will *not* be included in the returned list. Cannot be used with the `after` parameter. ```ts Node.js theme={null} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.apiKeys.list(); ``` ```php PHP theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->apiKeys->list(); ``` ```python Python theme={null} import resend resend.api_key = "re_xxxxxxxxx" resend.ApiKeys.list() ``` ```ruby Ruby theme={null} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::ApiKeys.list ``` ```go Go theme={null} import "github.com/resend/resend-go/v2" client := resend.NewClient("re_xxxxxxxxx") keys, err := client.ApiKeys.List() ``` ```rust Rust theme={null} 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={null} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); resend.apiKeys().list(); } } ``` ```csharp .NET theme={null} 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={null} curl -X GET 'https://api.resend.com/api-keys' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={null} { "object": "list", "has_more": false, "data": [ { "id": "91f3200a-df72-4654-b0cd-f202395f5354", "name": "Production", "created_at": "2023-04-08T00:11:13.110779+00:00" } ] } ``` # List Inbound Email Attachments Source: https://resend.com/docs/api-reference/attachments/list-inbound-email-attachments GET /emails/receiving/:email_id/attachments Retrieve a list of email attachments and their contents. Inbound emails are currently in private beta and only available to a limited number of users. APIs might change before GA. To use the methods on this page, you must upgrade your Resend SDK: ```bash Node.js theme={null} npm install resend@6.3.0-canary.0 ``` ```php PHP theme={null} // PHP SDK is not available yet ``` ```python Python theme={null} # Python SDK is not available yet ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet ``` ```go Go theme={null} // Go SDK is not available yet ``` ```rust Rust theme={null} // Rust SDK is not available yet ``` ```java Java theme={null} // Java SDK is not available yet ``` ```csharp .NET theme={null} // C# SDK is not available yet ``` [Join the waitlist](https://resend.com/inbound) if you're interested in testing this feature. ## Query Parameters Note that the `limit` parameter is *optional*. If you do not provide a `limit` we'll default to `20` attachments. Number of emails to retrieve. Maximum is `100`, and minimum is `1`. The default `limit` is `20`. The ID *after* which we'll retrieve more attachments (for pagination). This ID will *not* be included in the returned list. Cannot be used with the `before` parameter. The ID *before* which we'll retrieve more attachments (for pagination). This ID will *not* be included in the returned list. Cannot be used with the `after` parameter. ## Path Parameters The Email ID. ```ts Node.js theme={null} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.attachments.receiving.list({ emailId: '4ef9a417-02e9-4d39-ad75-9611e0fcc33c', }); ``` ```php PHP theme={null} // PHP SDK is not available yet ``` ```python Python theme={null} # Python SDK is not available yet ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet ``` ```go Go theme={null} // Go SDK is not available yet ``` ```rust Rust theme={null} // Rust SDK is not available yet ``` ```java Java theme={null} // Java SDK is not available yet ``` ```csharp .NET theme={null} // C# SDK is not available yet ``` ```bash cURL theme={null} curl -X GET 'https://api.resend.com/emails/receiving/4ef9a417-02e9-4d39-ad75-9611e0fcc33c/attachments' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={null} { "object": "list", "has_more": false, "data": [ { "id": "2a0c9ce0-3112-4728-976e-47ddcd16a318", "filename": "avatar.png", "content_type": "image/png", "content_disposition": "inline", "content_id": "img001", "content": "somebase64==" } ] } ``` # Retrieve Inbound Email Attachment Source: https://resend.com/docs/api-reference/attachments/retrieve-inbound-email-attachment GET /emails/receiving/:email_id/attachments/:id Retrieve a single attachment from an inbound email. Inbound emails are currently in private beta and only available to a limited number of users. APIs might change before GA. To use the methods on this page, you must upgrade your Resend SDK: ```bash Node.js theme={null} npm install resend@6.3.0-canary.0 ``` ```php PHP theme={null} // PHP SDK is not available yet ``` ```python Python theme={null} # Python SDK is not available yet ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet ``` ```go Go theme={null} // Go SDK is not available yet ``` ```rust Rust theme={null} // Rust SDK is not available yet ``` ```java Java theme={null} // Java SDK is not available yet ``` ```csharp .NET theme={null} // C# SDK is not available yet ``` [Join the waitlist](https://resend.com/inbound) if you're interested in testing this feature. ## Path Parameters The Attachment ID. The Email ID. ```js Node.js theme={null} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.attachments.receiving.get({ id: '2a0c9ce0-3112-4728-976e-47ddcd16a318', emailId: '4ef9a417-02e9-4d39-ad75-9611e0fcc33c', }); ``` ```php PHP theme={null} // PHP SDK is not available yet ``` ```python Python theme={null} # Python SDK is not available yet ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet ``` ```go Go theme={null} // Go SDK is not available yet ``` ```rust Rust theme={null} // Rust SDK is not available yet ``` ```java Java theme={null} // Java SDK is not available yet ``` ```csharp .NET theme={null} // C# SDK is not available yet ``` ```bash cURL theme={null} 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={null} { "object": "attachment", "id": "2a0c9ce0-3112-4728-976e-47ddcd16a318", "filename": "avatar.png", "content_type": "image/png", "content_disposition": "inline", "content_id": "img001", "content": "somebase64==" } ``` # Create Audience Source: https://resend.com/docs/api-reference/audiences/create-audience POST /audiences Create a list of contacts. ## Body Parameters The name of the audience you want to create. ```ts Node.js theme={null} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.audiences.create({ name: 'Registered Users', }); ``` ```php PHP theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->audiences->create([ 'name' => 'Registered Users' ]); ``` ```python Python theme={null} import resend resend.api_key = "re_xxxxxxxxx" params: resend.Audiences.CreateParams = { "name": "Registered Users" } resend.Audiences.create(params) ``` ```ruby Ruby theme={null} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::Audiences.create({ name: "Registered Users" }) ``` ```go Go theme={null} import "github.com/resend/resend-go/v2" client := resend.NewClient("re_xxxxxxxxx") params := &resend.CreateAudienceRequest{ Name: "Registered Users", } audience, err := client.Audiences.Create(params) ``` ```rust Rust theme={null} use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _audience = resend.audiences.create("Registered Users").await?; Ok(()) } ``` ```java Java theme={null} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); CreateAudienceOptions params = CreateAudienceOptions .builder() .name("Registered Users").build(); CreateAudienceResponseSuccess data = resend.audiences().create(params); } } ``` ```csharp .NET theme={null} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.AudienceAddAsync( "Registered Users" ); Console.WriteLine( "AudienceId={0}", resp.Content ); ``` ```bash cURL theme={null} curl -X POST 'https://api.resend.com/audiences' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'{ "name": "Registered Users" }' ``` ```json Response theme={null} { "object": "audience", "id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", "name": "Registered Users" } ``` # Delete Audience Source: https://resend.com/docs/api-reference/audiences/delete-audience DELETE /audiences/:audience_id Remove an existing audience. export const ResendParamField = ({children, body, path, ...props}) => { const [lang, setLang] = useState(() => { return localStorage.getItem('code') || '"Node.js"'; }); useEffect(() => { const onStorage = event => { const key = event.detail.key; if (key === 'code') { setLang(event.detail.value); } }; document.addEventListener('mintlify-localstorage', onStorage); return () => { document.removeEventListener('mintlify-localstorage', onStorage); }; }, []); const toCamelCase = str => typeof str === 'string' ? str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase()) : str; const resolvedBody = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(body) : body; }, [body, lang]); const resolvedPath = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(path) : path; }, [path, lang]); return {children} ; }; ## Path Parameters The Audience ID. ```ts Node.js theme={null} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.audiences.remove( '78261eea-8f8b-4381-83c6-79fa7120f1cf', ); ``` ```php PHP theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->audiences->remove('78261eea-8f8b-4381-83c6-79fa7120f1cf'); ``` ```python Python theme={null} import resend resend.api_key = "re_xxxxxxxxx" resend.Audiences.remove("78261eea-8f8b-4381-83c6-79fa7120f1cf") ``` ```ruby Ruby theme={null} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::Audiences.remove("78261eea-8f8b-4381-83c6-79fa7120f1cf") ``` ```go Go theme={null} import "github.com/resend/resend-go/v2" client := resend.NewClient("re_xxxxxxxxx") removed, err := client.Audiences.Remove("78261eea-8f8b-4381-83c6-79fa7120f1cf") ``` ```rust Rust theme={null} use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _deleted = resend .audiences .delete("78261eea-8f8b-4381-83c6-79fa7120f1cf") .await?; Ok(()) } ``` ```java Java theme={null} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); RemoveAudienceResponseSuccess data = resend.audiences().remove("78261eea-8f8b-4381-83c6-79fa7120f1cf"); } } ``` ```csharp .NET theme={null} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI await resend.AudienceDeleteAsync( new Guid( "78261eea-8f8b-4381-83c6-79fa7120f1cf" ) ); ``` ```bash cURL theme={null} curl -X DELETE 'https://api.resend.com/audiences/78261eea-8f8b-4381-83c6-79fa7120f1cf' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={null} { "object": "audience", "id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", "deleted": true } ``` # Retrieve Audience Source: https://resend.com/docs/api-reference/audiences/get-audience GET /audiences/:audience_id Retrieve a single audience. export const ResendParamField = ({children, body, path, ...props}) => { const [lang, setLang] = useState(() => { return localStorage.getItem('code') || '"Node.js"'; }); useEffect(() => { const onStorage = event => { const key = event.detail.key; if (key === 'code') { setLang(event.detail.value); } }; document.addEventListener('mintlify-localstorage', onStorage); return () => { document.removeEventListener('mintlify-localstorage', onStorage); }; }, []); const toCamelCase = str => typeof str === 'string' ? str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase()) : str; const resolvedBody = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(body) : body; }, [body, lang]); const resolvedPath = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(path) : path; }, [path, lang]); return {children} ; }; ## Path Parameters The Audience ID. ```ts Node.js theme={null} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.audiences.get( '78261eea-8f8b-4381-83c6-79fa7120f1cf', ); ``` ```php PHP theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->audiences->get('78261eea-8f8b-4381-83c6-79fa7120f1cf'); ``` ```python Python theme={null} import resend resend.api_key = "re_xxxxxxxxx" resend.Audiences.get("78261eea-8f8b-4381-83c6-79fa7120f1cf") ``` ```ruby Ruby theme={null} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::Audiences.get("78261eea-8f8b-4381-83c6-79fa7120f1cf") ``` ```go Go theme={null} import "github.com/resend/resend-go/v2" client := resend.NewClient("re_xxxxxxxxx") audience, err := client.Audiences.Get("78261eea-8f8b-4381-83c6-79fa7120f1cf") ``` ```rust Rust theme={null} use resend_rs::{Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _audience = resend .audiences .get("78261eea-8f8b-4381-83c6-79fa7120f1cf") .await?; Ok(()) } ``` ```java Java theme={null} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); GetAudienceResponseSuccess data = resend.audiences().get("78261eea-8f8b-4381-83c6-79fa7120f1cf"); } } ``` ```csharp .NET theme={null} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.AudienceRetrieveAsync( new Guid( "78261eea-8f8b-4381-83c6-79fa7120f1cf" ) ); Console.WriteLine( "Name={0}", resp.Content.Name ); ``` ```bash cURL theme={null} curl -X GET 'https://api.resend.com/audiences/78261eea-8f8b-4381-83c6-79fa7120f1cf' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={null} { "object": "audience", "id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", "name": "Registered Users", "created_at": "2023-10-06T22:59:55.977Z" } ``` # List Audiences Source: https://resend.com/docs/api-reference/audiences/list-audiences GET /audiences Retrieve a list of audiences. ## Query Parameters Note that the `limit` parameter is *optional*. If you do not provide a `limit`, all audiences will be returned in a single response. Number of audiences to retrieve. Maximum is `100`, and minimum is `1`. The ID *after* which we'll retrieve more audiences (for pagination). This ID will *not* be included in the returned list. Cannot be used with the `before` parameter. The ID *before* which we'll retrieve more audiences (for pagination). This ID will *not* be included in the returned list. Cannot be used with the `after` parameter. ```ts Node.js theme={null} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.audiences.list(); ``` ```php PHP theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->audiences->list(); ``` ```python Python theme={null} import resend resend.api_key = "re_xxxxxxxxx" resend.Audiences.list() ``` ```ruby Ruby theme={null} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::Audiences.list ``` ```go Go theme={null} import "github.com/resend/resend-go/v2" client := resend.NewClient("re_xxxxxxxxx") audiences, err := client.Audiences.List() ``` ```rust Rust theme={null} use resend_rs::{Resend, Result, list_opts::ListOptions}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let _audiences = resend.audiences.list(ListOptions::default()).await?; Ok(()) } ``` ```java Java theme={null} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); ListAudiencesResponseSuccess data = resend.audiences().list(); } } ``` ```csharp .NET theme={null} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.AudienceListAsync(); Console.WriteLine( "Nr Audience={0}", resp.Content.Count ); ``` ```bash cURL theme={null} curl -X GET 'https://api.resend.com/audiences' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={null} { "object": "list", "has_more": false, "data": [ { "id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", "name": "Registered Users", "created_at": "2023-10-06T22:59:55.977Z" } ] } ``` # Create Broadcast Source: https://resend.com/docs/api-reference/broadcasts/create-broadcast POST /broadcasts Create a new broadcast to send to your audience. export const ResendParamField = ({children, body, path, ...props}) => { const [lang, setLang] = useState(() => { return localStorage.getItem('code') || '"Node.js"'; }); useEffect(() => { const onStorage = event => { const key = event.detail.key; if (key === 'code') { setLang(event.detail.value); } }; document.addEventListener('mintlify-localstorage', onStorage); return () => { document.removeEventListener('mintlify-localstorage', onStorage); }; }, []); const toCamelCase = str => typeof str === 'string' ? str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase()) : str; const resolvedBody = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(body) : body; }, [body, lang]); const resolvedPath = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(path) : path; }, [path, lang]); return {children} ; }; ## Body Parameters The ID of the audience you want to send to. 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={null} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.broadcasts.create({ audienceId: '78261eea-8f8b-4381-83c6-79fa7120f1cf', from: 'Acme ', subject: 'hello world', html: 'Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}', }); ``` ```rust Rust theme={null} use resend_rs::{types::CreateBroadcastOptions, Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let audience_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(audience_id, from, subject).with_html(html); let _broadcast = resend.broadcasts.create(opts).await?; Ok(()) } ``` ```php PHP theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->broadcasts->create([ 'audience_id' => '78261eea-8f8b-4381-83c6-79fa7120f1cf', 'from' => 'Acme ', 'subject' => 'hello world', 'html' => 'Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}', ]); ``` ```java Java theme={null} Resend resend = new Resend("re_xxxxxxxxx"); CreateBroadcastOptions params = CreateBroadcastOptions.builder() .audienceId("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); ``` ```py Python theme={null} import resend resend.api_key = "re_xxxxxxxxx" params: resend.Broadcasts.CreateParams = { "audience_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) ``` ```ruby Ruby theme={null} require "resend" Resend.api_key = "re_xxxxxxxxx" params = { "audience_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) ``` ```go Go theme={null} import "fmt" import "github.com/resend/resend-go/v2" client := resend.NewClient("re_xxxxxxxxx") params := &resend.CreateBroadcastRequest{ AudienceId: "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) ``` ```csharp .NET theme={null} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.BroadcastAddAsync( new BroadcastData() { DisplayName = "Example Broadcast", AudienceId = 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 ); ``` ```bash cURL theme={null} curl -X POST 'https://api.resend.com/broadcasts' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'{ "audience_id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", "from": "Acme ", "subject": "hello world", "html": "Hi {{{FIRST_NAME|there}}}, you can unsubscribe here: {{{RESEND_UNSUBSCRIBE_URL}}}" }' ``` ```json Response theme={null} { "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. export const ResendParamField = ({children, body, path, ...props}) => { const [lang, setLang] = useState(() => { return localStorage.getItem('code') || '"Node.js"'; }); useEffect(() => { const onStorage = event => { const key = event.detail.key; if (key === 'code') { setLang(event.detail.value); } }; document.addEventListener('mintlify-localstorage', onStorage); return () => { document.removeEventListener('mintlify-localstorage', onStorage); }; }, []); const toCamelCase = str => typeof str === 'string' ? str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase()) : str; const resolvedBody = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(body) : body; }, [body, lang]); const resolvedPath = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(path) : path; }, [path, lang]); return {children} ; }; 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={null} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.broadcasts.remove( '559ac32e-9ef5-46fb-82a1-b76b840c0f7b', ); ``` ```rust Rust theme={null} 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(()) } ``` ```php PHP theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->broadcasts->remove('559ac32e-9ef5-46fb-82a1-b76b840c0f7b'); ``` ```java Java theme={null} Resend resend = new Resend("re_xxxxxxxxx"); RemoveBroadcastResponseSuccess data = resend.broadcasts().remove("559ac32e-9ef5-46fb-82a1-b76b840c0f7b"); ``` ```py Python theme={null} import resend resend.api_key = "re_xxxxxxxxx" resend.Broadcasts.remove(id="559ac32e-9ef5-46fb-82a1-b76b840c0f7b") ``` ```ruby Ruby theme={null} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::Broadcasts.remove("559ac32e-9ef5-46fb-82a1-b76b840c0f7b") ``` ```go Go theme={null} import "github.com/resend/resend-go/v2" client := resend.NewClient("re_xxxxxxxxx") removed, _ := client.Broadcasts.Remove("559ac32e-9ef5-46fb-82a1-b76b840c0f7b") ``` ```csharp .NET theme={null} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI await resend.BroadcastDeleteAsync( new Guid( "559ac32e-9ef5-46fb-82a1-b76b840c0f7b" ) ); ``` ```bash cURL theme={null} curl -X DELETE 'https://api.resend.com/broadcasts/559ac32e-9ef5-46fb-82a1-b76b840c0f7b' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={null} { "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. export const ResendParamField = ({children, body, path, ...props}) => { const [lang, setLang] = useState(() => { return localStorage.getItem('code') || '"Node.js"'; }); useEffect(() => { const onStorage = event => { const key = event.detail.key; if (key === 'code') { setLang(event.detail.value); } }; document.addEventListener('mintlify-localstorage', onStorage); return () => { document.removeEventListener('mintlify-localstorage', onStorage); }; }, []); const toCamelCase = str => typeof str === 'string' ? str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase()) : str; const resolvedBody = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(body) : body; }, [body, lang]); const resolvedPath = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(path) : path; }, [path, lang]); return {children} ; }; 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={null} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.broadcasts.get( '559ac32e-9ef5-46fb-82a1-b76b840c0f7b', ); ``` ```rust Rust theme={null} 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(()) } ``` ```php PHP theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->broadcasts->get('559ac32e-9ef5-46fb-82a1-b76b840c0f7b'); ``` ```java Java theme={null} Resend resend = new Resend("re_xxxxxxxxx"); GetBroadcastResponseSuccess data = resend.broadcasts().get("559ac32e-9ef5-46fb-82a1-b76b840c0f7b"); ``` ```py Python theme={null} import resend resend.api_key = "re_xxxxxxxxx" resend.Broadcasts.get(id="559ac32e-9ef5-46fb-82a1-b76b840c0f7b") ``` ```ruby Ruby theme={null} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::Broadcasts.get("559ac32e-9ef5-46fb-82a1-b76b840c0f7b") ``` ```go Go theme={null} import "github.com/resend/resend-go/v2" client := resend.NewClient("re_xxxxxxxxx") broadcast, _ := client.Broadcasts.Get("559ac32e-9ef5-46fb-82a1-b76b840c0f7b") ``` ```csharp .NET theme={null} 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={null} curl -X GET 'https://api.resend.com/broadcasts/559ac32e-9ef5-46fb-82a1-b76b840c0f7b' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={null} { "object": "broadcast", "id": "559ac32e-9ef5-46fb-82a1-b76b840c0f7b", "name": "Announcements", "audience_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). ## Query Parameters Note that the `limit` parameter is *optional*. If you do not provide a `limit`, all broadcasts will be returned in a single response. Number of broadcasts to retrieve. Maximum is `100`, and minimum is `1`. The ID *after* which we'll retrieve more broadcasts (for pagination). This ID will *not* be included in the returned list. Cannot be used with the `before` parameter. The ID *before* which we'll retrieve more broadcasts (for pagination). This ID will *not* be included in the returned list. Cannot be used with the `after` parameter. ```ts Node.js theme={null} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.broadcasts.list(); ``` ```rust Rust theme={null} 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(()) } ``` ```php PHP theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->broadcasts->list(); ``` ```java Java theme={null} Resend resend = new Resend("re_xxxxxxxxx"); ListBroadcastsResponseSuccess data = resend.broadcasts().list(); ``` ```py Python theme={null} import resend resend.api_key = "re_xxxxxxxxx" resend.Broadcasts.list() ``` ```ruby Ruby theme={null} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::Broadcasts.list() ``` ```go Go theme={null} import "github.com/resend/resend-go/v2" client := resend.NewClient("re_xxxxxxxxx") broadcasts, _ := client.Broadcasts.List() ``` ```csharp .NET theme={null} 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={null} curl -X GET 'https://api.resend.com/broadcasts' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={null} { "object": "list", "has_more": false, "data": [ { "id": "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794", "audience_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", "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. export const ResendParamField = ({children, body, path, ...props}) => { const [lang, setLang] = useState(() => { return localStorage.getItem('code') || '"Node.js"'; }); useEffect(() => { const onStorage = event => { const key = event.detail.key; if (key === 'code') { setLang(event.detail.value); } }; document.addEventListener('mintlify-localstorage', onStorage); return () => { document.removeEventListener('mintlify-localstorage', onStorage); }; }, []); const toCamelCase = str => typeof str === 'string' ? str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase()) : str; const resolvedBody = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(body) : body; }, [body, lang]); const resolvedPath = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(path) : path; }, [path, lang]); return {children} ; }; 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={null} 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', }, ); ``` ```rust Rust theme={null} 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(()) } ``` ```php PHP theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->broadcasts->send('559ac32e-9ef5-46fb-82a1-b76b840c0f7b', [ 'scheduled_at' => 'in 1 min', ]); ``` ```java Java theme={null} 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"); ``` ```py Python theme={null} 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={null} 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={null} import "github.com/resend/resend-go/v2" client := resend.NewClient("re_xxxxxxxxx") sendParams := &resend.SendBroadcastRequest{ BroadcastId: "559ac32e-9ef5-46fb-82a1-b76b840c0f7b", ScheduledAt: "in 1 min", } sent, _ := client.Broadcasts.Send(sendParams) ``` ```csharp .NET theme={null} 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={null} 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={null} { "id": "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794" } ``` # Update Broadcast Source: https://resend.com/docs/api-reference/broadcasts/update-broadcast PATCH /broadcasts/:id Update a broadcast to send to your audience. export const ResendParamField = ({children, body, path, ...props}) => { const [lang, setLang] = useState(() => { return localStorage.getItem('code') || '"Node.js"'; }); useEffect(() => { const onStorage = event => { const key = event.detail.key; if (key === 'code') { setLang(event.detail.value); } }; document.addEventListener('mintlify-localstorage', onStorage); return () => { document.removeEventListener('mintlify-localstorage', onStorage); }; }, []); const toCamelCase = str => typeof str === 'string' ? str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase()) : str; const resolvedBody = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(body) : body; }, [body, lang]); const resolvedPath = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(path) : path; }, [path, lang]); return {children} ; }; ## Path Parameters The ID of the broadcast you want to update. ## Body Parameters The ID of the audience you want to send to. 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={null} 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}}}', }, ); ``` ```rust Rust theme={null} 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(()) } ``` ```php PHP theme={null} $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}}}', ]); ``` ```java Java theme={null} 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); ``` ```py Python theme={null} 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={null} 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={null} import "fmt" import "github.com/resend/resend-go/v2" client := resend.NewClient("re_xxxxxxxxx") params := &resend.UpdateBroadcastRequest{ Id: "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794", Html: fmt.Sprintf("Hi %s, you can unsubscribe here: %s", FIRST_NAME, RESEND_UNSUBSCRIBE_URL), } broadcast, _ := client.Broadcasts.Update(params) ``` ```csharp .NET theme={null} 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={null} 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={null} { "id": "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794" } ``` # Create Contact Source: https://resend.com/docs/api-reference/contacts/create-contact POST /audiences/:audience_id/contacts Create a contact inside an audience. export const ResendParamField = ({children, body, path, ...props}) => { const [lang, setLang] = useState(() => { return localStorage.getItem('code') || '"Node.js"'; }); useEffect(() => { const onStorage = event => { const key = event.detail.key; if (key === 'code') { setLang(event.detail.value); } }; document.addEventListener('mintlify-localstorage', onStorage); return () => { document.removeEventListener('mintlify-localstorage', onStorage); }; }, []); const toCamelCase = str => typeof str === 'string' ? str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase()) : str; const resolvedBody = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(body) : body; }, [body, lang]); const resolvedPath = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(path) : path; }, [path, lang]); return {children} ; }; ## Body Parameters The email address of the contact. The Audience ID. The first name of the contact. The last name of the contact. The subscription status. ```ts Node.js theme={null} 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, audienceId: '78261eea-8f8b-4381-83c6-79fa7120f1cf', }); ``` ```php PHP theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->contacts->create( audienceId: '78261eea-8f8b-4381-83c6-79fa7120f1cf', parameters: [ 'email' => 'steve.wozniak@gmail.com', 'first_name' => 'Steve', 'last_name' => 'Wozniak', 'unsubscribed' => false ] ); ``` ```python Python theme={null} import resend resend.api_key = "re_xxxxxxxxx" params: resend.Contacts.CreateParams = { "email": "steve.wozniak@gmail.com", "first_name": "Steve", "last_name": "Wozniak", "unsubscribed": False, "audience_id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", } resend.Contacts.create(params) ``` ```ruby Ruby theme={null} require "resend" Resend.api_key = "re_xxxxxxxxx" params = { "email": "steve.wozniak@gmail.com", "first_name": "Steve", "last_name": "Wozniak", "unsubscribed": false, "audience_id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", } Resend::Contacts.create(params) ``` ```go Go theme={null} import "github.com/resend/resend-go/v2" client := resend.NewClient("re_xxxxxxxxx") params := &resend.CreateContactRequest{ Email: "steve.wozniak@gmail.com", FirstName: "Steve", LastName: "Wozniak", Unsubscribed: false, AudienceId: "78261eea-8f8b-4381-83c6-79fa7120f1cf", } contact, err := client.Contacts.Create(params) ``` ```rust Rust theme={null} use resend_rs::{types::ContactData, Resend, Result}; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let contact = ContactData::new("steve.wozniak@gmail.com") .with_first_name("Steve") .with_last_name("Wozniak") .with_unsubscribed(false); let _contact = resend .contacts .create("78261eea-8f8b-4381-83c6-79fa7120f1cf", contact) .await?; Ok(()) } ``` ```java Java theme={null} 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) .audienceId("78261eea-8f8b-4381-83c6-79fa7120f1cf") .build(); CreateContactResponseSuccess data = resend.contacts().create(params); } } ``` ```csharp .NET theme={null} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.ContactAddAsync( new Guid( "78261eea-8f8b-4381-83c6-79fa7120f1cf" ), new ContactData() { Email = "steve.wozniak@gmail.com", FirstName = "Steve", LastName = "Wozniak", IsUnsubscribed = false, } ); Console.WriteLine( "Contact Id={0}", resp.Content ); ``` ```bash cURL theme={null} curl -X POST 'https://api.resend.com/audiences/78261eea-8f8b-4381-83c6-79fa7120f1cf/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={null} { "object": "contact", "id": "479e3145-dd38-476b-932c-529ceb705947" } ``` # Delete Contact Source: https://resend.com/docs/api-reference/contacts/delete-contact DELETE /audiences/:audience_id/contacts/:id Remove an existing contact from an audience. export const ResendParamField = ({children, body, path, ...props}) => { const [lang, setLang] = useState(() => { return localStorage.getItem('code') || '"Node.js"'; }); useEffect(() => { const onStorage = event => { const key = event.detail.key; if (key === 'code') { setLang(event.detail.value); } }; document.addEventListener('mintlify-localstorage', onStorage); return () => { document.removeEventListener('mintlify-localstorage', onStorage); }; }, []); const toCamelCase = str => typeof str === 'string' ? str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase()) : str; const resolvedBody = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(body) : body; }, [body, lang]); const resolvedPath = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(path) : path; }, [path, lang]); return {children} ; }; ## Path Parameters The Audience ID. Either `id` or `email` must be provided. The Contact ID. The Contact email. ```ts Node.js theme={null} 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', audienceId: '78261eea-8f8b-4381-83c6-79fa7120f1cf', }); // Delete by contact email const { data, error } = await resend.contacts.remove({ email: 'acme@example.com', audienceId: '78261eea-8f8b-4381-83c6-79fa7120f1cf', }); ``` ```php PHP theme={null} $resend = Resend::client('re_xxxxxxxxx'); // Delete by contact id $resend->contacts->remove( audienceId: '78261eea-8f8b-4381-83c6-79fa7120f1cf', id: '520784e2-887d-4c25-b53c-4ad46ad38100' ); // Delete by contact email $resend->contacts->remove( audienceId: '78261eea-8f8b-4381-83c6-79fa7120f1cf', email: 'acme@example.com' ); ``` ```python Python theme={null} import resend resend.api_key = "re_xxxxxxxxx" # Delete by contact id resend.Contacts.remove( id="520784e2-887d-4c25-b53c-4ad46ad38100", audience_id="78261eea-8f8b-4381-83c6-79fa7120f1cf" ) # Delete by contact email resend.Contacts.remove( email="acme@example.com", audience_id="78261eea-8f8b-4381-83c6-79fa7120f1cf" ) ``` ```ruby Ruby theme={null} require "resend" Resend.api_key = "re_xxxxxxxxx" # Delete by contact id Resend::Contacts.remove( "78261eea-8f8b-4381-83c6-79fa7120f1cf", "520784e2-887d-4c25-b53c-4ad46ad38100" ) # Delete by contact email Resend::Contacts.remove( "78261eea-8f8b-4381-83c6-79fa7120f1cf", "acme@example.com" ) ``` ```go Go theme={null} import "github.com/resend/resend-go/v2" client := resend.NewClient("re_xxxxxxxxx") // Delete by contact id removed, err := client.Contacts.Remove( "78261eea-8f8b-4381-83c6-79fa7120f1cf", "520784e2-887d-4c25-b53c-4ad46ad38100" ) // Delete by contact email removed, err := client.Contacts.Remove( "78261eea-8f8b-4381-83c6-79fa7120f1cf", "acme@example.com" ) ``` ```rust Rust theme={null} 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_by_contact_id( "78261eea-8f8b-4381-83c6-79fa7120f1cf", "520784e2-887d-4c25-b53c-4ad46ad38100", ) .await?; // Delete by contact email let _deleted = resend .contacts .delete_by_email("78261eea-8f8b-4381-83c6-79fa7120f1cf", "acme@example.com") .await?; Ok(()) } ``` ```java Java theme={null} 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") .audienceId("78261eea-8f8b-4381-83c6-79fa7120f1cf") .build()); // Delete by contact email resend.contacts().remove(ContactRequestOptions.builder() .email("acme@example.com") .audienceId("78261eea-8f8b-4381-83c6-79fa7120f1cf") .build()); } } ``` ```csharp .NET theme={null} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI // By Id await resend.ContactDeleteAsync( audienceId: new Guid( "78261eea-8f8b-4381-83c6-79fa7120f1cf" ), contactId: new Guid( "520784e2-887d-4c25-b53c-4ad46ad38100" ) ); // By Email await resend.ContactDeleteByEmailAsync( new Guid( "78261eea-8f8b-4381-83c6-79fa7120f1cf" ), "acme@example.com" ); ``` ```bash cURL theme={null} # Delete by contact id curl -X DELETE 'https://api.resend.com/audiences/78261eea-8f8b-4381-83c6-79fa7120f1cf/contacts/520784e2-887d-4c25-b53c-4ad46ad38100' \ -H 'Authorization: Bearer re_xxxxxxxxx' # Deleted by contact email curl -X DELETE 'https://api.resend.com/audiences/78261eea-8f8b-4381-83c6-79fa7120f1cf/contacts/acme@example.com' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={null} { "object": "contact", "contact": "520784e2-887d-4c25-b53c-4ad46ad38100", "deleted": true } ``` # Retrieve Contact Source: https://resend.com/docs/api-reference/contacts/get-contact GET /audiences/:audience_id/contacts/:id Retrieve a single contact from an audience. export const ResendParamField = ({children, body, path, ...props}) => { const [lang, setLang] = useState(() => { return localStorage.getItem('code') || '"Node.js"'; }); useEffect(() => { const onStorage = event => { const key = event.detail.key; if (key === 'code') { setLang(event.detail.value); } }; document.addEventListener('mintlify-localstorage', onStorage); return () => { document.removeEventListener('mintlify-localstorage', onStorage); }; }, []); const toCamelCase = str => typeof str === 'string' ? str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase()) : str; const resolvedBody = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(body) : body; }, [body, lang]); const resolvedPath = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(path) : path; }, [path, lang]); return {children} ; }; ## Path Parameters The Audience ID. Either `id` or `email` must be provided. The Contact ID. The Contact Email. ```ts Node.js theme={null} 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', audienceId: '78261eea-8f8b-4381-83c6-79fa7120f1cf', }); // Get by contact email const { data, error } = await resend.contacts.get({ email: 'steve.wozniak@gmail.com', audienceId: '78261eea-8f8b-4381-83c6-79fa7120f1cf', }); ``` ```php PHP theme={null} $resend = Resend::client('re_xxxxxxxxx'); // Get by contact id $resend->contacts->get( audienceId: '78261eea-8f8b-4381-83c6-79fa7120f1cf', id: 'e169aa45-1ecf-4183-9955-b1499d5701d3' ); // Get by contact email $resend->contacts->get( audienceId: '78261eea-8f8b-4381-83c6-79fa7120f1cf', email: 'steve.wozniak@gmail.com' ); ``` ```python Python theme={null} import resend resend.api_key = "re_xxxxxxxxx" # Get by contact id resend.Contacts.get( id="e169aa45-1ecf-4183-9955-b1499d5701d3", audience_id="78261eea-8f8b-4381-83c6-79fa7120f1cf" ) # Get by contact email resend.Contacts.get( email="steve.wozniak@gmail.com", audience_id="78261eea-8f8b-4381-83c6-79fa7120f1cf" ) ``` ```ruby Ruby theme={null} require "resend" Resend.api_key = "re_xxxxxxxxx" # Get by contact id params = { "id": "e169aa45-1ecf-4183-9955-b1499d5701d3", "audience_id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", } Resend::Contacts.get(params) # Get by contact email params = { "email": "steve.wozniak@gmail.com", "audience_id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", } Resend::Contacts.get(params) ``` ```go Go theme={null} import "github.com/resend/resend-go/v2" client := resend.NewClient("re_xxxxxxxxx") // Get by contact id id := "e169aa45-1ecf-4183-9955-b1499d5701d3", contact, err := client.Contacts.Get(audienceId, id) // Get by contact email email := "steve.wozniak@gmail.com", contact, err := client.Contacts.Get(audienceId, email) ``` ```rust Rust theme={null} 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_by_id( "e169aa45-1ecf-4183-9955-b1499d5701d3", "78261eea-8f8b-4381-83c6-79fa7120f1cf", ) .await?; // Get by contact email let _contact = resend .contacts .get_by_email( "steve.wozniak@gmail.com", "78261eea-8f8b-4381-83c6-79fa7120f1cf", ) .await?; Ok(()) } ``` ```java Java theme={null} 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") .audienceId("78261eea-8f8b-4381-83c6-79fa7120f1cf").build(); // Get by contact email GetContactOptions params = GetContactOptions.builder() .email("steve.wozniak@gmail.com") .audienceId("78261eea-8f8b-4381-83c6-79fa7120f1cf").build(); GetContactResponseSuccess data = resend.contacts().get(params); } } ``` ```csharp .NET theme={null} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI // Get by contact id var resp = await resend.ContactRetrieveAsync( audienceId: new Guid( "78261eea-8f8b-4381-83c6-79fa7120f1cf" ), contactId: new Guid( "e169aa45-1ecf-4183-9955-b1499d5701d3" ) ); // Get by contact email var resp = await resend.ContactRetrieveAsync( audienceId: new Guid( "78261eea-8f8b-4381-83c6-79fa7120f1cf" ), email: "steve.wozniak@gmail.com" ); Console.WriteLine( "Contact Email={0}", resp.Content.Email ); ``` ```bash cURL theme={null} # Get by contact id curl -X GET 'https://api.resend.com/audiences/78261eea-8f8b-4381-83c6-79fa7120f1cf/contacts/e169aa45-1ecf-4183-9955-b1499d5701d3' \ -H 'Authorization: Bearer re_xxxxxxxxx' # Get by contact email curl -X GET 'https://api.resend.com/audiences/78261eea-8f8b-4381-83c6-79fa7120f1cf/contacts/steve.wozniak@gmail.com' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={null} { "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 } ``` # Retrieve Contact Topics Source: https://resend.com/docs/api-reference/contacts/get-contact-topic GET /contacts/:contact_id/topics Retrieve a list of topics subscriptions for a contact. Topics are currently in private beta and only available to a limited number of users. APIs might change before GA. To use the methods on this page, you must upgrade your Resend SDK: ```bash Node.js theme={null} npm install resend@6.3.0-canary.0 ``` ```bash PHP theme={null} composer require resend/resend-php:dev-topics ``` ```python Python theme={null} # Python SDK is not available yet ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet ``` ```go Go theme={null} // Go SDK is not available yet ``` ```rust Rust theme={null} // Rust SDK is not available yet ``` ```java Java theme={null} // Java SDK is not available yet ``` ```csharp .NET theme={null} // C# SDK is not available yet ``` [Get in touch](https://resend.com/contact) if you're interested in testing this feature. ## Path Parameters Either `id` or `email` must be provided. The Contact ID. The Contact Email. ```ts Node.js theme={null} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); // Get by contact id const { data, error } = await resend.contacts.topics.get( 'e169aa45-1ecf-4183-9955-b1499d5701d3', ); // Get by contact email const { data, error } = await resend.contacts.topics.get( 'steve.wozniak@gmail.com', ); ``` ```php PHP theme={null} // PHP SDK is not available yet ``` ```python Python theme={null} # Python SDK is not available yet ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet ``` ```go Go theme={null} // Go SDK is not available yet ``` ```rust Rust theme={null} // Rust SDK is not available yet ``` ```java Java theme={null} // Java SDK is not available yet ``` ```csharp .NET theme={null} // C# SDK is not available yet ``` ```bash cURL theme={null} // 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={null} { "email": "steve.wozniak@gmail.com", "topics": [ { "id": "b6d24b8e-af0b-4c3c-be0c-359bbd97381e", "name": "Product Updates", "description": "New features, and latest announcements.", "subscription": "opt_in" } ] } ``` # List Contacts Source: https://resend.com/docs/api-reference/contacts/list-contacts GET /audiences/:audience_id/contacts Show all contacts from an audience. ## Query Parameters Note that the `limit` parameter is *optional*. If you do not provide a `limit`, all contacts will be returned in a single response. Number of contacts to retrieve. Maximum is `100`, and minimum is `1`. The ID *after* which we'll retrieve more contacts (for pagination). This ID will *not* be included in the returned list. Cannot be used with the `before` parameter. The ID *before* which we'll retrieve more contacts (for pagination). This ID will *not* be included in the returned list. Cannot be used with the `after` parameter. ```ts Node.js theme={null} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.contacts.list({ audienceId: '78261eea-8f8b-4381-83c6-79fa7120f1cf', }); ``` ```php PHP theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->contacts->list( audienceId: '78261eea-8f8b-4381-83c6-79fa7120f1cf' ); ``` ```python Python theme={null} import resend resend.api_key = "re_xxxxxxxxx" resend.Contacts.list( audience_id="78261eea-8f8b-4381-83c6-79fa7120f1cf" ) ``` ```ruby Ruby theme={null} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::Contacts.list("78261eea-8f8b-4381-83c6-79fa7120f1cf") ``` ```go Go theme={null} import "github.com/resend/resend-go/v2" client := resend.NewClient("re_xxxxxxxxx") contacts, err := client.Contacts.List("78261eea-8f8b-4381-83c6-79fa7120f1cf") ``` ```rust Rust theme={null} 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( "78261eea-8f8b-4381-83c6-79fa7120f1cf", ListOptions::default(), ) .await?; Ok(()) } ``` ```java Java theme={null} import com.resend.*; public class Main { public static void main(String[] args) { Resend resend = new Resend("re_xxxxxxxxx"); ListContactsResponseSuccess data = resend.contacts().list("78261eea-8f8b-4381-83c6-79fa7120f1cf"); } } ``` ```csharp .NET theme={null} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI var resp = await resend.ContactListAsync( new Guid( "78261eea-8f8b-4381-83c6-79fa7120f1cf" ) ); Console.WriteLine( "Nr Contacts={0}", resp.Content.Count ); ``` ```bash cURL theme={null} curl -X GET 'https://api.resend.com/audiences/78261eea-8f8b-4381-83c6-79fa7120f1cf/contacts' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={null} { "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 /audiences/:audience_id/contacts/:id Update an existing contact. export const ResendParamField = ({children, body, path, ...props}) => { const [lang, setLang] = useState(() => { return localStorage.getItem('code') || '"Node.js"'; }); useEffect(() => { const onStorage = event => { const key = event.detail.key; if (key === 'code') { setLang(event.detail.value); } }; document.addEventListener('mintlify-localstorage', onStorage); return () => { document.removeEventListener('mintlify-localstorage', onStorage); }; }, []); const toCamelCase = str => typeof str === 'string' ? str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase()) : str; const resolvedBody = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(body) : body; }, [body, lang]); const resolvedPath = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(path) : path; }, [path, lang]); return {children} ; }; ## Path Parameters The Audience ID. 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 subscription status. ```ts Node.js theme={null} 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', audienceId: '78261eea-8f8b-4381-83c6-79fa7120f1cf', unsubscribed: true, }); // Update by contact email const { data, error } = await resend.contacts.update({ email: 'acme@example.com', audienceId: '78261eea-8f8b-4381-83c6-79fa7120f1cf', unsubscribed: true, }); ``` ```php PHP theme={null} $resend = Resend::client('re_xxxxxxxxx'); // Update by contact id $resend->contacts->update( audienceId: '78261eea-8f8b-4381-83c6-79fa7120f1cf', id: 'e169aa45-1ecf-4183-9955-b1499d5701d3', parameters: [ 'unsubscribed' => true ] ); // Update by contact email $resend->contacts->update( audienceId: '78261eea-8f8b-4381-83c6-79fa7120f1cf', email: 'acme@example.com', parameters: [ 'unsubscribed' => true ] ); ``` ```python Python theme={null} import resend resend.api_key = "re_xxxxxxxxx" # Update by contact id params: resend.Contacts.UpdateParams = { "id": "e169aa45-1ecf-4183-9955-b1499d5701d3", "audience_id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", "unsubscribed": True, } resend.Contacts.update(params) # Update by contact email params: resend.Contacts.UpdateParams = { "email": "acme@example.com", "audience_id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", "unsubscribed": True, } resend.Contacts.update(params) ``` ```ruby Ruby theme={null} require "resend" Resend.api_key = "re_xxxxxxxxx" # Update by contact id params = { "id": "e169aa45-1ecf-4183-9955-b1499d5701d3", "audience_id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", "unsubscribed": true, } Resend::Contacts.update(params) # Update by contact email params = { "email": "acme@example.com", "audience_id": "78261eea-8f8b-4381-83c6-79fa7120f1cf", "unsubscribed": true, } Resend::Contacts.update(params) ``` ```go Go theme={null} import "github.com/resend/resend-go/v2" client := resend.NewClient("re_xxxxxxxxx") // Update by contact id params := &resend.UpdateContactRequest{ Id: "e169aa45-1ecf-4183-9955-b1499d5701d3", AudienceId: "78261eea-8f8b-4381-83c6-79fa7120f1cf", Unsubscribed: true, } contact, err := client.Contacts.Update(params) // Update by contact email params = &resend.UpdateContactRequest{ Email: "acme@example.com", AudienceId: "78261eea-8f8b-4381-83c6-79fa7120f1cf", Unsubscribed: true, } contact, err := client.Contacts.Update(params) ``` ```rust Rust theme={null} 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_by_id( "e169aa45-1ecf-4183-9955-b1499d5701d3", "78261eea-8f8b-4381-83c6-79fa7120f1cf", changes.clone(), ) .await?; // Update by contact email let _contact = resend .contacts .update_by_email( "acme@example.com", "78261eea-8f8b-4381-83c6-79fa7120f1cf", changes, ) .await?; Ok(()) } ``` ```java Java theme={null} 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() .audienceId("78261eea-8f8b-4381-83c6-79fa7120f1cf") .id("e169aa45-1ecf-4183-9955-b1499d5701d3") .unsubscribed(true) .build(); // Update by contact email UpdateContactOptions params = UpdateContactOptions.builder() .audienceId("78261eea-8f8b-4381-83c6-79fa7120f1cf") .email("acme@example.com") .unsubscribed(true) .build(); UpdateContactResponseSuccess data = resend.contacts().update(params); } } ``` ```csharp .NET theme={null} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI // By Id await resend.ContactUpdateAsync( audienceId: new Guid( "78261eea-8f8b-4381-83c6-79fa7120f1cf" ), contactId: new Guid( "e169aa45-1ecf-4183-9955-b1499d5701d3" ), new ContactData() { FirstName = "Stevie", LastName = "Wozniaks", IsUnsubscribed = true, } ); // By Email await resend.ContactUpdateByEmailAsync( new Guid( "78261eea-8f8b-4381-83c6-79fa7120f1cf" ), "acme@example.com", new ContactData() { FirstName = "Stevie", LastName = "Wozniaks", IsUnsubscribed = true, } ); ``` ```bash cURL theme={null} # Update by contact id curl -X PATCH 'https://api.resend.com/audiences/78261eea-8f8b-4381-83c6-79fa7120f1cf/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/audiences/78261eea-8f8b-4381-83c6-79fa7120f1cf/contacts/acme@example.com' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'{ "unsubscribed": true }' ``` ```json Response theme={null} { "object": "contact", "id": "479e3145-dd38-476b-932c-529ceb705947" } ``` # Update Contact Topic Source: https://resend.com/docs/api-reference/contacts/update-contact-topic PATCH /contacts/:contact_id/topics Update an existing topic subscription for a contact. Topics are currently in private beta and only available to a limited number of users. APIs might change before GA. To use the methods on this page, you must upgrade your Resend SDK: ```bash Node.js theme={null} npm install resend@6.3.0-canary.0 ``` ```bash PHP theme={null} composer require resend/resend-php:dev-topics ``` ```python Python theme={null} # Python SDK is not available yet ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet ``` ```go Go theme={null} // Go SDK is not available yet ``` ```rust Rust theme={null} // Rust SDK is not available yet ``` ```java Java theme={null} // Java SDK is not available yet ``` ```csharp .NET theme={null} // C# SDK is not available yet ``` [Get in touch](https://resend.com/contact) if you're interested in testing this feature. ## 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={null} 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={null} // PHP SDK is not available yet ``` ```python Python theme={null} # Python SDK is not available yet ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet ``` ```go Go theme={null} // Go SDK is not available yet ``` ```rust Rust theme={null} // Rust SDK is not available yet ``` ```java Java theme={null} // Java SDK is not available yet ``` ```csharp .NET theme={null} // C# SDK is not available yet ``` ```bash cURL theme={null} // 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={null} { "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. export const ResendParamField = ({children, body, path, ...props}) => { const [lang, setLang] = useState(() => { return localStorage.getItem('code') || '"Node.js"'; }); useEffect(() => { const onStorage = event => { const key = event.detail.key; if (key === 'code') { setLang(event.detail.value); } }; document.addEventListener('mintlify-localstorage', onStorage); return () => { document.removeEventListener('mintlify-localstorage', onStorage); }; }, []); const toCamelCase = str => typeof str === 'string' ? str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase()) : str; const resolvedBody = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(body) : body; }, [body, lang]); const resolvedPath = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(path) : path; }, [path, lang]); return {children} ; }; ## 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). See all available `status` types in [the Domains overview](/dashboard/domains/introduction#understand-a-domain-status). ```ts Node.js theme={null} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.domains.create({ name: 'example.com' }); ``` ```php PHP theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->domains->create([ 'name' => 'example.com' ]); ``` ```python Python theme={null} import resend resend.api_key = "re_xxxxxxxxx" params: resend.Domains.CreateParams = { "name": "example.com", } resend.Domains.create(params) ``` ```ruby Ruby theme={null} Resend.api_key = ENV["RESEND_API_KEY"] params = { name: "example.com", } domain = Resend::Domains.create(params) puts domain ``` ```go Go theme={null} import "github.com/resend/resend-go/v2" client := resend.NewClient("re_xxxxxxxxx") params := &resend.CreateDomainRequest{ Name: "example.com", } domain, err := client.Domains.Create(params) ``` ```rust Rust theme={null} 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={null} 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={null} 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={null} 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={null} { "id": "4dd369bc-aa82-4ff3-97de-514ae3000ee0", "name": "example.com", "created_at": "2023-03-28T17:12:02.059593+00:00", "status": "not_started", "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. export const ResendParamField = ({children, body, path, ...props}) => { const [lang, setLang] = useState(() => { return localStorage.getItem('code') || '"Node.js"'; }); useEffect(() => { const onStorage = event => { const key = event.detail.key; if (key === 'code') { setLang(event.detail.value); } }; document.addEventListener('mintlify-localstorage', onStorage); return () => { document.removeEventListener('mintlify-localstorage', onStorage); }; }, []); const toCamelCase = str => typeof str === 'string' ? str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase()) : str; const resolvedBody = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(body) : body; }, [body, lang]); const resolvedPath = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(path) : path; }, [path, lang]); return {children} ; }; ## Path Parameters The Domain ID. ```js Node.js theme={null} 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={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->domains->remove('d91cd9bd-1176-453e-8fc1-35364d380206'); ``` ```python Python theme={null} import resend resend.api_key = "re_xxxxxxxxx" resend.Domains.remove(domain_id="d91cd9bd-1176-453e-8fc1-35364d380206") ``` ```ruby Ruby theme={null} Resend.api_key = ENV["RESEND_API_KEY"] Resend::Domains.remove("d91cd9bd-1176-453e-8fc1-35364d380206") ``` ```go Go theme={null} import "github.com/resend/resend-go/v2" client := resend.NewClient("re_xxxxxxxxx") removed, err := client.Domains.Remove("d91cd9bd-1176-453e-8fc1-35364d380206") ``` ```rust Rust theme={null} 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={null} 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={null} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI await resend.DomainDeleteAsync( new Guid( "d91cd9bd-1176-453e-8fc1-35364d380206" ) ); ``` ```bash cURL theme={null} curl -X DELETE 'https://api.resend.com/domains/d91cd9bd-1176-453e-8fc1-35364d380206' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={null} { "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. export const ResendParamField = ({children, body, path, ...props}) => { const [lang, setLang] = useState(() => { return localStorage.getItem('code') || '"Node.js"'; }); useEffect(() => { const onStorage = event => { const key = event.detail.key; if (key === 'code') { setLang(event.detail.value); } }; document.addEventListener('mintlify-localstorage', onStorage); return () => { document.removeEventListener('mintlify-localstorage', onStorage); }; }, []); const toCamelCase = str => typeof str === 'string' ? str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase()) : str; const resolvedBody = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(body) : body; }, [body, lang]); const resolvedPath = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(path) : path; }, [path, lang]); return {children} ; }; ## 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={null} 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={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->domains->get('d91cd9bd-1176-453e-8fc1-35364d380206'); ``` ```python Python theme={null} import resend resend.api_key = "re_xxxxxxxxx" resend.Domains.get(domain_id="d91cd9bd-1176-453e-8fc1-35364d380206") ``` ```ruby Ruby theme={null} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::Domains.get "d91cd9bd-1176-453e-8fc1-35364d380206" ``` ```go Go theme={null} import "github.com/resend/resend-go/v2" client := resend.NewClient("re_xxxxxxxxx") retrievedDomain, err := client.Domains.Get("d91cd9bd-1176-453e-8fc1-35364d380206") ``` ```rust Rust theme={null} 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={null} 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={null} 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={null} curl -X GET 'https://api.resend.com/domains/d91cd9bd-1176-453e-8fc1-35364d380206' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={null} { "object": "domain", "id": "d91cd9bd-1176-453e-8fc1-35364d380206", "name": "example.com", "status": "not_started", "capability": "send", "created_at": "2023-04-26T20:21:26.347412+00:00", "region": "us-east-1", "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). ## Query Parameters Note that the `limit` parameter is *optional*. If you do not provide a `limit`, all domains will be returned in a single response. Number of domains to retrieve. Maximum is `100`, and minimum is `1`. The ID *after* which we'll retrieve more domains (for pagination). This ID will *not* be included in the returned list. Cannot be used with the `before` parameter. The ID *before* which we'll retrieve more domains (for pagination). This ID will *not* be included in the returned list. Cannot be used with the `after` parameter. ```ts Node.js theme={null} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.domains.list(); ``` ```php PHP theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->domains->list(); ``` ```python Python theme={null} import resend resend.api_key = "re_xxxxxxxxx" resend.Domains.list() ``` ```ruby Ruby theme={null} Resend.api_key = ENV["RESEND_API_KEY"] Resend::Domains.list ``` ```go Go theme={null} import "github.com/resend/resend-go/v2" client := resend.NewClient("re_xxxxxxxxx") domains, err := client.Domains.List() ``` ```rust Rust theme={null} 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={null} 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={null} 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={null} curl -X GET 'https://api.resend.com/domains' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={null} { "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" } ] } ``` # Update Domain Source: https://resend.com/docs/api-reference/domains/update-domain PATCH /domains/:domain_id Update an existing domain. export const ResendParamField = ({children, body, path, ...props}) => { const [lang, setLang] = useState(() => { return localStorage.getItem('code') || '"Node.js"'; }); useEffect(() => { const onStorage = event => { const key = event.detail.key; if (key === 'code') { setLang(event.detail.value); } }; document.addEventListener('mintlify-localstorage', onStorage); return () => { document.removeEventListener('mintlify-localstorage', onStorage); }; }, []); const toCamelCase = str => typeof str === 'string' ? str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase()) : str; const resolvedBody = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(body) : body; }, [body, lang]); const resolvedPath = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(path) : path; }, [path, lang]); return {children} ; }; ## Path Parameters The Domain ID. ## Body Parameters Track clicks within the body of each HTML email. Track the open rate of each email. ```ts Node.js theme={null} 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={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->domains->update( 'b8617ad3-b712-41d9-81a0-f7c3d879314e', [ 'open_tracking' => false, 'click_tracking' => true, 'tls' => 'enforced', ] ); ``` ```python Python theme={null} 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={null} 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={null} import "github.com/resend/resend-go/v2" client := resend.NewClient("re_xxxxxxxxx") updateDomainParams := &resend.UpdateDomainRequest{ OpenTracking: false, ClickTracking: true, Tls: resend.Enforced, } updated, err := client.Domains.Update("b8617ad3-b712-41d9-81a0-f7c3d879314e", updateDomainParams) ``` ```rust Rust theme={null} 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={null} 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={null} 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={null} 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={null} { "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. export const ResendParamField = ({children, body, path, ...props}) => { const [lang, setLang] = useState(() => { return localStorage.getItem('code') || '"Node.js"'; }); useEffect(() => { const onStorage = event => { const key = event.detail.key; if (key === 'code') { setLang(event.detail.value); } }; document.addEventListener('mintlify-localstorage', onStorage); return () => { document.removeEventListener('mintlify-localstorage', onStorage); }; }, []); const toCamelCase = str => typeof str === 'string' ? str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase()) : str; const resolvedBody = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(body) : body; }, [body, lang]); const resolvedPath = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(path) : path; }, [path, lang]); return {children} ; }; ## Path Parameters The Domain ID. ```ts Node.js theme={null} 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={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->domains->verify('d91cd9bd-1176-453e-8fc1-35364d380206'); ``` ```python Python theme={null} import resend resend.api_key = "re_xxxxxxxxx" resend.Domains.verify(domain_id="d91cd9bd-1176-453e-8fc1-35364d380206") ``` ```ruby Ruby theme={null} Resend.api_key = ENV["RESEND_API_KEY"] Resend::Domains.verify("d91cd9bd-1176-453e-8fc1-35364d380206") ``` ```go Go theme={null} import "github.com/resend/resend-go/v2" client := resend.NewClient("re_xxxxxxxxx") verified, err := client.Domains.Verify("d91cd9bd-1176-453e-8fc1-35364d380206") ``` ```rust Rust theme={null} 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={null} 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={null} 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={null} 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={null} { "object": "domain", "id": "d91cd9bd-1176-453e-8fc1-35364d380206" } ``` # Cancel Email Source: https://resend.com/docs/api-reference/emails/cancel-email POST /emails/:id/cancel Cancel a scheduled email. ## Path Parameters The Email ID. ```ts Node.js theme={null} 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={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->emails->cancel('49a3999c-0ce1-4ea6-ab68-afcd6dc2e794'); ``` ```python Python theme={null} import resend resend.api_key = "re_xxxxxxxxx" resend.Emails.cancel(email_id="49a3999c-0ce1-4ea6-ab68-afcd6dc2e794") ``` ```ruby Ruby theme={null} require "resend" Resend.api_key = "re_xxxxxxxxx" Resend::Emails.cancel("49a3999c-0ce1-4ea6-ab68-afcd6dc2e794") ``` ```go Go theme={null} import "github.com/resend/resend-go/v2" 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={null} 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={null} 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={null} using Resend; IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI await resend.EmailCancelAsync( new Guid( "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794" ) ); ``` ```bash cURL theme={null} 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={null} { "object": "email", "id": "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794" } ``` # List Inbound Emails Source: https://resend.com/docs/api-reference/emails/list-inbound-emails GET /emails/receiving/ Retrieve a list of received emails for the authenticated user. Inbound emails are currently in private beta and only available to a limited number of users. APIs might change before GA. To use the methods on this page, you must upgrade your Resend SDK: ```bash Node.js theme={null} npm install resend@6.3.0-canary.0 ``` ```php PHP theme={null} // PHP SDK is not available yet ``` ```python Python theme={null} # Python SDK is not available yet ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet ``` ```go Go theme={null} // Go SDK is not available yet ``` ```rust Rust theme={null} // Rust SDK is not available yet ``` ```java Java theme={null} // Java SDK is not available yet ``` ```csharp .NET theme={null} // C# SDK is not available yet ``` [Join the waitlist](https://resend.com/inbound) if you're interested in testing this feature. ## Query Parameters Note that the `limit` parameter is *optional*. If you do not provide a `limit` we'll default to `20` emails. Number of emails to retrieve. Maximum is `100`, and minimum is `1`. The default `limit` is `20`. The ID *after* which we'll retrieve more emails (for pagination). This ID will *not* be included in the returned list. Cannot be used with the `before` parameter. The ID *before* which we'll retrieve more emails (for pagination). This ID will *not* be included in the returned list. Cannot be used with the `after` parameter. ```ts Node.js theme={null} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.emails.receiving.list(); ``` ```php PHP theme={null} // PHP SDK is not available yet ``` ```python Python theme={null} # Python SDK is not available yet ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet ``` ```go Go theme={null} // Go SDK is not available yet ``` ```rust Rust theme={null} // Rust SDK is not available yet ``` ```java Java theme={null} // Java SDK is not available yet ``` ```csharp .NET theme={null} // C# SDK is not available yet ``` ```bash cURL theme={null} curl -X GET 'https://api.resend.com/emails/receiving' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={null} { "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/: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={null} 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={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->emails->get('37e4414c-5e25-4dbc-a071-43552a4bd53b'); ``` ```python Python theme={null} import resend resend.api_key = "re_xxxxxxxxx" resend.Emails.get(email_id="4ef9a417-02e9-4d39-ad75-9611e0fcc33c") ``` ```ruby Ruby theme={null} Resend.api_key = "re_xxxxxxxxx" email = Resend::Emails.get("4ef9a417-02e9-4d39-ad75-9611e0fcc33c") puts email ``` ```go Go theme={null} import "github.com/resend/resend-go/v2" client := resend.NewClient("re_xxxxxxxxx") email, err := client.Emails.Get("4ef9a417-02e9-4d39-ad75-9611e0fcc33c") ``` ```rust Rust theme={null} 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={null} 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={null} 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={null} curl -X GET 'https://api.resend.com/emails/4ef9a417-02e9-4d39-ad75-9611e0fcc33c' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={null} { "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 } ``` # Retrieve Inbound Email Source: https://resend.com/docs/api-reference/emails/retrieve-inbound-email GET /emails/receiving/:id Retrieve a single inbound email. Inbound emails are currently in private beta and only available to a limited number of users. APIs might change before GA. To use the methods on this page, you must upgrade your Resend SDK: ```bash Node.js theme={null} npm install resend@6.3.0-canary.0 ``` ```php PHP theme={null} // PHP SDK is not available yet ``` ```python Python theme={null} # Python SDK is not available yet ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet ``` ```go Go theme={null} // Go SDK is not available yet ``` ```rust Rust theme={null} // Rust SDK is not available yet ``` ```java Java theme={null} // Java SDK is not available yet ``` ```csharp .NET theme={null} // C# SDK is not available yet ``` [Join the waitlist](https://resend.com/inbound) if you're interested in testing this feature. ## Path Parameters The ID for the inbound email. ```js Node.js theme={null} 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={null} // PHP SDK is not available yet ``` ```python Python theme={null} # Python SDK is not available yet ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet ``` ```go Go theme={null} // Go SDK is not available yet ``` ```rust Rust theme={null} // Rust SDK is not available yet ``` ```java Java theme={null} // Java SDK is not available yet ``` ```csharp .NET theme={null} // C# SDK is not available yet ``` ```bash cURL theme={null} curl -X GET 'https://api.resend.com/emails/receiving/4ef9a417-02e9-4d39-ad75-9611e0fcc33c' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={null} { "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": [], "message_id": "", "attachments": [ { "id": "2a0c9ce0-3112-4728-976e-47ddcd16a318", "filename": "avatar.png", "content_type": "image/png", "content_disposition": "inline", "content_id": "img001" } ] } ``` # 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. export const ResendParamField = ({children, body, path, ...props}) => { const [lang, setLang] = useState(() => { return localStorage.getItem('code') || '"Node.js"'; }); useEffect(() => { const onStorage = event => { const key = event.detail.key; if (key === 'code') { setLang(event.detail.value); } }; document.addEventListener('mintlify-localstorage', onStorage); return () => { document.removeEventListener('mintlify-localstorage', onStorage); }; }, []); const toCamelCase = str => typeof str === 'string' ? str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase()) : str; const resolvedBody = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(body) : body; }, [body, lang]); const resolvedPath = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(path) : path; }, [path, lang]); return {children} ; }; 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. 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. Templates are currently in private beta and only available to a limited number of users. APIs might change before GA. To use the methods on this page, you must upgrade your Resend SDK: ```bash Node.js theme={null} npm install resend@6.3.0-canary.0 ``` ```bash PHP theme={null} composer require resend/resend-php:dev-templates ``` ```python Python theme={null} # Python SDK is not available yet ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet ``` ```go Go theme={null} // Go SDK is not available yet ``` ```bash Rust theme={null} cargo add resend-rs@0.19.0-beta ``` ```java Java theme={null} // Java SDK is not available yet ``` ```csharp .NET theme={null} // C# SDK is not available yet ``` [Get in touch](https://resend.com/contact) if you're interested in testing this feature. To send using a template, provide a `template` object with: * `id`: id of the published template * `variables`: array of variable objects (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. See the [errors reference](/api-reference/errors) for more details. Template variables object with key/value pairs. ```ts theme={null} 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. [See examples](/dashboard/templates/introduction). The key of the variable. May only contain ASCII letters (a–z, A–Z), numbers (0–9), and underscores (\_). It can contain no more than 50 characters. The value of the variable. Observe these technical limitations: * `string`: maximum length of 50 characters * `number`: not greater than 2^53 - 1 * `boolean`: `true` or `false` * `object`: maximum length of 50 keys * `list`: maximum length of 50 indexes ## 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) Batch validation modes control how emails are validated in batch sending. Choose between two modes: * **Strict mode (default)**: sends the batch only if all emails in the request are valid. * **Permissive mode**: processes all emails, allowing for partial success and returning validation errors if present. [Learn more about batch validation →](/dashboard/emails/batch-validation-modes) ## Limitations The `attachments` and `scheduled_at` fields are not supported yet. ```ts Node.js theme={null} 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={null} $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={null} 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={null} 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={null} package examples import ( "fmt" "os" "github.com/resend/resend-go/v2" ) 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={null} 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={null} 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={null} 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={null} 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={null} { "data": [ { "id": "ae2014de-c168-4c61-8267-70d2662a1ce1" }, { "id": "faccb7a5-8a28-4e9a-ac64-8da1cc3bc1cb" } ], // the `errors` array is only present in permissive batch validation mode "errors": [ { "index": 2, // 0-indexed (first item is index 0) "message": "The `to` field is missing." } ] } ``` # Send Email Source: https://resend.com/docs/api-reference/emails/send-email POST /emails Start sending emails through the Resend Email API. export const ResendParamField = ({children, body, path, ...props}) => { const [lang, setLang] = useState(() => { return localStorage.getItem('code') || '"Node.js"'; }); useEffect(() => { const onStorage = event => { const key = event.detail.key; if (key === 'code') { setLang(event.detail.value); } }; document.addEventListener('mintlify-localstorage', onStorage); return () => { document.removeEventListener('mintlify-localstorage', onStorage); }; }, []); const toCamelCase = str => typeof str === 'string' ? str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase()) : str; const resolvedBody = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(body) : body; }, [body, lang]); const resolvedPath = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(path) : path; }, [path, lang]); return {children} ; }; ## 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. 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. Templates are currently in private beta and only available to a limited number of users. APIs might change before GA. To use the methods on this page, you must upgrade your Resend SDK: ```bash Node.js theme={null} npm install resend@6.3.0-canary.0 ``` ```bash PHP theme={null} composer require resend/resend-php:dev-templates ``` ```python Python theme={null} # Python SDK is not available yet ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet ``` ```go Go theme={null} // Go SDK is not available yet ``` ```bash Rust theme={null} cargo add resend-rs@0.19.0-beta ``` ```java Java theme={null} // Java SDK is not available yet ``` ```csharp .NET theme={null} // C# SDK is not available yet ``` [Get in touch](https://resend.com/contact) if you're interested in testing this feature. To send using a template, provide a `template` object with: * `id`: id of the published template * `variables`: array of variable objects (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. See the [errors reference](/api-reference/errors) for more details. Template variables object with key/value pairs. ```ts theme={null} 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. [See examples](/dashboard/templates/introduction). The key of the variable. May only contain ASCII letters (a–z, A–Z), numbers (0–9), and underscores (\_). It can contain no more than 50 characters. The value of the variable. Observe these technical limitations: * `string`: maximum length of 50 characters * `number`: not greater than 2^53 - 1 * `boolean`: `true` or `false` * `object`: maximum length of 50 keys * `list`: maximum length of 50 indexes ## 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={null} 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={null} $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={null} 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={null} 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={null} import ( "fmt" "github.com/resend/resend-go/v2" ) 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={null} 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={null} 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={null} 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={null} 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={null} { "id": "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794" } ``` # Update Email Source: https://resend.com/docs/api-reference/emails/update-email PATCH /emails/:id Update a scheduled email. export const ResendParamField = ({children, body, path, ...props}) => { const [lang, setLang] = useState(() => { return localStorage.getItem('code') || '"Node.js"'; }); useEffect(() => { const onStorage = event => { const key = event.detail.key; if (key === 'code') { setLang(event.detail.value); } }; document.addEventListener('mintlify-localstorage', onStorage); return () => { document.removeEventListener('mintlify-localstorage', onStorage); }; }, []); const toCamelCase = str => typeof str === 'string' ? str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase()) : str; const resolvedBody = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(body) : body; }, [body, lang]); const resolvedPath = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(path) : path; }, [path, lang]); return {children} ; }; ## 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={null} 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={null} $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={null} 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={null} 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={null} import "github.com/resend/resend-go/v2" 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 } updatedEmail, err := client.Emails.Update(updateParams) if err != nil { panic(err) } fmt.Printf("%v\n", updatedEmail) ``` ```rust Rust theme={null} 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={null} 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={null} 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={null} 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={null} { "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`). * **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. ### `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 a 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. ### `daily_quota_exceeded` * **Status:** 429 * **Message:** You have reached your daily email sending quota. * **Suggested action:** [Upgrade your plan](https://resend.com/settings/billing) to remove the daily quota limit or wait until 24 hours have passed to continue sending. ### `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 ``` ## 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**. This number can be increased for trusted senders by request. 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 At this moment, there are no pagination parameters since we don't provide a way to fetch data via API yet. We plan to add pagination capabilities in the future. Currently, there's no versioning system in place. We plan to add versioning via calendar-based headers in the future. # Rate Limit Source: https://resend.com/docs/api-reference/rate-limit Understand rate limits and how to increase them. 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**. This number can be increased for trusted senders upon request. 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. # Create Template Source: https://resend.com/docs/api-reference/templates/create-template POST /templates Create a new template with optional variables. export const ResendParamField = ({children, body, path, ...props}) => { const [lang, setLang] = useState(() => { return localStorage.getItem('code') || '"Node.js"'; }); useEffect(() => { const onStorage = event => { const key = event.detail.key; if (key === 'code') { setLang(event.detail.value); } }; document.addEventListener('mintlify-localstorage', onStorage); return () => { document.removeEventListener('mintlify-localstorage', onStorage); }; }, []); const toCamelCase = str => typeof str === 'string' ? str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase()) : str; const resolvedBody = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(body) : body; }, [body, lang]); const resolvedPath = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(path) : path; }, [path, lang]); return {children} ; }; Templates are currently in private beta and only available to a limited number of users. APIs might change before GA. To use the methods on this page, you must upgrade your Resend SDK: ```bash Node.js theme={null} npm install resend@6.3.0-canary.0 ``` ```bash PHP theme={null} composer require resend/resend-php:dev-templates ``` ```python Python theme={null} # Python SDK is not available yet ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet ``` ```go Go theme={null} // Go SDK is not available yet ``` ```bash Rust theme={null} cargo add resend-rs@0.19.0-beta ``` ```java Java theme={null} // Java SDK is not available yet ``` ```csharp .NET theme={null} // C# SDK is not available yet ``` [Get in touch](https://resend.com/contact) if you're interested in testing this feature. ## Body Parameters The name 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. Email subject. If provided, this value can be overridden when sending an email using the template. Reply-to email address. For multiple addresses, send as an array of strings. If provided, this value can be overridden when sending an email using the template. The HTML version of 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 20 variables. Each variable is an object with the following properties: The key of the variable. We recommend capitalizing the key (e.g. `FIRST_NAME`). The type of the variable. Can be `'string'`, `'number'`, `'boolean'`, `'object'`, or `'list'`. 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. If `object` type is provided, you must include a fallback. 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). ```ts Node.js theme={null} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); await resend.templates.create({ name: 'welcome-email', html: 'Hey, {{{NAME}}}, you are {{{AGE}}} years old.', variables: [ { key: 'NAME', type: 'string', fallbackValue: 'user', }, { key: 'AGE', type: 'number', fallbackValue: 25, }, { key: 'OPTIONAL_VARIABLE', type: 'string', fallbackValue: undefined, }, ], }); // Or create and publish a template in one step await resend.templates.create({ ... }).publish(); ``` ```php PHP theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->templates->create([ 'name' => 'welcome-email', 'html' => 'Hey, {{{NAME}}}, you are {{{AGE}}} years old.', 'variables' => [ [ 'key' => 'NAME', 'type' => 'string', 'fallback_value' => 'user', ], [ 'key' => 'AGE', 'type' => 'number', 'fallback_value' => 25, ], [ 'key' => 'OPTIONAL_VARIABLE', 'type' => 'string', ], ], ]); ``` ```py Python theme={null} # Python SDK is not available yet. ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet. ``` ```go Go theme={null} // Go SDK is not available yet. ``` ```rust Rust theme={null} use resend_rs::{ types::{CreateTemplateOptions, Variable, VariableType}, Resend, Result, }; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let name = "welcome-email"; let html = "Hey, {{{NAME}}}, you are {{{AGE}}} years old."; let variables = [ Variable::new("NAME", VariableType::String).with_fallback("user".into()), Variable::new("AGE", VariableType::Number).with_fallback(25.into()), Variable::new("OPTIONAL_VARIABLE", VariableType::String).with_fallback(None::.into()), ]; 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={null} // Java SDK is not available yet. ``` ```csharp .NET theme={null} // C# SDK is not available yet. ``` ```bash cURL theme={null} curl -X POST 'https://api.resend.com/templates' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'{ "name": "welcome-email", "html": "Hey, {{{NAME}}}, you are {{{AGE}}} years old.", "variables": [ { "key": "NAME", "type": "string", "fallback_value": "user" }, { "key": "AGE", "type": "number", "fallback_value": 25 }, { "key": "OPTIONAL_VARIABLE", "type": "string" } ] }' ``` ```json Response theme={null} { "id": "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794", "object": "template" } ``` # Delete Template Source: https://resend.com/docs/api-reference/templates/delete-template DELETE /templates/:id Delete a template. Templates are currently in private beta and only available to a limited number of users. APIs might change before GA. To use the methods on this page, you must upgrade your Resend SDK: ```bash Node.js theme={null} npm install resend@6.3.0-canary.0 ``` ```bash PHP theme={null} composer require resend/resend-php:dev-templates ``` ```python Python theme={null} # Python SDK is not available yet ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet ``` ```go Go theme={null} // Go SDK is not available yet ``` ```bash Rust theme={null} cargo add resend-rs@0.19.0-beta ``` ```java Java theme={null} // Java SDK is not available yet ``` ```csharp .NET theme={null} // C# SDK is not available yet ``` [Get in touch](https://resend.com/contact) if you're interested in testing this feature. ## Path Parameters The ID or alias of the template to delete. ```ts Node.js theme={null} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); await resend.templates.remove('34a080c9-b17d-4187-ad80-5af20266e535'); ``` ```php PHP theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->templates->remove('34a080c9-b17d-4187-ad80-5af20266e535'); ``` ```py Python theme={null} # Python SDK is not available yet. ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet. ``` ```go Go theme={null} // Go SDK is not available yet. ``` ```rust Rust theme={null} 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={null} // Java SDK is not available yet. ``` ```csharp .NET theme={null} // C# SDK is not available yet. ``` ```bash cURL theme={null} 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={null} { "object": "template", "id": "34a080c9-b17d-4187-ad80-5af20266e535", "deleted": true } ``` # Duplicate Template Source: https://resend.com/docs/api-reference/templates/duplicate-template POST /templates/:id/duplicate Duplicate a template. Templates are currently in private beta and only available to a limited number of users. APIs might change before GA. To use the methods on this page, you must upgrade your Resend SDK: ```bash Node.js theme={null} npm install resend@6.3.0-canary.0 ``` ```bash PHP theme={null} composer require resend/resend-php:dev-templates ``` ```python Python theme={null} # Python SDK is not available yet ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet ``` ```go Go theme={null} // Go SDK is not available yet ``` ```bash Rust theme={null} cargo add resend-rs@0.19.0-beta ``` ```java Java theme={null} // Java SDK is not available yet ``` ```csharp .NET theme={null} // C# SDK is not available yet ``` [Get in touch](https://resend.com/contact) if you're interested in testing this feature. ## Path Parameters The ID or alias of the template to duplicate. ```ts Node.js theme={null} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); await resend.templates.duplicate('34a080c9-b17d-4187-ad80-5af20266e535'); ``` ```php PHP theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->templates->duplicate('34a080c9-b17d-4187-ad80-5af20266e535'); ``` ```py Python theme={null} # Python SDK is not available yet. ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet. ``` ```go Go theme={null} // Go SDK is not available yet. ``` ```rust Rust theme={null} 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={null} // Java SDK is not available yet. ``` ```csharp .NET theme={null} // C# SDK is not available yet. ``` ```bash cURL theme={null} 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={null} { "object": "template", "id": "e169aa45-1ecf-4183-9955-b1499d5701d3" } ``` # Get Template Source: https://resend.com/docs/api-reference/templates/get-template GET /templates/:id Get a template by ID. Templates are currently in private beta and only available to a limited number of users. APIs might change before GA. To use the methods on this page, you must upgrade your Resend SDK: ```bash Node.js theme={null} npm install resend@6.3.0-canary.0 ``` ```bash PHP theme={null} composer require resend/resend-php:dev-templates ``` ```python Python theme={null} # Python SDK is not available yet ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet ``` ```go Go theme={null} // Go SDK is not available yet ``` ```bash Rust theme={null} cargo add resend-rs@0.19.0-beta ``` ```java Java theme={null} // Java SDK is not available yet ``` ```csharp .NET theme={null} // C# SDK is not available yet ``` [Get in touch](https://resend.com/contact) if you're interested in testing this feature. ## Path Parameters The ID or alias of the template to get. ```ts Node.js theme={null} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); await resend.templates.get('34a080c9-b17d-4187-ad80-5af20266e535'); ``` ```php PHP theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->templates->get('34a080c9-b17d-4187-ad80-5af20266e535'); ``` ```py Python theme={null} # Python SDK is not available yet. ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet. ``` ```go Go theme={null} // Go SDK is not available yet. ``` ```rust Rust theme={null} 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={null} // Java SDK is not available yet. ``` ```csharp .NET theme={null} // C# SDK is not available yet. ``` ```bash cURL theme={null} 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={null} { "object": "template", "id": "34a080c9-b17d-4187-ad80-5af20266e535", "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" } ] } ```
# 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. Templates are currently in private beta and only available to a limited number of users. APIs might change before GA. To use the methods on this page, you must upgrade your Resend SDK: ```bash Node.js theme={null} npm install resend@6.3.0-canary.0 ``` ```bash PHP theme={null} composer require resend/resend-php:dev-templates ``` ```python Python theme={null} # Python SDK is not available yet ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet ``` ```go Go theme={null} // Go SDK is not available yet ``` ```bash Rust theme={null} cargo add resend-rs@0.19.0-beta ``` ```java Java theme={null} // Java SDK is not available yet ``` ```csharp .NET theme={null} // C# SDK is not available yet ``` [Get in touch](https://resend.com/contact) if you're interested in testing this feature. ## Query Parameters The number of templates to return. Defaults to `20`. Maximum is `100`. The ID of the template to start after. The API will return the templates after (and not including) the given ID. The ID of the template to start before. The API will return the templates before (and not including) the given ID. ```ts Node.js theme={null} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); await resend.templates.list({ limit: 2, after: '34a080c9-b17d-4187-ad80-5af20266e535', }); ``` ```php PHP theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->templates->list([ 'limit' => 2, 'after' => '34a080c9-b17d-4187-ad80-5af20266e535' ]); ``` ```py Python theme={null} # Python SDK is not available yet. ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet. ``` ```go Go theme={null} // Go SDK is not available yet. ``` ```rust Rust theme={null} 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={null} // Java SDK is not available yet. ``` ```csharp .NET theme={null} // C# SDK is not available yet. ``` ```bash cURL theme={null} 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={null} { "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/:id/publish Publish a template. export const ResendParamField = ({children, body, path, ...props}) => { const [lang, setLang] = useState(() => { return localStorage.getItem('code') || '"Node.js"'; }); useEffect(() => { const onStorage = event => { const key = event.detail.key; if (key === 'code') { setLang(event.detail.value); } }; document.addEventListener('mintlify-localstorage', onStorage); return () => { document.removeEventListener('mintlify-localstorage', onStorage); }; }, []); const toCamelCase = str => typeof str === 'string' ? str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase()) : str; const resolvedBody = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(body) : body; }, [body, lang]); const resolvedPath = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(path) : path; }, [path, lang]); return {children} ; }; Templates are currently in private beta and only available to a limited number of users. APIs might change before GA. To use the methods on this page, you must upgrade your Resend SDK: ```bash Node.js theme={null} npm install resend@6.3.0-canary.0 ``` ```bash PHP theme={null} composer require resend/resend-php:dev-templates ``` ```python Python theme={null} # Python SDK is not available yet ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet ``` ```go Go theme={null} // Go SDK is not available yet ``` ```bash Rust theme={null} cargo add resend-rs@0.19.0-beta ``` ```java Java theme={null} // Java SDK is not available yet ``` ```csharp .NET theme={null} // C# SDK is not available yet ``` [Get in touch](https://resend.com/contact) if you're interested in testing this feature. ## Path Parameters The ID or alias of the template to duplicate. ```ts Node.js theme={null} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); await resend.templates.publish('34a080c9-b17d-4187-ad80-5af20266e535'); ``` ```php PHP theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->templates->publish('34a080c9-b17d-4187-ad80-5af20266e535'); ``` ```py Python theme={null} # Python SDK is not available yet. ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet. ``` ```go Go theme={null} // Go SDK is not available yet. ``` ```rust Rust theme={null} 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={null} // Java SDK is not available yet. ``` ```csharp .NET theme={null} // C# SDK is not available yet. ``` ```bash cURL theme={null} 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={null} { "id": "34a080c9-b17d-4187-ad80-5af20266e535", "object": "template" } ``` # Update Template Source: https://resend.com/docs/api-reference/templates/update-template PATCH /templates/:id Update a template. export const ResendParamField = ({children, body, path, ...props}) => { const [lang, setLang] = useState(() => { return localStorage.getItem('code') || '"Node.js"'; }); useEffect(() => { const onStorage = event => { const key = event.detail.key; if (key === 'code') { setLang(event.detail.value); } }; document.addEventListener('mintlify-localstorage', onStorage); return () => { document.removeEventListener('mintlify-localstorage', onStorage); }; }, []); const toCamelCase = str => typeof str === 'string' ? str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase()) : str; const resolvedBody = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(body) : body; }, [body, lang]); const resolvedPath = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(path) : path; }, [path, lang]); return {children} ; }; Templates are currently in private beta and only available to a limited number of users. APIs might change before GA. To use the methods on this page, you must upgrade your Resend SDK: ```bash Node.js theme={null} npm install resend@6.3.0-canary.0 ``` ```bash PHP theme={null} composer require resend/resend-php:dev-templates ``` ```python Python theme={null} # Python SDK is not available yet ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet ``` ```go Go theme={null} // Go SDK is not available yet ``` ```bash Rust theme={null} cargo add resend-rs@0.19.0-beta ``` ```java Java theme={null} // Java SDK is not available yet ``` ```csharp .NET theme={null} // C# SDK is not available yet ``` [Get in touch](https://resend.com/contact) if you're interested in testing this feature. ## Path Parameters The ID or alias of the template to duplicate. ## Body Parameters The name 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. Email subject. If provided, this value can be overridden when sending an email using the template. Reply-to email address. For multiple addresses, send as an array of strings. If provided, this value can be overridden when sending an email using the template. The HTML version of 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 20 variables. Each variable is an object with the following properties: The key of the variable. We recommend capitalizing the key (e.g. `FIRST_NAME`). The type of the variable. Can be `'string'`, `'number'`, `'boolean'`, `'object'`, or `'list'`. 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. If `object` type is provided, you must include a fallback. 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). ```ts Node.js theme={null} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); await resend.templates.update('34a080c9-b17d-4187-ad80-5af20266e535', { name: 'welcome-email', html: 'Hey, {{{NAME}}}, you are {{{AGE}}} years old.', variables: [ { key: 'NAME', type: 'string', fallbackValue: 'user', }, { key: 'AGE', type: 'number', fallbackValue: 25, }, { key: 'OPTIONAL_VARIABLE', type: 'string', }, ], }); ``` ```php PHP theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->templates->update('34a080c9-b17d-4187-ad80-5af20266e535', [ 'name' => 'welcome-email', 'html' => 'Hey, {{{NAME}}}, you are {{{AGE}}} years old.', 'variables' => [ [ 'key' => 'NAME', 'type' => 'string', 'fallback_value' => 'user', ], [ 'key' => 'AGE', 'type' => 'number', 'fallback_value' => 25, ], [ 'key' => 'OPTIONAL_VARIABLE', 'type' => 'string', ], ], ]); ``` ```py Python theme={null} # Python SDK is not available yet. ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet. ``` ```go Go theme={null} // Go SDK is not available yet. ``` ```rust Rust theme={null} use resend_rs::{ types::{UpdateTemplateOptions, Variable, VariableType}, Resend, Result, }; #[tokio::main] async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let name = "welcome-email"; let html = "Hey, {{{NAME}}}, you are {{{AGE}}} years old."; let variables = [ Variable::new("NAME", VariableType::String).with_fallback("user".into()), Variable::new("AGE", VariableType::Number).with_fallback(25.into()), Variable::new("OPTIONAL_VARIABLE", VariableType::String), ]; let update = UpdateTemplateOptions::new(name, html).with_variables(&variables); let _template = resend .templates .update("34a080c9-b17d-4187-ad80-5af20266e535", update) .await?; Ok(()) } ``` ```java Java theme={null} // Java SDK is not available yet. ``` ```csharp .NET theme={null} // C# SDK is not available yet. ``` ```bash cURL theme={null} 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": "welcome-email", "html": "Hey, {{{NAME}}}, you are {{{AGE}}} years old.", "variables": [ { "key": "NAME", "type": "string", "fallback_value": "user" }, { "key": "AGE", "type": "number", "fallback_value": 25 }, { "key": "OPTIONAL_VARIABLE", "type": "string" } ] }' ``` ```json Response theme={null} { "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. export const ResendParamField = ({children, body, path, ...props}) => { const [lang, setLang] = useState(() => { return localStorage.getItem('code') || '"Node.js"'; }); useEffect(() => { const onStorage = event => { const key = event.detail.key; if (key === 'code') { setLang(event.detail.value); } }; document.addEventListener('mintlify-localstorage', onStorage); return () => { document.removeEventListener('mintlify-localstorage', onStorage); }; }, []); const toCamelCase = str => typeof str === 'string' ? str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase()) : str; const resolvedBody = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(body) : body; }, [body, lang]); const resolvedPath = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(path) : path; }, [path, lang]); return {children} ; }; Topics are currently in private beta and only available to a limited number of users. APIs might change before GA. To use the methods on this page, you must upgrade your Resend SDK: ```bash Node.js theme={null} npm install resend@6.3.0-canary.0 ``` ```bash PHP theme={null} composer require resend/resend-php:dev-topics ``` ```python Python theme={null} # Python SDK is not available yet ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet ``` ```go Go theme={null} // Go SDK is not available yet ``` ```rust Rust theme={null} // Rust SDK is not available yet ``` ```java Java theme={null} // Java SDK is not available yet ``` ```csharp .NET theme={null} // C# SDK is not available yet ``` [Get in touch](https://resend.com/contact) if you're interested in testing this feature. ## 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. ```ts Node.js theme={null} 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={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->topics->create([ 'name' => 'Weekly Newsletter', 'default_subscription' => 'opt_in', ]); ``` ```python Python theme={null} # Python SDK is not available yet ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet ``` ```go Go theme={null} // Go SDK is not available yet ``` ```rust Rust theme={null} // Rust SDK is not available yet ``` ```java Java theme={null} // Java SDK is not available yet ``` ```csharp .NET theme={null} // C# SDK is not available yet ``` ```bash cURL theme={null} 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={null} { "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. export const ResendParamField = ({children, body, path, ...props}) => { const [lang, setLang] = useState(() => { return localStorage.getItem('code') || '"Node.js"'; }); useEffect(() => { const onStorage = event => { const key = event.detail.key; if (key === 'code') { setLang(event.detail.value); } }; document.addEventListener('mintlify-localstorage', onStorage); return () => { document.removeEventListener('mintlify-localstorage', onStorage); }; }, []); const toCamelCase = str => typeof str === 'string' ? str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase()) : str; const resolvedBody = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(body) : body; }, [body, lang]); const resolvedPath = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(path) : path; }, [path, lang]); return {children} ; }; Topics are currently in private beta and only available to a limited number of users. APIs might change before GA. To use the methods on this page, you must upgrade your Resend SDK: ```bash Node.js theme={null} npm install resend@6.3.0-canary.0 ``` ```bash PHP theme={null} composer require resend/resend-php:dev-topics ``` ```python Python theme={null} # Python SDK is not available yet ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet ``` ```go Go theme={null} // Go SDK is not available yet ``` ```rust Rust theme={null} // Rust SDK is not available yet ``` ```java Java theme={null} // Java SDK is not available yet ``` ```csharp .NET theme={null} // C# SDK is not available yet ``` [Get in touch](https://resend.com/contact) if you're interested in testing this feature. ## Path Parameters The topic ID. ```ts Node.js theme={null} 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={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->topics->remove('b6d24b8e-af0b-4c3c-be0c-359bbd97381e'); ``` ```python Python theme={null} # Python SDK is not available yet ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet ``` ```go Go theme={null} // Go SDK is not available yet ``` ```rust Rust theme={null} // Rust SDK is not available yet ``` ```java Java theme={null} // Java SDK is not available yet ``` ```csharp .NET theme={null} // C# SDK is not available yet ``` ```bash cURL theme={null} curl -X DELETE 'https://api.resend.com/topics/b6d24b8e-af0b-4c3c-be0c-359bbd97381e' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={null} { "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. export const ResendParamField = ({children, body, path, ...props}) => { const [lang, setLang] = useState(() => { return localStorage.getItem('code') || '"Node.js"'; }); useEffect(() => { const onStorage = event => { const key = event.detail.key; if (key === 'code') { setLang(event.detail.value); } }; document.addEventListener('mintlify-localstorage', onStorage); return () => { document.removeEventListener('mintlify-localstorage', onStorage); }; }, []); const toCamelCase = str => typeof str === 'string' ? str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase()) : str; const resolvedBody = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(body) : body; }, [body, lang]); const resolvedPath = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(path) : path; }, [path, lang]); return {children} ; }; Topics are currently in private beta and only available to a limited number of users. APIs might change before GA. To use the methods on this page, you must upgrade your Resend SDK: ```bash Node.js theme={null} npm install resend@6.3.0-canary.0 ``` ```bash PHP theme={null} composer require resend/resend-php:dev-topics ``` ```python Python theme={null} # Python SDK is not available yet ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet ``` ```go Go theme={null} // Go SDK is not available yet ``` ```rust Rust theme={null} // Rust SDK is not available yet ``` ```java Java theme={null} // Java SDK is not available yet ``` ```csharp .NET theme={null} // C# SDK is not available yet ``` [Get in touch](https://resend.com/contact) if you're interested in testing this feature. ## Path Parameters The Topic ID. ```ts Node.js theme={null} 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={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->topics->get('b6d24b8e-af0b-4c3c-be0c-359bbd97381e'); ``` ```python Python theme={null} # Python SDK is not available yet ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet ``` ```go Go theme={null} // Go SDK is not available yet ``` ```rust Rust theme={null} // Rust SDK is not available yet ``` ```java Java theme={null} // Java SDK is not available yet ``` ```csharp .NET theme={null} // C# SDK is not available yet ``` ```bash cURL theme={null} curl -X GET 'https://api.resend.com/topics/b6d24b8e-af0b-4c3c-be0c-359bbd97381e' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={null} { "id": "b6d24b8e-af0b-4c3c-be0c-359bbd97381e", "name": "Weekly Newsletter", "description": "Weekly newsletter for our subscribers", "default_subscription": "opt_in", "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. Topics are currently in private beta and only available to a limited number of users. APIs might change before GA. To use the methods on this page, you must upgrade your Resend SDK: ```bash Node.js theme={null} npm install resend@6.3.0-canary.0 ``` ```bash PHP theme={null} composer require resend/resend-php:dev-topics ``` ```python Python theme={null} # Python SDK is not available yet ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet ``` ```go Go theme={null} // Go SDK is not available yet ``` ```rust Rust theme={null} // Rust SDK is not available yet ``` ```java Java theme={null} // Java SDK is not available yet ``` ```csharp .NET theme={null} // C# SDK is not available yet ``` [Get in touch](https://resend.com/contact) if you're interested in testing this feature. ## Query Parameters Number of topics to retrieve. Default is `20`, maximum is `100`, and minimum is `1`. The ID *after* which we'll retrieve more topics (for pagination). This ID will *not* be included in the returned list. Cannot be used with the `before` parameter. The ID *before* which we'll retrieve more topics (for pagination). This ID will *not* be included in the returned list. Cannot be used with the `after` parameter. ```ts Node.js theme={null} import { Resend } from 'resend'; const resend = new Resend('re_xxxxxxxxx'); const { data, error } = await resend.topics.list(); ``` ```php PHP theme={null} $resend = Resend::client('re_xxxxxxxxx'); $resend->topics->list(); ``` ```php PHP theme={null} // PHP SDK is not available yet ``` ```python Python theme={null} # Python SDK is not available yet ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet ``` ```go Go theme={null} // Go SDK is not available yet ``` ```rust Rust theme={null} // Rust SDK is not available yet ``` ```java Java theme={null} // Java SDK is not available yet ``` ```csharp .NET theme={null} // C# SDK is not available yet ``` ```bash cURL theme={null} curl -X GET 'https://api.resend.com/topics' \ -H 'Authorization: Bearer re_xxxxxxxxx' ``` ```json Response theme={null} { "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", "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. export const ResendParamField = ({children, body, path, ...props}) => { const [lang, setLang] = useState(() => { return localStorage.getItem('code') || '"Node.js"'; }); useEffect(() => { const onStorage = event => { const key = event.detail.key; if (key === 'code') { setLang(event.detail.value); } }; document.addEventListener('mintlify-localstorage', onStorage); return () => { document.removeEventListener('mintlify-localstorage', onStorage); }; }, []); const toCamelCase = str => typeof str === 'string' ? str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase()) : str; const resolvedBody = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(body) : body; }, [body, lang]); const resolvedPath = useMemo(() => { const value = JSON.parse(lang); return value === 'Node.js' ? toCamelCase(path) : path; }, [path, lang]); return {children} ; }; Topics are currently in private beta and only available to a limited number of users. APIs might change before GA. To use the methods on this page, you must upgrade your Resend SDK: ```bash Node.js theme={null} npm install resend@6.3.0-canary.0 ``` ```bash PHP theme={null} composer require resend/resend-php:dev-topics ``` ```python Python theme={null} # Python SDK is not available yet ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet ``` ```go Go theme={null} // Go SDK is not available yet ``` ```rust Rust theme={null} // Rust SDK is not available yet ``` ```java Java theme={null} // Java SDK is not available yet ``` ```csharp .NET theme={null} // C# SDK is not available yet ``` [Get in touch](https://resend.com/contact) if you're interested in testing this feature. ## Path Parameters The Topic ID. ## Body Parameters The topic name. Max length is `50` characters. The topic description. Max length is `200` characters. ```ts Node.js theme={null} 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={null} $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={null} # Python SDK is not available yet ``` ```ruby Ruby theme={null} # Ruby SDK is not available yet ``` ```go Go theme={null} // Go SDK is not available yet ``` ```rust Rust theme={null} // Rust SDK is not available yet ``` ```java Java theme={null} // Java SDK is not available yet ``` ```csharp .NET theme={null} // C# SDK is not available yet ``` ```bash cURL theme={null} 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={null} { "id": "b6d24b8e-af0b-4c3c-be0c-359bbd97381e" } ``` # 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. 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 * 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.