# Upload a template media header asset

Canonical: https://docs.bluehola.com/docs/templates-flows-media/post-v1-templates-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/templates/media</code></div>

Upload a template media header asset (multipart) and get back the `handle` to put in components.

:::note[Authentication]

Send `Authorization: Bearer <API_KEY>` in the request headers; required scope: `templates:manage`. 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 |
| --- | --- | --- | --- | --- |
| `wabaId` | query | Yes | string | The platform's WABA ID, `waba_...`. **Required** — missing or empty returns `400 VALIDATION_FAILED` |

### 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`. Each file is also checked against the per-type limit listed under **Supported types and expiry** below, with the same error code.
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

#### A template with an image/video/document header must come here first
Meta requires a template's media header to be declared **only** via an asset handle, and a handle can only be obtained from the Resumable Upload API. First call `POST /v1/templates/media?wabaId=waba_...` (multipart, one `file` part) to get a `handle`, then put it into the template component:

```json
{ "type": "HEADER", "format": "IMAGE", "example": { "header_handle": ["<handle>"] } }
```

#### It is not the same thing as `POST /v1/media`
`POST /v1/media` produces a media id for **sending messages**; this endpoint produces a handle for **building templates**. The two are not interchangeable — putting a media id into `header_handle` is rejected by Meta.

#### Supported types and expiry
Only `image/jpeg`, `image/jpg`, `image/png`, `video/mp4` and `application/pdf` (Meta's allowlist, checked locally first, telling you the permitted list). Each type also has its own size limit: **5 MB** for `image/jpeg`/`image/png`, **16 MB** for `video/mp4` and `application/pdf` — the platform caps documents stricter than Meta's own 100 MB, because the upload path buffers the whole file in memory. **The handle expires after about 4 days** (the response's `expiresAt` is exactly that) — build the template as soon as you get it, and do not treat it as an asset library.
