# molted attachments

Source: https://molted.email/docs/cli/attachments

Manage email attachments

| Command | Description |
| - | - |
| [`molted attachments upload`](#molted-attachments-upload) | Upload an attachment |
| [`molted attachments list`](#molted-attachments-list) | List attachments for a message |
| [`molted attachments download`](#molted-attachments-download) | Download an attachment (without `--output`, prints a signed download URL) |

## Agent context

Attachments let you upload files and include them in outbound emails. Files are uploaded first, then referenced by ID when sending.

### Upload a file

```bash
molted attachments upload ./invoice.pdf
# → { "id": "<uuid>", "filename": "invoice.pdf", "contentType": "application/pdf",
#     "contentTypeDeclared": null, "sizeBytes": 48213, "checksumSha256": "...", "status": "uploaded" }

molted attachments upload ./logo.png --mailbox <id>
# → stores it against that mailbox (a mailbox-scoped key needs send on it)
```

### Include in a send

```bash
molted send --to alice@example.com --template _default \
  --dedupe-key "invoice-alice-1" \
  --payload '{"subject": "Your Invoice", "html": "See attached."}' \
  --attachments '[{"id": "<attachment-id>"}]'
```

### List attachments on a message

```bash
molted attachments list --message-id <id> --message-type inbound
molted attachments list --message-id <id> --message-type thread
# → [{ "id", "filename", "contentType", "sizeBytes", "status", "createdAt" }]
```

### Download an attachment

```bash
molted attachments download <id> --output ./downloaded.pdf
# → { "saved": "./downloaded.pdf", "size": 48213 }
molted attachments download <id>
# → without --output, prints { "url", "expiresInSeconds", "filename",
#   "contentType", "sizeBytes", "status" }: a signed URL valid for 1 hour
```

Uploads: at most 10 MB per file. The CLI sets the content type from the file extension (.pdf, .png, .jpg, .jpeg, .gif, .svg, .txt, .csv, .html, .json, .xml, .zip, .doc, .docx, .xls, .xlsx; anything else is sent as application/octet-stream), and the server re-detects it from the file's bytes (contentTypeDeclared shows the CLI's value when they differ). Executable and script extensions (.exe, .bat, .js, .ps1, .dll and similar) are refused.

Related: [`molted send`](https://molted.email/docs/cli/send.md), [`molted threads`](https://molted.email/docs/cli/threads.md)

## Commands

### molted attachments upload

Upload an attachment

```bash
molted attachments upload [options] <file>
```

| Argument | Description | Required |
| - | - | - |
| `<file>` | | yes |

| Option | Description | Default |
| - | - | - |
| `--mailbox <id>` | Mailbox ID | |

### molted attachments list

List attachments for a message

```bash
molted attachments list [options]
```

| Option | Description | Default |
| - | - | - |
| `--message-id <id>` | Message ID (required) (required) | |
| `--message-type <type>` | Message type (inbound\|thread) (required) (required) | |
| `--include-quarantined` | List the attachments of a quarantined message: names and sizes only, never the bytes (needs an operator-scoped key; never on by default) | |

### molted attachments download

Download an attachment (without `--output`, prints a signed download URL)

```bash
molted attachments download [options] <id>
```

| Argument | Description | Required |
| - | - | - |
| `<id>` | | yes |

| Option | Description | Default |
| - | - | - |
| `--output <file>` | Save the file to this path | |

See [CLI overview](https://molted.email/docs/cli.md) for global options, credentials and output format.
