---
title: "Download an email attachment"
method: GET
path: "/api/inboxes/{channelId}/threads/{threadId}/messages/{messageId}/attachments/{attachmentId}"
tags: ["Inboxes"]
---

# Download an email attachment

`GET /api/inboxes/{channelId}/threads/{threadId}/messages/{messageId}/attachments/{attachmentId}`

## Request

- Base URL: `https://core-api.getaptly.com`
- URL: `https://core-api.getaptly.com/api/inboxes/{channelId}/threads/{threadId}/messages/{messageId}/attachments/{attachmentId}`
- Auth: one of:
  - API key in header `x-token`
  - API key in header `Authorization`
  - HTTP bearer
- TypeScript: <https://skmtc.dev/getaptly/apis/aptly-api/docs/api/inboxes/:channelId/threads/:threadId/messages/:messageId/attachments/:attachmentId/get.ts> (a function with typed inputs; its response is checked against the schema)

Streams one attachment's bytes through Aptly from the mail provider, with
`Content-Disposition: attachment` and the attachment's file name.
`Content-Type` is the attachment's `contentType` from the message endpoint
(falling back to the provider's, then `application/octet-stream`).
`attachmentId` is an `attachments[].id` from the message endpoint. A `Range`
request header is forwarded, so large files can be fetched in parts (206).

## Path parameters

- `channelId` string, required
- `threadId` string, required
- `messageId` string, required
- `attachmentId` string, required

## Headers

- `Range` string

## Response `200`

The attachment bytes.

## Other responses

- `206`: Partial content for a `Range` request.
- `400`: Not an email message.
- `403`: No access to this inbox.
- `404`: Inbox, thread, message or attachment not found.
- `502`: The mail provider request failed.

---

[API](https://skmtc.dev/getaptly/apis/aptly-api.md) - [All operations](https://skmtc.dev/getaptly/apis/aptly-api/llms.txt) - [OpenAPI document](https://skmtc.dev/getaptly/apis/aptly-api/revisions/75c367e0b8e5?raw)
