# Retrieve Attachment

> GET /emails/:id/attachments/:attachment_id — fetch a single attachment from a sent email.

`GET /emails/:id/attachments/:attachment_id`

Retrieve a single attachment from a sent email by its id. The response returns the attachment metadata. SendPing does not retain the original file bytes for sent mail, so `download_url` and `expires_at` are **`null`** — binary retrieval is not guaranteed for sent-email attachments.

## Path parameters

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

## Response fields

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `object` | string | No | Always `attachment`. |
| `id` | string | No | The attachment id. |
| `filename` | string | No | The file name. |
| `size` | number | null | No | The file size in bytes, or `null` when the attachment was sent by hosted `path` URL (the size is derived from stored base64 `content`). |
| `content_type` | string | No | The MIME type. |
| `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 { SendPing } from 'sendping';

const mb = new SendPing('mb_xxxxxxxxx');

const { data, error } = await mb.emails.getAttachment('4ef9a417-02e9-4d39-ad75-9611e0fcc33c', '2a0c9ce0-3112-4728-976e-47ddcd16a318');
console.log({ data, error });
```

**Ruby**

```ruby
require "sendping"

SendPing.api_key = "mb_xxxxxxxxx"

SendPing::Emails.get_attachment("4ef9a417-02e9-4d39-ad75-9611e0fcc33c", "2a0c9ce0-3112-4728-976e-47ddcd16a318")
```

**PHP**

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

use SendPing\SendPing;

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

$sendping->emails->getAttachment('4ef9a417-02e9-4d39-ad75-9611e0fcc33c', '2a0c9ce0-3112-4728-976e-47ddcd16a318');
```

**Python**

```python
import sendping

sendping.api_key = "mb_xxxxxxxxx"

sendping.Emails.get_attachment("4ef9a417-02e9-4d39-ad75-9611e0fcc33c", "2a0c9ce0-3112-4728-976e-47ddcd16a318")
```

**Go**

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

client := sendping.NewClient("mb_xxxxxxxxx")

attachment, err := client.Emails.GetAttachment("4ef9a417-02e9-4d39-ad75-9611e0fcc33c", "2a0c9ce0-3112-4728-976e-47ddcd16a318")
```

**Rust**

```rust
use sendping::SendPing;

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

let _attachment = mb.emails.get_attachment("4ef9a417-02e9-4d39-ad75-9611e0fcc33c", "2a0c9ce0-3112-4728-976e-47ddcd16a318").await?;
```

**Java**

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

SendPing sendping = new SendPing("mb_xxxxxxxxx");

SendPingResponse response = sendping.emails().getAttachment(
        "4ef9a417-02e9-4d39-ad75-9611e0fcc33c",
        "2a0c9ce0-3112-4728-976e-47ddcd16a318");
```

**.NET**

```csharp
using SendPing;

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

var resp = await sendping.EmailRetrieveAttachmentAsync(
    "4ef9a417-02e9-4d39-ad75-9611e0fcc33c",
    "2a0c9ce0-3112-4728-976e-47ddcd16a318");
```

**cURL**

```bash
curl -X GET 'https://www.sendping.co/api/emails/4ef9a417-02e9-4d39-ad75-9611e0fcc33c/attachments/2a0c9ce0-3112-4728-976e-47ddcd16a318' \
  -H 'Authorization: Bearer mb_xxxxxxxxx'
```

**CLI**

```bash
sendping emails attachment 4ef9a417-02e9-4d39-ad75-9611e0fcc33c 2a0c9ce0-3112-4728-976e-47ddcd16a318
```

## Response

```json
{
  "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 the email or the attachment does not exist for your account. See the [error reference](https://www.sendping.co/docs/api/errors).
