Skip to main content
Resend Docs

Search documentation

Type to search this documentation.

On this pageOverview

Attachments

There are two ways to send attachments:

  1. From a remote file
  2. From a local file

Include the path parameter to send attachments from a remote file. This parameter accepts a URL to the file you want to attach.

Define the file name that will be attached using the filename parameter.

Node.js
import { Resend } from 'resend';const resend = new Resend('re_xxxxxxxxx');await resend.emails.send({  from: 'Acme <onboarding@resend.dev>',  to: ['delivered@resend.dev'],  subject: 'Receipt for your payment',  html: '<p>Thanks for the payment</p>',  attachments: [    {      path: 'https://resend.com/static/sample/invoice.pdf',      filename: 'invoice.pdf',    },  ],});
PHP
$resend = Resend::client('re_xxxxxxxxx');$resend->emails->send([  'from' => 'Acme <onboarding@resend.dev>',  'to' => ['delivered@resend.dev'],  'subject' => 'Receipt for your payment',  'html' => '<p>Thanks for the payment</p>',  'attachments' => [    [      'path' => 'https://resend.com/static/sample/invoice.pdf',      'filename' => 'invoice.pdf'    ]  ]]);
Python
import resendresend.api_key = "re_xxxxxxxxx"attachment: resend.RemoteAttachment = {  "path": "https://resend.com/static/sample/invoice.pdf",  "filename": "invoice.pdf",}params: resend.Emails.SendParams = {  "from": "Acme <onboarding@resend.dev>",  "to": ["delivered@resend.dev"],  "subject": "Receipt for your payment",  "html": "<p>Thanks for the payment</p>",  "attachments": [attachment],}resend.Emails.send(params)
Ruby
require "resend"Resend.api_key = "re_xxxxxxxxx"params = {  "from": "Acme <onboarding@resend.dev>",  "to": ["delivered@resend.dev"],  "subject": "Receipt for your payment",  "html": "<p>Thanks for the payment</p>",  "attachments": [    {      "path": "https://resend.com/static/sample/invoice.pdf",      "filename": 'invoice.pdf',    }  ]}Resend::Emails.send(params)
Go
package mainimport (	"context"	"fmt"	"github.com/resend/resend-go/v4")func main() {  ctx := context.TODO()  client := resend.NewClient("re_xxxxxxxxx")  attachment := &resend.Attachment{    Path:  "https://resend.com/static/sample/invoice.pdf",    Filename: "invoice.pdf",  }  params := &resend.SendEmailRequest{      From:        "Acme <onboarding@resend.dev>",      To:          []string{"delivered@resend.dev"},      Subject:     "Receipt for your payment",      Html:        "<p>Thanks for the payment</p>",      Attachments: []*resend.Attachment{attachment},  }  sent, err := client.Emails.SendWithContext(ctx, params)  if err != nil {    panic(err)  }  fmt.Println(sent.Id)}
Rust
use resend_rs::types::{CreateAttachment, CreateEmailBaseOptions};use resend_rs::{Resend, Result};#[tokio::main]async fn main() -> Result<()> {  let resend = Resend::new("re_xxxxxxxxx");  let from = "Acme <onboarding@resend.dev>";  let to = ["delivered@resend.dev"];  let subject = "Receipt for your payment";  let path = "https://resend.com/static/sample/invoice.pdf";  let filename = "invoice.pdf";  let email = CreateEmailBaseOptions::new(from, to, subject)    .with_html("<p>Thanks for the payment</p>")    .with_attachment(CreateAttachment::from_path(path).with_filename(filename));  let _email = resend.emails.send(email).await?;  Ok(())}
Java
import com.resend.*;import com.resend.core.exception.ResendException;import com.resend.services.emails.model.Attachment;import com.resend.services.emails.model.CreateEmailOptions;import com.resend.services.emails.model.CreateEmailResponse;public class Main {    public static void main(String[] args) throws ResendException {        Resend resend = new Resend("re_xxxxxxxxx");        Attachment att = Attachment.builder()                .path("https://resend.com/static/sample/invoice.pdf")                .fileName("invoice.pdf")                .build();        CreateEmailOptions params = CreateEmailOptions.builder()                .from("Acme <onboarding@resend.dev>")                .to("delivered@resend.dev")                .subject("Receipt for your payment")                .html("<p>Thanks for the payment</p>")                .attachments(att)                .build();        CreateEmailResponse data = resend.emails().send(params);    }}
.NET
using Resend;using System.Collections.Generic;IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DIvar message = new EmailMessage(){    From = "Acme <onboarding@resend.dev>",    To = "delivered@resend.dev",    Subject = "Receipt for your payment",    HtmlBody = "<p>Thanks for the payment</p>",};message.Attachments = new List<EmailAttachment>();message.Attachments.Add( new EmailAttachment() {  Filename = "invoice.pdf",  Path = "https://resend.com/static/sample/invoice.pdf",} );var resp = await resend.EmailSendAsync( message );Console.WriteLine( "Email Id={0}", resp.Content );
cURL
curl -X POST 'https://api.resend.com/emails' \     -H 'Authorization: Bearer re_xxxxxxxxx' \     -H 'Content-Type: application/json' \     -d $'{  "from": "Acme <onboarding@resend.dev>",  "to": ["delivered@resend.dev"],  "subject": "Receipt for your payment",  "html": "<p>Thanks for the payment</p>",  "attachments": [    {      "path": "https://resend.com/static/sample/invoice.pdf",      "filename": "invoice.pdf"    }  ]}'

