# List Attachments

> GET /emails/:id/attachments — list the attachments on a sent email.

`GET /emails/:id/attachments`

List the attachments on an email your account has sent. Each entry returns the attachment metadata — `filename`, `size`, and MIME fields. MailBlastr does not retain the original file bytes for sent mail, so `download_url` and `expires_at` are **`null`** for sent-email attachments; binary retrieval is not guaranteed. (For received mail, attachment bytes are downloadable — see [List Received Attachments](https://www.mailblastr.com/docs/api/emails-received-list-attachments).)

> **Note:** This endpoint is paginated. The `limit` parameter is optional — if you omit it, all attachments are returned in a single response. See [Pagination](https://www.mailblastr.com/docs/api/pagination).

## Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | Yes | The id of the sent email. |

## Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `limit` | number | No | Number of attachments to retrieve per page. Optional. Maximum `100`, minimum `1`. |
| `after` | string | No | The attachment `id` **after** which more attachments are retrieved. The passed id is not included. Cannot be combined with `before`. |
| `before` | string | No | The attachment `id` **before** which more attachments are retrieved. The passed id is not included. Cannot be combined with `after`. |

## Response fields

Each item in `data` is an attachment object:

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | No | The attachment id. |
| `filename` | string | No | The file name. |
| `size` | number | No | The file size in bytes. |
| `content_type` | string | No | The MIME type (e.g. `image/png`). |
| `content_disposition` | string | No | `inline` or `attachment`. |
| `content_id` | string | No | The Content-ID, for inline images referenced by `cid:`. |
| `download_url` | string | null | No | A signed URL to download the file bytes. Always `null` for sent-email attachments — the original bytes are not retained. |
| `expires_at` | string | null | No | ISO 8601 time at which `download_url` expires. Always `null` for sent-email attachments. |

## Request

**Node.js**

```js
import { MailBlastr } from 'mailblastr';

const mb = new MailBlastr('mb_xxxxxxxxx');

const { data, error } = await mb.emails.listAttachments('4ef9a417-02e9-4d39-ad75-9611e0fcc33c');
console.log({ data, error });
```

**Ruby**

```ruby
require "mailblastr"

Mailblastr.api_key = "mb_xxxxxxxxx"

Mailblastr::Emails.list_attachments("4ef9a417-02e9-4d39-ad75-9611e0fcc33c")
```

**PHP**

```php
$mailblastr = Mailblastr::client('mb_xxxxxxxxx');

$mailblastr->emails->attachments->list('4ef9a417-02e9-4d39-ad75-9611e0fcc33c');
```

**Python**

```python
import mailblastr

mailblastr.api_key = "mb_xxxxxxxxx"

mailblastr.Emails.Attachments.list("4ef9a417-02e9-4d39-ad75-9611e0fcc33c")
```

**Go**

```go
package main

import (
    "fmt"
    "io"
    "net/http"
)

func main() {
    req, _ := http.NewRequest("GET", "https://api.mailblastr.com/emails/4ef9a417-02e9-4d39-ad75-9611e0fcc33c/attachments", nil)
    req.Header.Set("Authorization", "Bearer mb_xxxxxxxxx")
    res, _ := http.DefaultClient.Do(req)
    defer res.Body.Close()
    out, _ := io.ReadAll(res.Body)
    fmt.Println(string(out))
}
```

**Rust**

```rust
use reqwest::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let res = Client::new()
        .get("https://api.mailblastr.com/emails/4ef9a417-02e9-4d39-ad75-9611e0fcc33c/attachments")
        .header("Authorization", "Bearer mb_xxxxxxxxx")
        .send()
        .await?;
    println!("{}", res.text().await?);
    Ok(())
}
```

**Java**

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.mailblastr.com/emails/4ef9a417-02e9-4d39-ad75-9611e0fcc33c/attachments"))
    .header("Authorization", "Bearer mb_xxxxxxxxx")
    .method("GET", HttpRequest.BodyPublishers.noBody())
    .build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```

**.NET**

```csharp
using System.Net.Http;
using System.Text;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://api.mailblastr.com/emails/4ef9a417-02e9-4d39-ad75-9611e0fcc33c/attachments");
request.Headers.Add("Authorization", "Bearer mb_xxxxxxxxx");
var response = await client.SendAsync(request);
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

**cURL**

```bash
curl -X GET 'https://api.mailblastr.com/emails/4ef9a417-02e9-4d39-ad75-9611e0fcc33c/attachments' \
  -H 'Authorization: Bearer mb_xxxxxxxxx'
```

**CLI**

```bash
mailblastr emails attachments 4ef9a417-02e9-4d39-ad75-9611e0fcc33c
```

## Response

```json
{
  "object": "list",
  "has_more": false,
  "data": [
    {
      "object": "attachment",
      "id": "2a0c9ce0-3112-4728-976e-47ddcd16a318",
      "filename": "avatar.png",
      "size": 4096,
      "content_type": "image/png",
      "content_disposition": "inline",
      "content_id": "img001",
      "download_url": null,
      "expires_at": null
    }
  ]
}
```

## Errors

Returns `not_found` (404) if no email with that id exists for your account; `validation_error` for a bad cursor or out-of-range `limit`. See the [error reference](https://www.mailblastr.com/docs/api/errors).
