Create a draft in an inbox, either to start a new thread or reply to an existing thread.
POST
/
inboxes
/
:inbox_id
/
drafts
import { Resend } from 'resend';const resend = new Resend('re_xxxxxxxxx');const { data, error } = await resend.inboxes.drafts.create({ inboxId: 'b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1', to: ['ada@example.org'], subject: 'Refund for order 1041', html: '<p>Refund issued for order 1041.</p>', text: 'Refund issued for order 1041.', attachments: [ { filename: 'note.txt', content: 'aGVsbG8=', contentType: 'text/plain', }, ],});
$resend = Resend::client('re_xxxxxxxxx');$resend->inboxes->drafts->create('b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1', [ 'to' => ['ada@example.org'], 'subject' => 'Refund for order 1041', 'html' => '<p>Refund issued for order 1041.</p>', 'text' => 'Refund issued for order 1041.', 'attachments' => [ [ 'filename' => 'note.txt', 'content' => 'aGVsbG8=', 'content_type' => 'text/plain', ], ],]);
import resendresend.api_key = "re_xxxxxxxxx"params: resend.Inboxes.Drafts.CreateParams = { "inbox_id": "b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1", "to": ["ada@example.org"], "subject": "Refund for order 1041", "html": "<p>Refund issued for order 1041.</p>", "text": "Refund issued for order 1041.", "attachments": [ { "filename": "note.txt", "content": "aGVsbG8=", "content_type": "text/plain", } ],}resend.Inboxes.Drafts.create(params)
require "resend"Resend.api_key = "re_xxxxxxxxx"params = { inbox_id: "b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1", to: ["ada@example.org"], subject: "Refund for order 1041", html: "<p>Refund issued for order 1041.</p>", text: "Refund issued for order 1041.", attachments: [{ filename: "note.txt", content: "aGVsbG8=", content_type: "text/plain" }]}Resend::Inboxes::Drafts.create(params)
package mainimport "github.com/resend/resend-go/v4"func main() { client := resend.NewClient("re_xxxxxxxxx") params := &resend.CreateInboxDraftRequest{ To: []string{"ada@example.org"}, Subject: "Refund for order 1041", Html: "<p>Refund issued for order 1041.</p>", Text: "Refund issued for order 1041.", Attachments: []*resend.InboxDraftAttachmentInput{ { Content: []byte("hello"), Filename: "note.txt", ContentType: "text/plain", }, }, } client.Inboxes.Drafts.Create("b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1", params)}
use resend_rs::{ types::{CreateInboxDraftAttachment, CreateInboxDraftOptions}, Resend, Result,};#[tokio::main]async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let opts = CreateInboxDraftOptions::new() .with_to(["ada@example.org"]) .with_subject("Refund for order 1041") .with_html("<p>Refund issued for order 1041.</p>") .with_text("Refund issued for order 1041.") .with_attachment(CreateInboxDraftAttachment::new( b"hello".to_vec(), "note.txt", "text/plain", )); let _draft = resend .inboxes .create_draft("b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1", opts) .await?; Ok(())}
import com.resend.Resend;import com.resend.core.exception.ResendException;import com.resend.services.emails.model.Attachment;import com.resend.services.inboxes.model.CreateInboxDraftOptions;import com.resend.services.inboxes.model.CreateInboxDraftResponseSuccess;public class Main { public static void main(String[] args) throws ResendException { Resend resend = new Resend("re_xxxxxxxxx"); CreateInboxDraftOptions params = CreateInboxDraftOptions.builder() .to("ada@example.org") .subject("Refund for order 1041") .html("<p>Refund issued for order 1041.</p>") .text("Refund issued for order 1041.") .attachments(Attachment.builder() .fileName("note.txt") .content("aGVsbG8=") .contentType("text/plain") .build()) .build(); CreateInboxDraftResponseSuccess data = resend.inboxes().drafts() .create("b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1", params); }}
using Resend;IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DIvar resp = await resend.InboxDraftCreateAsync( new Guid( "b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1" ), new InboxDraftCreateData() { To = "ada@example.org", Subject = "Refund for order 1041", HtmlBody = "<p>Refund issued for order 1041.</p>", TextBody = "Refund issued for order 1041.", Attachments = [ new EmailAttachment() { Filename = "note.txt", Content = System.Text.Encoding.UTF8.GetBytes( "hello" ), ContentType = "text/plain", }, ], });Console.WriteLine( "Draft Id={0}", resp.Content );
curl -X POST 'https://api.resend.com/inboxes/b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1/drafts' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'{ "to": ["ada@example.org"], "subject": "Refund for order 1041", "html": "<p>Refund issued for order 1041.</p>", "text": "Refund issued for order 1041.", "attachments": [ { "filename": "note.txt", "content": "aGVsbG8=", "content_type": "text/plain" } ]}'
curl -X POST 'https://api.resend.com/inboxes/b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1/drafts' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'{ "thread_id": "4d8e2a1c-9b3f-4c6d-8a21-3e5f7c9c0d12", "reply_to_email_id": "5b1a9f47-2c8d-4e6f-9a03-1d2e3f4a5b60", "text": "Refund issued for order 1041."}'
resend inboxes drafts create b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1 \ --to ada@example.org \ --subject "Refund for order 1041" \ --html "<p>Refund issued for order 1041.</p>" \ --text "Refund issued for order 1041." \ --attachment "./note.txt;type=text/plain"
A draft lets you prepare a message before sending it.Omit thread_id and reply_to_email_id to start a new thread. Pass both for a
reply draft.An email can have only one unsent reply draft. A request for an email that
already has one returns a 200 with the existing Draft ID. It changes only the
attachments of that draft.
Path Parameters
Body Parameters
At least one of to, cc, bcc, subject, text, html, or attachments
must be non-empty. to, cc, and bcc combined cannot exceed 50 recipients.
string | string[] | null
Recipients. For multiple addresses, send an array of strings. Each value can
include a friendly name, for example Ada Lovelace <ada@example.org>. On a
reply draft, when you omit to or send null, the draft gets the recipients
of a reply. Send [] for no
recipients.
string | string[] | null
CC recipients.
string | string[] | null
BCC recipients.
string | null
The subject. 1 to 2000 characters, with no line breaks.
string | null
The HTML body.
string | null
The plain-text body.
array | null
Files to store on the draft, up to 25 MB in total, downloaded files
included. All path downloads must finish within 20 seconds together.
Drafts do not accept content_id.
Hide properties
buffer | string
Content of an attached file, passed as a buffer or Base64 string. Either
content or path must be provided.
string
Path where the attachment file is hosted. Resend downloads it when the
draft is saved, so a URL that cannot be downloaded returns an error. When
both content and path are sent, content is used.
string
required
Name of attached file.
Headers
string
Add an idempotency key to prevent duplicated drafts.
Should be unique per API request
Idempotency keys expire after 24 hours
Have a maximum length of 256 characters
A retry with the same key returns the first successful response, with the
idempotent-replayed: true header
A failed request is not stored, so you can retry it with the same key
Reusing the key with a different body, or while the first request is still
running, returns a 409
import { Resend } from 'resend';const resend = new Resend('re_xxxxxxxxx');const { data, error } = await resend.inboxes.drafts.create({ inboxId: 'b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1', to: ['ada@example.org'], subject: 'Refund for order 1041', html: '<p>Refund issued for order 1041.</p>', text: 'Refund issued for order 1041.', attachments: [ { filename: 'note.txt', content: 'aGVsbG8=', contentType: 'text/plain', }, ],});
$resend = Resend::client('re_xxxxxxxxx');$resend->inboxes->drafts->create('b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1', [ 'to' => ['ada@example.org'], 'subject' => 'Refund for order 1041', 'html' => '<p>Refund issued for order 1041.</p>', 'text' => 'Refund issued for order 1041.', 'attachments' => [ [ 'filename' => 'note.txt', 'content' => 'aGVsbG8=', 'content_type' => 'text/plain', ], ],]);
import resendresend.api_key = "re_xxxxxxxxx"params: resend.Inboxes.Drafts.CreateParams = { "inbox_id": "b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1", "to": ["ada@example.org"], "subject": "Refund for order 1041", "html": "<p>Refund issued for order 1041.</p>", "text": "Refund issued for order 1041.", "attachments": [ { "filename": "note.txt", "content": "aGVsbG8=", "content_type": "text/plain", } ],}resend.Inboxes.Drafts.create(params)
require "resend"Resend.api_key = "re_xxxxxxxxx"params = { inbox_id: "b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1", to: ["ada@example.org"], subject: "Refund for order 1041", html: "<p>Refund issued for order 1041.</p>", text: "Refund issued for order 1041.", attachments: [{ filename: "note.txt", content: "aGVsbG8=", content_type: "text/plain" }]}Resend::Inboxes::Drafts.create(params)
package mainimport "github.com/resend/resend-go/v4"func main() { client := resend.NewClient("re_xxxxxxxxx") params := &resend.CreateInboxDraftRequest{ To: []string{"ada@example.org"}, Subject: "Refund for order 1041", Html: "<p>Refund issued for order 1041.</p>", Text: "Refund issued for order 1041.", Attachments: []*resend.InboxDraftAttachmentInput{ { Content: []byte("hello"), Filename: "note.txt", ContentType: "text/plain", }, }, } client.Inboxes.Drafts.Create("b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1", params)}
use resend_rs::{ types::{CreateInboxDraftAttachment, CreateInboxDraftOptions}, Resend, Result,};#[tokio::main]async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let opts = CreateInboxDraftOptions::new() .with_to(["ada@example.org"]) .with_subject("Refund for order 1041") .with_html("<p>Refund issued for order 1041.</p>") .with_text("Refund issued for order 1041.") .with_attachment(CreateInboxDraftAttachment::new( b"hello".to_vec(), "note.txt", "text/plain", )); let _draft = resend .inboxes .create_draft("b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1", opts) .await?; Ok(())}
import com.resend.Resend;import com.resend.core.exception.ResendException;import com.resend.services.emails.model.Attachment;import com.resend.services.inboxes.model.CreateInboxDraftOptions;import com.resend.services.inboxes.model.CreateInboxDraftResponseSuccess;public class Main { public static void main(String[] args) throws ResendException { Resend resend = new Resend("re_xxxxxxxxx"); CreateInboxDraftOptions params = CreateInboxDraftOptions.builder() .to("ada@example.org") .subject("Refund for order 1041") .html("<p>Refund issued for order 1041.</p>") .text("Refund issued for order 1041.") .attachments(Attachment.builder() .fileName("note.txt") .content("aGVsbG8=") .contentType("text/plain") .build()) .build(); CreateInboxDraftResponseSuccess data = resend.inboxes().drafts() .create("b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1", params); }}
using Resend;IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DIvar resp = await resend.InboxDraftCreateAsync( new Guid( "b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1" ), new InboxDraftCreateData() { To = "ada@example.org", Subject = "Refund for order 1041", HtmlBody = "<p>Refund issued for order 1041.</p>", TextBody = "Refund issued for order 1041.", Attachments = [ new EmailAttachment() { Filename = "note.txt", Content = System.Text.Encoding.UTF8.GetBytes( "hello" ), ContentType = "text/plain", }, ], });Console.WriteLine( "Draft Id={0}", resp.Content );
curl -X POST 'https://api.resend.com/inboxes/b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1/drafts' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'{ "to": ["ada@example.org"], "subject": "Refund for order 1041", "html": "<p>Refund issued for order 1041.</p>", "text": "Refund issued for order 1041.", "attachments": [ { "filename": "note.txt", "content": "aGVsbG8=", "content_type": "text/plain" } ]}'
curl -X POST 'https://api.resend.com/inboxes/b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1/drafts' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'{ "thread_id": "4d8e2a1c-9b3f-4c6d-8a21-3e5f7c9c0d12", "reply_to_email_id": "5b1a9f47-2c8d-4e6f-9a03-1d2e3f4a5b60", "text": "Refund issued for order 1041."}'
resend inboxes drafts create b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1 \ --to ada@example.org \ --subject "Refund for order 1041" \ --html "<p>Refund issued for order 1041.</p>" \ --text "Refund issued for order 1041." \ --attachment "./note.txt;type=text/plain"
import { Resend } from 'resend';const resend = new Resend('re_xxxxxxxxx');const { data, error } = await resend.inboxes.drafts.create({ inboxId: 'b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1', to: ['ada@example.org'], subject: 'Refund for order 1041', html: '<p>Refund issued for order 1041.</p>', text: 'Refund issued for order 1041.', attachments: [ { filename: 'note.txt', content: 'aGVsbG8=', contentType: 'text/plain', }, ],});
$resend = Resend::client('re_xxxxxxxxx');$resend->inboxes->drafts->create('b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1', [ 'to' => ['ada@example.org'], 'subject' => 'Refund for order 1041', 'html' => '<p>Refund issued for order 1041.</p>', 'text' => 'Refund issued for order 1041.', 'attachments' => [ [ 'filename' => 'note.txt', 'content' => 'aGVsbG8=', 'content_type' => 'text/plain', ], ],]);
import resendresend.api_key = "re_xxxxxxxxx"params: resend.Inboxes.Drafts.CreateParams = { "inbox_id": "b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1", "to": ["ada@example.org"], "subject": "Refund for order 1041", "html": "<p>Refund issued for order 1041.</p>", "text": "Refund issued for order 1041.", "attachments": [ { "filename": "note.txt", "content": "aGVsbG8=", "content_type": "text/plain", } ],}resend.Inboxes.Drafts.create(params)
require "resend"Resend.api_key = "re_xxxxxxxxx"params = { inbox_id: "b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1", to: ["ada@example.org"], subject: "Refund for order 1041", html: "<p>Refund issued for order 1041.</p>", text: "Refund issued for order 1041.", attachments: [{ filename: "note.txt", content: "aGVsbG8=", content_type: "text/plain" }]}Resend::Inboxes::Drafts.create(params)
package mainimport "github.com/resend/resend-go/v4"func main() { client := resend.NewClient("re_xxxxxxxxx") params := &resend.CreateInboxDraftRequest{ To: []string{"ada@example.org"}, Subject: "Refund for order 1041", Html: "<p>Refund issued for order 1041.</p>", Text: "Refund issued for order 1041.", Attachments: []*resend.InboxDraftAttachmentInput{ { Content: []byte("hello"), Filename: "note.txt", ContentType: "text/plain", }, }, } client.Inboxes.Drafts.Create("b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1", params)}
use resend_rs::{ types::{CreateInboxDraftAttachment, CreateInboxDraftOptions}, Resend, Result,};#[tokio::main]async fn main() -> Result<()> { let resend = Resend::new("re_xxxxxxxxx"); let opts = CreateInboxDraftOptions::new() .with_to(["ada@example.org"]) .with_subject("Refund for order 1041") .with_html("<p>Refund issued for order 1041.</p>") .with_text("Refund issued for order 1041.") .with_attachment(CreateInboxDraftAttachment::new( b"hello".to_vec(), "note.txt", "text/plain", )); let _draft = resend .inboxes .create_draft("b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1", opts) .await?; Ok(())}
import com.resend.Resend;import com.resend.core.exception.ResendException;import com.resend.services.emails.model.Attachment;import com.resend.services.inboxes.model.CreateInboxDraftOptions;import com.resend.services.inboxes.model.CreateInboxDraftResponseSuccess;public class Main { public static void main(String[] args) throws ResendException { Resend resend = new Resend("re_xxxxxxxxx"); CreateInboxDraftOptions params = CreateInboxDraftOptions.builder() .to("ada@example.org") .subject("Refund for order 1041") .html("<p>Refund issued for order 1041.</p>") .text("Refund issued for order 1041.") .attachments(Attachment.builder() .fileName("note.txt") .content("aGVsbG8=") .contentType("text/plain") .build()) .build(); CreateInboxDraftResponseSuccess data = resend.inboxes().drafts() .create("b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1", params); }}
using Resend;IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DIvar resp = await resend.InboxDraftCreateAsync( new Guid( "b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1" ), new InboxDraftCreateData() { To = "ada@example.org", Subject = "Refund for order 1041", HtmlBody = "<p>Refund issued for order 1041.</p>", TextBody = "Refund issued for order 1041.", Attachments = [ new EmailAttachment() { Filename = "note.txt", Content = System.Text.Encoding.UTF8.GetBytes( "hello" ), ContentType = "text/plain", }, ], });Console.WriteLine( "Draft Id={0}", resp.Content );
curl -X POST 'https://api.resend.com/inboxes/b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1/drafts' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'{ "to": ["ada@example.org"], "subject": "Refund for order 1041", "html": "<p>Refund issued for order 1041.</p>", "text": "Refund issued for order 1041.", "attachments": [ { "filename": "note.txt", "content": "aGVsbG8=", "content_type": "text/plain" } ]}'
curl -X POST 'https://api.resend.com/inboxes/b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1/drafts' \ -H 'Authorization: Bearer re_xxxxxxxxx' \ -H 'Content-Type: application/json' \ -d $'{ "thread_id": "4d8e2a1c-9b3f-4c6d-8a21-3e5f7c9c0d12", "reply_to_email_id": "5b1a9f47-2c8d-4e6f-9a03-1d2e3f4a5b60", "text": "Refund issued for order 1041."}'
resend inboxes drafts create b3e2b2b6-3f0e-4c8e-9ad3-2f43a1e2c7f1 \ --to ada@example.org \ --subject "Refund for order 1041" \ --html "<p>Refund issued for order 1041.</p>" \ --text "Refund issued for order 1041." \ --attachment "./note.txt;type=text/plain"