# Upload a multipart file to Meta

Canonical: https://docs.bluehola.com/docs/templates-flows-media/post-v1-media
OpenAPI: https://docs.bluehola.com/openapi.yaml

<div class="endpoint"><span class="endpoint-method endpoint-method--post">POST</span><code class="endpoint-path">/v1/media</code></div>

Upload a multipart file to Meta and get back a media ID.

:::note[Authentication]

Send `Authorization: Bearer <API_KEY>` in the request headers; required scope: `media:write`. Which resources an API Key can reach is determined by its current authorization scope.

:::

## Request

Base URL: `https://api.bluehola.com`

### Parameters

| Name | In | Required | Type / constraints | Description |
| --- | --- | --- | --- | --- |
| `phoneNumberId` | query | Yes | string | The platform's phone number ID, `pn_...`. **Required** — missing or empty returns `400 VALIDATION_FAILED`; it must also pass the API Key's phone number authorization check |

### Request body
A request body is required. A single `file` part (at most 3 files per request); a file over **16 MB** returns `400 VALIDATION_FAILED` with the message `invalid multipart upload (max 16MB per file, 3 files)`. Each file is also checked against a per-type size limit — see **Upload size limits by media type** below — and exceeding that returns `400 VALIDATION_FAILED` with `details: { mimeType, sizeBytes, limitBytes }`.
Content-Type: `multipart/form-data`
Schema:

```json
{
  "type": "object",
  "properties": {
    "file": {
      "type": "string",
      "format": "binary"
    }
  },
  "required": [
    "file"
  ]
}
```

## Response

| Status | Description |
| --- | --- |
| `201` | Created |
| `4xx` | Client error |

For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md).

## Notes

`phoneNumberId` must be the platform's own phone number ID (pn_...) and must belong to the current account; the server resolves the Meta-side phone number ID from it before forwarding the upload. The media itself is not persisted on the platform (only the filename, type and owning phone number are recorded — not the bytes), and Meta-side media IDs typically expire after a few days, so it is not advisable to depend on the same ID long-term.

#### Upload size limits by media type

The platform checks the uploaded file's size against a per-type table that mirrors Meta's own limits, instead of one flat cap:

| Type | Limit |
| --- | --- |
| `image/jpeg`, `image/png` | 5 MB |
| `audio/*` (aac, amr, mpeg, mp4, ogg), `video/3gpp`, `video/mp4` | 16 MB |
| Documents (`text/plain`, `application/pdf`, Word/Excel/PowerPoint) | 16 MB — stricter than Meta's own 100 MB, because the upload path buffers the whole file in memory |
| `image/webp` stickers | 100 KB static / 500 KB animated (read from the WebP container; a container the platform cannot recognize is treated as static, the stricter limit) |
| Any other MIME type | 16 MB, deferred to Meta's own check |

A file over its type's limit is rejected (`400 VALIDATION_FAILED`) before it ever reaches Meta. Audio, video and documents up to 16 MB can now go through this upload channel directly; use the `link` form on the message instead only for assets past these limits (or past Meta's own 100 MB cap for documents).

The format allowlist and other per-type details still follow whatever Meta enforces **when the media message is actually sent**; the platform does not pre-check formats at this layer.