Include the content parameter to send attachments from a local file. This parameter accepts the Base64 encoded content of the file you want to attach.

Define the file name that will be attached using the filename parameter.

Node.js
import { Resend } from 'resend';import fs from 'fs';const resend = new Resend('re_xxxxxxxxx');const filepath = `${__dirname}/static/invoice.pdf`;const attachment = fs.readFileSync(filepath).toString('base64');await resend.emails.send({  from: 'Acme <onboarding@resend.dev>',  to: ['delivered@resend.dev'],  subject: 'Receipt for your payment',  text: '<p>Thanks for the payment</p>',  attachments: [    {      content: attachment,      filename: 'invoice.pdf',    },  ],});
PHP
$resend = Resend::client('re_xxxxxxxxx');$attachment = base64_encode(file_get_contents(__DIR__ . '/static/invoice.pdf'));$resend->emails->send([  'from' => 'Acme <onboarding@resend.dev>',  'to' => ['delivered@resend.dev'],  'subject' => 'Receipt for your payment',  'html' => '<p>Thanks for the payment</p>',  'attachments' => [    [      'filename' => 'invoice.pdf',      'content' => $attachment    ]  ]]);
Python
import osimport resendresend.api_key = "re_xxxxxxxxx"f: bytes = open(  os.path.join(os.path.dirname(__file__), "../static/invoice.pdf"), "rb").read()attachment: resend.Attachment = {"content": list(f), "filename": "invoice.pdf"}params: resend.Emails.SendParams = {  "from": "Acme <onboarding@resend.dev>",  "to": ["delivered@resend.dev"],  "subject": "Receipt for your payment",  "html": "<p>Thanks for the payment</p>",  "attachments": [attachment],}resend.Emails.send(params)
Ruby
require "resend"Resend.api_key = "re_xxxxxxxxx"file = IO.read("invoice.pdf")params = {  "from": "Acme <onboarding@resend.dev>",  "to": ["delivered@resend.dev"],  "subject": "Receipt for your payment",  "html": "<p>Thanks for the payment</p>",  "attachments": [    {      "content": file.bytes,      "filename": 'invoice.pdf',    }  ]}Resend::Emails.send(params)
Go
package mainimport (	"context"	"fmt"	"os"	"github.com/resend/resend-go/v4")func main() {  ctx := context.TODO()  client := resend.NewClient("re_xxxxxxxxx")  pwd, _ := os.Getwd()  f, err := os.ReadFile(pwd + "/static/invoice.pdf")  if err != nil {    panic(err)  }  attachment := &resend.Attachment{    Content:  f,    Filename: "invoice.pdf",  }  params := &resend.SendEmailRequest{      From:        "Acme <onboarding@resend.dev>",      To:          []string{"delivered@resend.dev"},      Subject:     "Receipt for your payment",      Html:        "<p>Thanks for the payment</p>",      Attachments: []*resend.Attachment{attachment},  }  sent, err := client.Emails.SendWithContext(ctx, params)  if err != nil {    panic(err)  }  fmt.Println(sent.Id)}
Rust
use std::fs::File;use std::io::Read;use resend_rs::types::{CreateAttachment, CreateEmailBaseOptions};use resend_rs::{Resend, Result};#[tokio::main]async fn main() -> Result<()> {  let resend = Resend::new("re_xxxxxxxxx");  let from = "Acme <onboarding@resend.dev>";  let to = ["delivered@resend.dev"];  let subject = "Receipt for your payment";  let filename = "invoice.pdf";  let mut f = File::open(filename).unwrap();  let mut invoice = Vec::new();  f.read_to_end(&mut invoice).unwrap();  let email = CreateEmailBaseOptions::new(from, to, subject)    .with_html("<p>Thanks for the payment</p>")    .with_attachment(CreateAttachment::from_content(invoice).with_filename(filename));  let _email = resend.emails.send(email).await?;  Ok(())}
Java
import com.resend.*;import com.resend.core.exception.ResendException;import com.resend.services.emails.model.Attachment;import com.resend.services.emails.model.CreateEmailOptions;import com.resend.services.emails.model.CreateEmailResponse;public class Main {    public static void main(String[] args) throws ResendException {        Resend resend = new Resend("re_xxxxxxxxx");        Attachment att = Attachment.builder()                .fileName("invoice.pdf")                .content("invoiceBuffer")                .build();        CreateEmailOptions params = CreateEmailOptions.builder()                .from("Acme <onboarding@resend.dev>")                .to("delivered@resend.dev")                .subject("Receipt for your payment")                .html("<p>Thanks for the payment</p>")                .attachments(att)                .build();        CreateEmailResponse data = resend.emails().send(params);    }}
.NET
using Resend;using System.Collections.Generic;using System.IO;IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DIvar message = new EmailMessage(){    From = "Acme <onboarding@resend.dev>",    To = "delivered@resend.dev",    Subject = "Receipt for your payment",    HtmlBody = "<p>Thanks for the payment</p>",};message.Attachments = new List<EmailAttachment>();message.Attachments.Add( new EmailAttachment() {  Filename = "invoice.pdf",  Content = await File.ReadAllBytesAsync( "invoice.pdf" ),} );var resp = await resend.EmailSendAsync( message );Console.WriteLine( "Email Id={0}", resp.Content );
cURL
curl -X POST 'https://api.resend.com/emails' \     -H 'Authorization: Bearer re_xxxxxxxxx' \     -H 'Content-Type: application/json' \     -d $'{  "from": "Acme <onboarding@resend.dev>",  "to": ["delivered@resend.dev"],  "subject": "Receipt for your payment",  "html": "<p>Thanks for the payment</p>",  "attachments": [    {      "content": "UmVzZW5kIGF0dGFjaG1lbnQgZXhhbXBsZS4gTmljZSBqb2Igc2VuZGluZyB0aGUgZW1haWwh%",      "filename": "invoice.txt"    }  ]}'
CLI
resend emails send \  --from "Acme <onboarding@resend.dev>" \  --to delivered@resend.dev \  --subject "Receipt for your payment" \  --html "<p>Thanks for the payment</p>" \  --attachment ./static/invoice.pdf

