# Process receiving attachments

> List a received email’s attachments and download each one with a short-lived download_url.

A common reason to receive email is to process **attachments** — airplane tickets, receipts, expenses, and so on. You can inspect attachments in the dashboard, or process them programmatically with the [Attachments API](https://www.mailblastr.com/docs/receiving/attachments).

## View and download in the dashboard

1. **Open Emails → Receiving** — Go to Emails and select the "Receiving" tab.
2. **Open the message** — Open the received email that includes the attachment.
3. **Download** — Click the attachment to download it locally.

For automated processing, use the Attachments API instead.

## Process attachments programmatically

> **Warning:** Webhooks include attachment **metadata** only — not the content. Call the [List attachments](https://www.mailblastr.com/docs/receiving/attachments) API to get each attachment's `download_url`, which points at the actual bytes. This keeps webhook payloads small for serverless platforms with limited request-body sizes.

After the `email.received` webhook, call the Attachments API for the `email_id`. It returns a `data` array of attachments, each with metadata and a `download_url` you fetch to get the bytes. To retrieve a single attachment, use [Retrieve attachment](https://www.mailblastr.com/docs/receiving/attachments).

> **Note:** A `download_url` is valid for **1 hour**. After it expires, call the Attachments API again to get a fresh URL. Each attachment also carries an `expires_at` field telling you exactly when its current URL stops working.

**Node.js**

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

const mb = new MailBlastr('mb_xxxxxxxxx');

const { data, error } = await mb.emails.receiving.listAttachments('56761188-7520-42d8-8898-ff6fc54ce618');
console.log({ data, error });
```

**Ruby**

```ruby
require "mailblastr"

Mailblastr.api_key = "mb_xxxxxxxxx"

Mailblastr::Emails::Receiving.list_attachments("56761188-7520-42d8-8898-ff6fc54ce618")
```

**PHP**

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

$mailblastr->emails->receiving->listAttachments('56761188-7520-42d8-8898-ff6fc54ce618');
```

**Python**

```python
import mailblastr

mailblastr.api_key = "mb_xxxxxxxxx"

mailblastr.Emails.Receiving.attachments("56761188-7520-42d8-8898-ff6fc54ce618")
```

**Go**

```go
package main

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

func main() {
    req, _ := http.NewRequest("GET", "https://api.mailblastr.com/emails/receiving/56761188-7520-42d8-8898-ff6fc54ce618/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/receiving/56761188-7520-42d8-8898-ff6fc54ce618/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/receiving/56761188-7520-42d8-8898-ff6fc54ce618/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/receiving/56761188-7520-42d8-8898-ff6fc54ce618/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/receiving/56761188-7520-42d8-8898-ff6fc54ce618/attachments' \
  -H 'Authorization: Bearer mb_xxxxxxxxx'
```

**CLI**

```bash
mailblastr emails receiving attachments 56761188-7520-42d8-8898-ff6fc54ce618
```

## Attachment fields

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | No | The attachment id, unique within the received email. |
| `filename` | string | No | The attachment file name (e.g. `invoice.pdf`). |
| `content_type` | string | No | MIME type of the attachment (e.g. `image/png`). |
| `content_disposition` | string | No | `attachment` or `inline` (inline parts are typically embedded images). |
| `content_id` | string | No | The MIME `Content-ID` for an inline part, used to reference it from the HTML body. |
| `download_url` | string | No | A short-lived URL to download the raw bytes. Valid for 1 hour. |
| `expires_at` | string | No | ISO 8601 timestamp when the current `download_url` expires. |

Once you have processed the attachments, you may want to [forward the email](https://www.mailblastr.com/docs/receiving/forward-emails) to another address.
