<!-- https://missblue.dev/docs/attachments -->

# Attachments

Upload first, then send the id. The upload is a raw body, not a multipart form.

Base URL: `https://api.missblue.dev`

Every request carries `Authorization: Bearer $MISS_BLUE_KEY`.

### GET /v1/messages/{id}/attachments/{attachment_id}

Download a file from a message your project can read.

Accepts the same project bearer key as the message API. The attachment must appear in this message's attachments array. Returns the original bytes and Content-Type with private, no-store caching. A missing file, unreadable message, or unrelated attachment returns 404. Received files can remain unavailable if the file did not finish uploading; reconcile before a bounded retry. On a Twilio line, each photo, video, sound or file on an incoming MMS is kept the same way and downloads with this route.

Example:

```bash
curl -X GET https://api.missblue.dev/v1/messages/0b5ed7e8-f7a1-4f6e-9c2a-2a1f0d9e8b77/attachments/7deff905-9038-4e4e-b47c-580a1ab52220 --output attachment.bin \
  -H "Authorization: Bearer $MISS_BLUE_KEY"
```

Response:

```json
Original attachment bytes
```

Errors:

- `404` — Message or attachment unavailable to this project, or attachment does not belong to the message.

### POST /v1/attachments

Upload a file and get an id to send it with.

The file name and type ride in headers. GIFs, common video and voice-recording formats, PDFs, archives, Office and iWork files are accepted up to 100 MiB. Send one attachment id per message call.

Headers beyond `Authorization` and `Content-Type`:

- `Content-Type`: image/png
- `X-Miss-Blue-File-Name`: receipt.png

| Parameter | Type | Required | Notes |
| --- | --- | --- | --- |
| `X-Miss-Blue-File-Name` | `header` | yes | The name the recipient sees. |
| `Content-Type` | `header` | yes | Must be a type we allow. |

Request body: the raw bytes of the file (`receipt.png`), not JSON.

Example:

```bash
curl -X POST https://api.missblue.dev/v1/attachments \
  -H "Authorization: Bearer $MISS_BLUE_KEY" \
  -H "Content-Type: image/png" \
  -H "X-Miss-Blue-File-Name: receipt.png" \
  --data-binary @receipt.png
```

Response:

```json
{
  "id": "7deff905-9038-4e4e-b47c-580a1ab52220",
  "file_name": "receipt.png",
  "mime_type": "image/png",
  "size_bytes": 20481,
  "sha256": "c414cd0e204de974f73753c7e28d7638e7b3691bb8b1a2bab6b25bb7fed7ce77"
}
```

Errors:

- `400` — An empty file, a missing name, or a type we do not allow.
- `413` — Over the size limit.