You can optionally embed an image in the HTML body of the email. Both remote and local attachments are supported. All attachment requirements, options, and limitations apply to embedded inline images as well.

Embedding images requires two steps:

1. Add the CID in the email HTML.

Use the prefix cid: to reference the ID in the src attribute of an image tag in the HTML body of the email.

HTML
<img src="cid:logo-image" />

2. Reference the CID in the attachment

The content id is an arbitrary string set by you, and must be less than 128 characters.

Node.js
import { Resend } from 'resend';

const resend = new Resend('re_xxxxxxxxx');

await resend.emails.send({
  from: 'Acme <onboarding@resend.dev>',
  to: ['delivered@resend.dev'],
  subject: 'Thank you for contacting us',
  html: '<p>Here is our <img src="cid:logo-image"/> inline logo</p>',
  attachments: [
    {
      path: 'https://resend.com/static/sample/logo.png',
      filename: 'logo.png',
      contentId: 'logo-image',
    },
  ],
});
PHP
$resend = Resend::client('re_xxxxxxxxx');$resend->emails->send([  'from' => 'Acme <onboarding@resend.dev>',  'to' => ['delivered@resend.dev'],  'subject' => 'Thank you for contacting us',  'html' => '<p>Here is our <img src="cid:logo-image"/> inline logo</p>',  'attachments' => [    [      'path' => 'https://resend.com/static/sample/logo.png',      'filename' => 'logo.png',      'content_id' => 'logo-image',    ]  ]]);
Python
import resendresend.api_key = "re_xxxxxxxxx"attachment: resend.RemoteAttachment = {  "path": "https://resend.com/static/sample/logo.png",  "filename": "logo.png",  "content_id": "logo-image",}params: resend.Emails.SendParams = {  "from": "Acme <onboarding@resend.dev>",  "to": ["delivered@resend.dev"],  "subject": "Thank you for contacting us",  "html": "<p>Here is our <img src=\"cid:logo-image\"/> inline logo</p>",  "attachments": [attachment],}resend.Emails.send(params)
Ruby
require "resend"

Resend.api_key = "re_xxxxxxxxx"

params = {
  "from": "Acme <onboarding@resend.dev>",
  "to": ["delivered@resend.dev"],
  "subject": "Thank you for contacting us",
  "html": "<p>Here is our <img src=\"cid:logo-image\"/> inline logo</p>",
  "attachments": [
    {
      "path": "https://resend.com/static/sample/logo.png",
      "filename": 'logo.png',
      "content_id": "logo-image",
    }
  ]
}

