Appearance
Retrieve an attachment
One attachment that went out with a message, with a fresh signed link to download it.
http
GET /v1/emails/{email_id}/attachments/{attachment_id}Requires a Full access API key.
Path parameters
| Parameter | Type | Description |
|---|---|---|
email_id | string | The email's id — a UUID. |
attachment_id | string | The attachment's id, as returned by List attachments. |
Example
bash
curl "https://api.sendgrail.com/v1/emails/$EMAIL_ID/attachments/$ATTACHMENT_ID" \
-H "Authorization: Bearer $SENDGRAIL_API_KEY"js
const res = await fetch(
`https://api.sendgrail.com/v1/emails/${emailId}/attachments/${attachmentId}`,
{ headers: { Authorization: `Bearer ${process.env.SENDGRAIL_API_KEY}` } },
);
const attachment = await res.json();
// download_url needs no API key — hand it straight to a browser
const file = await fetch(attachment.download_url);Response
json
{
"object": "attachment",
"id": "8e0fd050-661f-4b3c-8178-c4f291d1f751",
"filename": "invoice.pdf",
"content_type": "application/pdf",
"size": 20418,
"download_url": "https://api.sendgrail.com/v1/emails/…/download?expires=…&signature=…",
"expires_at": "2026-07-14T10:09:15+00:00"
}| Field | Type | Description |
|---|---|---|
object | string | Always "attachment". |
id | string | The attachment identifier — a UUID. Stable; the download_url is not. |
filename | string | The name the file was sent under. |
content_type | string | null | MIME type, e.g. application/pdf. null if none was recorded. |
size | number | Decoded size in bytes. |
download_url | string | A signed, short-lived link to the bytes — no API key required. |
expires_at | string | ISO 8601 time the download_url stops working (~15 minutes out). |
The download URL
download_url is the same signed, short-lived link that List attachments returns — valid for about 15 minutes, stated in expires_at. The signature is the authorisation, so the link carries no API key and can be handed straight to a browser, an <img> tag, or a customer. A leaked link exposes one file for fifteen minutes, not your account.
Fetch a fresh copy when it expires; the id is stable, the URL is not.
Errors
An attachment_id that isn't on this email returns 404 not_found — the id must belong to the email named in the path. Once an attachment is past its 30-day retention window the metadata still retrieves, but the download_url returns 404.