---
title: "Export"
description: "Export every message in a MachineMail inbox, oldest first, as one mbox file of raw MIME or as JSON Lines with one Message object per line."
canonical: "https://machinemail.dev/docs/reference/api/export"
---

# Export

> Export every message in a MachineMail inbox, oldest first, as one mbox file of raw MIME or as JSON Lines with one Message object per line.

Source: https://machinemail.dev/docs/reference/api/export

| Method | Path                                          | Summary                                     |
| ------ | --------------------------------------------- | ------------------------------------------- |
| `GET`  | `/v0/inboxes/{inbox_id}/export`               | [Export Inbox](#export-inbox)               |
| `GET`  | `/v0/pods/{pod_id}/inboxes/{inbox_id}/export` | [Export Inbox in Pod](#export-inbox-in-pod) |

## Export Inbox

```http
GET /v0/inboxes/{inbox_id}/export
```

Every message in the inbox, oldest first, streamed as an attachment named `<inbox_id>.<format>`.

**Authentication:** `Authorization: Bearer <api key>` or the dashboard `mm_session` cookie. Permission: `message_read`.

#### Path parameters

| Field | Type | | Description |
| --- | --- | --- | --- |
| `inbox_id` | `string` | required | ID of the inbox: its email address, as in AgentMail (inbox_id == email). |

#### Query parameters

| Field | Type | | Description |
| --- | --- | --- | --- |
| `format` | `"mbox" \| "jsonl"` |  | mbox: every message as raw MIME in one mbox file. jsonl: one Message JSON object per line. Default: `"mbox"`. |

#### Response

**200** The export (`application/mbox`, `application/x-ndjson`)

Headers:

| Field | Type | | Description |
| --- | --- | --- | --- |
| `Content-Disposition` | `string` |  | attachment; filename="<inbox_id>.<format>" |

#### Errors

| Status | Meaning                                                                                                                                                                                                                                |
| ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `400`  | Invalid request: error.type is validation and error.param names the field.                                                                                                                                                             |
| `401`  | Missing, invalid, expired or revoked credential.                                                                                                                                                                                       |
| `403`  | The credential lacks the permission or scope for this request (error.type forbidden), or MachineMail suspended the organization or its sending (account\_suspended: error.message says what still works; do not retry or re-register). |
| `404`  | Not found. Also returned for resources outside the credential scope.                                                                                                                                                                   |
| `500`  | Unexpected server error.                                                                                                                                                                                                               |

Error bodies use the [error envelope](https://machinemail.dev/docs/reference/errors).

#### Example

```bash title="Request"
curl "https://api.machinemail.dev/v0/inboxes/agent@machinemail.dev/export" \
  -H "Authorization: Bearer $MACHINEMAIL_API_KEY"
```

## Export Inbox in Pod

```http
GET /v0/pods/{pod_id}/inboxes/{inbox_id}/export
```

Same as Export Inbox (`GET /v0/inboxes/{inbox_id}/export`), limited to the pod.

**Authentication:** `Authorization: Bearer <api key>` or the dashboard `mm_session` cookie. Permission: `message_read`.

#### Path parameters

| Field | Type | | Description |
| --- | --- | --- | --- |
| `pod_id` | `string` | required | ID of the pod. |
| `inbox_id` | `string` | required | ID of the inbox: its email address, as in AgentMail (inbox_id == email). |

#### Query parameters

| Field | Type | | Description |
| --- | --- | --- | --- |
| `format` | `"mbox" \| "jsonl"` |  | mbox: every message as raw MIME in one mbox file. jsonl: one Message JSON object per line. Default: `"mbox"`. |

#### Response

**200** The export (`application/mbox`, `application/x-ndjson`)

Headers:

| Field | Type | | Description |
| --- | --- | --- | --- |
| `Content-Disposition` | `string` |  | attachment; filename="<inbox_id>.<format>" |

#### Errors

| Status | Meaning                                                                                                                                                                                                                                |
| ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `400`  | Invalid request: error.type is validation and error.param names the field.                                                                                                                                                             |
| `401`  | Missing, invalid, expired or revoked credential.                                                                                                                                                                                       |
| `403`  | The credential lacks the permission or scope for this request (error.type forbidden), or MachineMail suspended the organization or its sending (account\_suspended: error.message says what still works; do not retry or re-register). |
| `404`  | Not found. Also returned for resources outside the credential scope.                                                                                                                                                                   |
| `500`  | Unexpected server error.                                                                                                                                                                                                               |

Error bodies use the [error envelope](https://machinemail.dev/docs/reference/errors).

#### Example

```bash title="Request"
curl "https://api.machinemail.dev/v0/pods/pod_01k6x2m9qd0001b8j4mr0w3d5f/inboxes/agent@machinemail.dev/export" \
  -H "Authorization: Bearer $MACHINEMAIL_API_KEY"
```