Resend::Emails.send(params)
Go
package main

import (
	"context"
	"fmt"

	"github.com/resend/resend-go/v4"
)

func main() {
  ctx := context.TODO()
  client := resend.NewClient("re_xxxxxxxxx")

  attachment := &resend.Attachment{
    Path:  "https://resend.com/static/sample/logo.png",
    Filename: "logo.png",
    ContentId: "logo-image",
  }

  params := &resend.SendEmailRequest{
      From:        "Acme <onboarding@resend.dev>",
      To:          []string{"delivered@resend.dev"},
      Subject:     "Thank you for contacting us",
      Html:        "<p>Here is our <img src=\"cid:logo-image\"/> inline logo</p>",
      Attachments: []*resend.Attachment{attachment},
  }

  sent, err := client.Emails.SendWithContext(ctx, params)

  if err != nil {
    panic(err)
  }
  fmt.Println(sent.Id)
}
Rust
use resend_rs::types::{CreateAttachment, CreateEmailBaseOptions};
use resend_rs::{Resend, Result};

#[tokio::main]
async fn main() -> Result<()> {
  let resend = Resend::new("re_xxxxxxxxx");

  let from = "Acme <onboarding@resend.dev>";
  let to = ["delivered@resend.dev"];
  let subject = "Thank you for contacting us";

  let path = "https://resend.com/static/sample/logo.png";
  let filename = "logo.png";
  let content_id = "logo-image";

  let email = CreateEmailBaseOptions::new(from, to, subject)
    .with_html("<p>Here is our <img src=\"cid:logo-image\"/> inline logo</p>")
    .with_attachment(
      CreateAttachment::from_path(path)
        .with_filename(filename)
        .with_content_id(content_id),
    );

  let _email = resend.emails.send(email).await?;

  Ok(())
}
Java
import com.resend.*;
import com.resend.core.exception.ResendException;
import com.resend.services.emails.model.Attachment;
import com.resend.services.emails.model.CreateEmailOptions;
import com.resend.services.emails.model.CreateEmailResponse;

public class Main {
    public static void main(String[] args) throws ResendException {
        Resend resend = new Resend("re_xxxxxxxxx");

        Attachment att = Attachment.builder()
                .path("https://resend.com/static/sample/logo.png")
                .fileName("logo.png")
                .contentId("logo-image")
                .build();

        CreateEmailOptions params = CreateEmailOptions.builder()
                .from("Acme <onboarding@resend.dev>")
                .to("delivered@resend.dev")
                .subject("Thank you for contacting us")
                .html("<p>Here is our <img src=\"cid:logo-image\"/> inline logo</p>")
                .attachments(att)
                .build();

        CreateEmailResponse data = resend.emails().send(params);
    }
}
.NET
using Resend;
using System.Collections.Generic;

IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI

var message = new EmailMessage()
{
    From = "Acme <onboarding@resend.dev>",
    To = "delivered@resend.dev",
    Subject = "Thank you for contacting us",
    HtmlBody = "<p>Here is our <img src=\"cid:logo-image\"/> inline logo</p>",
};

message.Attachments = new List<EmailAttachment>();
message.Attachments.Add( new EmailAttachment() {
  Filename = "logo.png",
  Path = "https://resend.com/static/sample/logo.png",
  ContentId = "logo-image",
} );

var resp = await resend.EmailSendAsync( message );
Console.WriteLine( "Email Id={0}", resp.Content );
cURL
curl -X POST 'https://api.resend.com/emails' \     -H 'Authorization: Bearer re_xxxxxxxxx' \     -H 'Content-Type: application/json' \     -d $'{  "from": "Acme <onboarding@resend.dev>",  "to": ["delivered@resend.dev"],  "subject": "Thank you for contacting us",  "html": "<p>Here is our <img src=\"cid:logo-image\"/> inline logo</p>",  "attachments": [    {      "path": "https://resend.com/static/sample/logo.png",      "filename": "logo.png",      "content_id": "logo-image"    }  ]}'

Learn more about embedding images.

You can view and download attachments from sent emails from the dashboard or programmatically through the Attachments API.

  1. Go to Emails.
  2. Navigate to any email you sent with an attachment.
  3. Click on the attachment to download it locally.

Attachments include the filename and an icon to help you identify the type of attachment. Each attachment type has a unique icon:

  • Image
  • PDF
  • Spreadsheet
  • Default (for unknown types)

Use List Attachments to fetch all attachments for a sent email, or Retrieve Attachment to fetch a single one. Both endpoints return a signed download_url that you can use to download the content.

  • Emails can be no larger than 40MB (including attachments after Base64 encoding).
  • Not all file types are supported. See the list of unsupported file types.
  • Emails with attachments cannot be sent using our batching endpoint.
Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu