# Process receiving attachments

> List a received email’s attachments and download each one from its 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.sendping.co/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.sendping.co/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.sendping.co/docs/receiving/attachments).

> **Note:** A `download_url` is **not** a public link: fetch it with the same `Authorization: Bearer` header as every other API call. It does not expire. Attachments whose bytes were not stored have `downloadable: false` and no `download_url` — skip those rather than retrying them.

**Node.js**

```js
import { SendPing } from 'sendping';

const mb = new SendPing('mb_xxxxxxxxx');

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

**Ruby**

```ruby
require "sendping"

SendPing.api_key = "mb_xxxxxxxxx"

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

**PHP**

```php
<?php
require 'vendor/autoload.php';

use SendPing\SendPing;

$sendping = SendPing::client('mb_xxxxxxxxx');

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

**Python**

```python
import sendping

sendping.api_key = "mb_xxxxxxxxx"

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

**Go**

```go
import "github.com/shekhu10/sendping-sdks/sendping-go"

client := sendping.NewClient("mb_xxxxxxxxx")

attachments, err := client.Emails.Receiving.ListAttachments("56761188-7520-42d8-8898-ff6fc54ce618", nil)
```

**Rust**

```rust
use sendping::SendPing;

let mb = SendPing::new("mb_xxxxxxxxx");

let _attachments = mb.emails.receiving.list_attachments("56761188-7520-42d8-8898-ff6fc54ce618", None).await?;
```

**Java**

```java
import co.sendping.SendPing;
import co.sendping.SendPingResponse;

SendPing sendping = new SendPing("mb_xxxxxxxxx");

SendPingResponse response = sendping.emails().receiving().listAttachments("56761188-7520-42d8-8898-ff6fc54ce618");
```

**.NET**

```csharp
using SendPing;

ISendPing sendping = SendPingClient.Create("mb_xxxxxxxxx");

var resp = await sendping.ReceivedEmailListAttachmentsAsync("56761188-7520-42d8-8898-ff6fc54ce618");
```

**cURL**

```bash
curl -X GET 'https://www.sendping.co/api/emails/receiving/56761188-7520-42d8-8898-ff6fc54ce618/attachments' \
  -H 'Authorization: Bearer mb_xxxxxxxxx'
```

**CLI**

```bash
sendping 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. |
| `downloadable` | boolean | No | Whether the file bytes were stored and can be downloaded. `false` means no `download_url` is returned. |
| `download_url` | string | No | URL to download the raw bytes. Requires your API key — send the same `Authorization: Bearer` header. Omitted when `downloadable` is `false`. |

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