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 resend
resend.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 main
import "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(())
}
using Resend;
IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI
var 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"
{
"object": "inbox_draft",
"id": "c3a1e8b4-2d5f-4a7c-9e10-6b8d7f5a4c32"
}
Create Draft
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 resend
resend.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 main
import "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(())
}
using Resend;
IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI
var 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"
{
"object": "inbox_draft",
"id": "c3a1e8b4-2d5f-4a7c-9e10-6b8d7f5a4c32"
}
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 ofto, 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
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: trueheader - 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
Response Fields
string
Always
inbox_draft.string
The ID of the draft.
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 resend
resend.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 main
import "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(())
}
using Resend;
IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI
var 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"
{
"object": "inbox_draft",
"id": "c3a1e8b4-2d5f-4a7c-9e10-6b8d7f5a4c32"
}
Was this page helpful?
⌘I