# Attachments

Download a file from a message.

An SDK signs every request with your key: [Authentication](https://mailset.app/docs/authentication.md). To sign one yourself, see [Calling the API without an SDK](https://mailset.app/docs/authentication/http.md).

## attachments.get

Download an attachment.

`POST /v1/attachments.get`

An app key with `read` on the mailbox. Or a person: any signed-in person, with an API token.

### Parameters

- `id` (string, required): The attachment’s id, from the message it came on in `threads get`.

### Returns

`data` is an object with:

- `name` (string): The file’s name.
- `contentType` (string): Its media type, as the message declared it.
- `size` (number): Its size in bytes.
- `data` (string): The file, base64.

### Request

TypeScript:

```typescript
import { Mailset } from 'mailset';

// Reads MAILSET_KEY from the environment.
const mailset = new Mailset();

const answer = await mailset.attachments.get({
	id: "att_3c9e1f7a5b2d4086c7e1a9f2",
});
console.log(answer);
```

Python:

```python
from mailset import Mailset

# Reads MAILSET_KEY from the environment.
mailset = Mailset()

answer = mailset.attachments.get(
    {"id": "att_3c9e1f7a5b2d4086c7e1a9f2"}
)
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_KEY from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	params := &mailset.AttachmentsGetParams{
		ID: "att_3c9e1f7a5b2d4086c7e1a9f2",
	}
	answer, err := client.Attachments.Get(ctx, params)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

# Reads MAILSET_KEY from the environment.
mailset = Mailset::Client.new

answer = mailset.attachments.get(
  id: 'att_3c9e1f7a5b2d4086c7e1a9f2'
)
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

// Reads MAILSET_KEY from the environment.
$mailset = new Mailset\Client();

$answer = $mailset->attachments->get([
    'id' => 'att_3c9e1f7a5b2d4086c7e1a9f2',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.AttachmentsGetParams;
import app.mailset.model.AttachmentsGetResult;

// Reads MAILSET_KEY from the environment.
Mailset mailset = Mailset.fromEnv();

var params = AttachmentsGetParams.builder()
        .id("att_3c9e1f7a5b2d4086c7e1a9f2")
        .build();
AttachmentsGetResult answer =
        mailset.attachments().get(params);
System.out.println(answer);
```

Rust:

```rust
use mailset::types::AttachmentsGetParams;

// Reads MAILSET_KEY from the environment.
let mailset = mailset::Client::from_env()?;

let answer = mailset
    .attachments()
    .get(AttachmentsGetParams {
        id: "att_3c9e1f7a5b2d4086c7e1a9f2".into(),
    })
    .await?;
println!("{answer:?}");
```

curl:

```bash
curl https://mailset.app/v1/attachments.get \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"id":"att_3c9e1f7a5b2d4086c7e1a9f2"}}'
```

curl can’t sign a request. `$TOKEN` is your credential’s token, and `$MS_TIME` and `$MS_PROOF` sign this exact body: [Calling the API without an SDK](https://mailset.app/docs/authentication/http) shows how.

CLI:

```bash
mailset attachments get att_3c9e1f7a5b2d4086c7e1a9f2 --out invoice.pdf
```

### Response

```json
{
  "ok": true,
  "data": {
    "name": "Acme API",
    "contentType": "text",
    "size": 20480,
    "data": "<base64>"
  }
}
```

In the CLI: [mailset reference](https://mailset.app/docs/cli/attachments#attachments-get)

---

© 2026 Intenseloop, Inc. Mailset’s site, docs and guides are copyrighted. You may read them and use their code to build with Mailset. Don’t republish them or use them to build a copy of Mailset. Terms: https://mailset.app/terms#content