# WhatsApp template media headers: image, video and document

> Create a WhatsApp template with an image, video or document header using a Resumable Upload handle, then send it with a media ID or link.

Published 2026-11-04. Z-API Omni team.

A WhatsApp template media header takes an asset handle from the Resumable Upload API at creation, and a media `id` or public `link` at send time. The handle goes in `example.header_handle`. The media `id` comes from the `/media` endpoint and goes in the send request's `header` component. A handle looks like `4::aW...` and a media ID is a plain number such as `1339522734477770`.

## Get a header handle with the Resumable Upload API

Meta's components page says to "Use the Resumable Upload API to generate an asset handle" and put it in `header_handle` ([components, accessed 2026-11-04](https://developers.facebook.com/documentation/business-messaging/whatsapp/templates/components)). The upload guide is a general Graph API page ([Resumable Upload API, accessed 2026-11-04](https://developers.facebook.com/docs/graph-api/guides/upload)). It needs three things:

1. Your Meta app ID.
2. A file in a supported `file_type`: `application/pdf`, `image/jpeg`, `image/jpg`, `image/png` or `video/mp4`.
3. A user access token.

The guide names only a user access token. It doesn't say whether a system user token works here, so test that before you automate it. Tokens in general are covered in [Cloud API access tokens and system users](/academy/articles/whatsapp-cloud-api-access-tokens-system-user/).

Step one opens an upload session. Meta's sample splits the URL across lines inside double quotes, which doesn't run. The version below joins it onto one line, moves it to v26.0 (the guide's samples use v27.0) and fills the length from the file:

```bash
FILE=welcome.jpg
curl -i -X POST "https://graph.facebook.com/v26.0/$APP_ID/uploads?file_name=$FILE&file_length=$(wc -c < "$FILE" | tr -d ' ')&file_type=image/jpeg&access_token=$USER_ACCESS_TOKEN"
```

The response is `{"id": "upload:<UPLOAD_SESSION_ID>"}`. Step two sends the bytes to that session, with the token in an `OAuth` header this time:

```bash
UPLOAD_SESSION="upload:UPLOAD_SESSION_ID"
curl -i -X POST "https://graph.facebook.com/v26.0/$UPLOAD_SESSION" \
  --header "Authorization: OAuth $USER_ACCESS_TOKEN" \
  --header "file_offset: 0" \
  --data-binary @"$FILE"
```

The response is `{"h": "<UPLOADED_FILE_HANDLE>"}`, for example `2:c2FtcGxl...`. That `h` value is the header handle. If the upload breaks, send a GET to the same session with the same header. The response gives `file_offset`, and you repeat the POST from there. Meta's published resume response is missing a comma after the `id` line, so don't paste it as a parser fixture.

Meta's template media page says the upload "returns a media ID" that you pass as `header_handle` ([template media, accessed 2026-11-04](https://developers.facebook.com/documentation/business-messaging/whatsapp/templates/template-media)). The upload guide returns a handle, and the handle has a different form from a `/media` ID. Follow the upload guide and the components page, which both call it a handle.

## Create the template with the handle

This create request is Meta's matched sample from the custom marketing templates page, moved from v23.0 to v26.0 ([custom marketing templates, accessed 2026-11-04](https://developers.facebook.com/documentation/business-messaging/whatsapp/templates/marketing-templates/custom-marketing-templates)). Replace `HEADER_ASSET_HANDLE` with the `h` value.

```bash
curl "https://graph.facebook.com/v26.0/$WABA_ID/message_templates" \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -d '{
  "name": "welcome_discount_template",
  "language": "en_US",
  "category": "marketing",
  "parameter_format": "named",
  "components": [
    {
      "type": "header",
      "format": "image",
      "example": {
        "header_handle": ["HEADER_ASSET_HANDLE"]
      }
    },
    {
      "type": "body",
      "text": "Welcome to Lucky Shrub, {{first_name}}!\n\nUse code *{{discount_code}}* to get {{discount_amount}} off of your first purchase!",
      "example": {
        "body_text_named_params": [
          { "param_name": "first_name", "example": "Pablo" },
          { "param_name": "discount_code", "example": "WELCOME20" },
          { "param_name": "discount_amount", "example": "20%" }
        ]
      }
    },
    {
      "type": "footer",
      "text": "Lucky Shrub: Your gateway to succulents!"
    },
    {
      "type": "buttons",
      "buttons": [
        { "type": "url", "text": "View deals", "url": "https://www.luckyshrub.com/deals" },
        { "type": "phone_number", "text": "Call us", "phone_number": "+15550051310" },
        { "type": "quick_reply", "text": "Unsubscribe" }
      ]
    }
  ]
}'
```

The response is `{"id": "1627019861106475", "status": "PENDING", "category": "MARKETING"}`. Review rules for samples are in [create a WhatsApp message template with the API](/academy/articles/whatsapp-create-message-template-api/).

For other media, change `format`. The components page lists `IMAGE`, `VIDEO`, `GIF` and `DOCUMENT`. GIF headers work only through the Marketing Messages API, and Meta says "Gifs are mp4 files with a max size of 3.5MB". Larger files display as video messages. The [template API reference](https://developers.facebook.com/documentation/business-messaging/whatsapp/reference/whatsapp-business-account/message-template-api) lists no GIF in its format enum, so the components page is the only source for it. The [Marketing Messages API post](/academy/articles/whatsapp-marketing-messages-api/) covers that route.

## Send with a media ID or a link

The send step takes a media `id`. Upload the file to your phone number's `/media` endpoint first. This is Meta's sample from the media page ([media, accessed 2026-11-04](https://developers.facebook.com/documentation/business-messaging/whatsapp/business-phone-numbers/media)), with its ID and token replaced by shell variables:

```bash
curl "https://graph.facebook.com/v26.0/$PHONE_NUMBER_ID/media" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -F 'messaging_product=whatsapp' \
  -F 'file=@/media/template_assets/black_friday_2025.mp4;type=video/mp4'
```

Meta's sample uploads a video. For the image template above, upload a JPEG or PNG with `type=image/jpeg`. The response is `{"id": "1037543291543636"}`. Media IDs from the API "expire after 30 days", so re-upload the file for a recurring template before 30 days pass. Details are in [the media upload API and media IDs](/academy/articles/whatsapp-media-upload-api-media-id/).

Then send the template. This is the send half of Meta's matched pair, at v26.0:

```bash
curl "https://graph.facebook.com/v26.0/$PHONE_NUMBER_ID/messages" \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -d '{
  "messaging_product": "whatsapp",
  "recipient_type": "individual",
  "to": "16505551234",
  "type": "template",
  "template": {
    "name": "welcome_discount_template",
    "language": { "code": "en_US" },
    "components": [
      {
        "type": "header",
        "parameters": [
          { "type": "image", "image": { "id": "1339522734477770" } }
        ]
      },
      {
        "type": "body",
        "parameters": [
          { "type": "text", "parameter_name": "first_name", "text": "Jessica" },
          { "type": "text", "parameter_name": "discount_code", "text": "WELCOME25" },
          { "type": "text", "parameter_name": "discount_amount", "text": "25%" }
        ]
      }
    ]
  }
}'
```

The response carries `messages[0].id` and `"message_status": "accepted"`. Accepted means the API took the request. Delivery shows up later in [status webhooks](/academy/articles/whatsapp-message-status-webhooks-sent-delivered-read-failed/).

To use a URL instead, the template media page swaps `id` for `link`. This is the header component, excerpted from its send sample:

```json
{
  "type": "header",
  "parameters": [
    { "type": "image", "image": { "link": "https://URL" } }
  ]
}
```

The file must sit on a publicly accessible server, or the message fails to send. Meta recommends that you "upload your media assets and use their IDs when sending messages". That page's response sample has trailing commas and no comma between `contacts` and `messages`. The cleaned shape is:

```json
{
  "messaging_product": "whatsapp",
  "contacts": [{ "input": "PHONE_NUMBER", "wa_id": "WHATSAPP_ID" }],
  "messages": [{ "id": "wamid.ID" }]
}
```

### Video and document headers

Meta publishes template samples only for image headers. The limited-time offer page writes the header parameter as `"type": "<HEADER_TYPE>", "<HEADER_TYPE>": {"id": "<HEADER_ASSET_ID>"}` ([limited-time offer templates, accessed 2026-11-04](https://developers.facebook.com/documentation/business-messaging/whatsapp/templates/marketing-templates/limited-time-offer-templates)). The two components below are inferred from that placeholder:

```json
{ "type": "header", "parameters": [{ "type": "video", "video": { "id": "MEDIA_ID" } }] }
```

```json
{ "type": "header", "parameters": [{ "type": "document", "document": { "id": "MEDIA_ID", "filename": "invoice-1042.pdf" } }] }
```

No template page documents `filename` on a document header. The field mirrors the document object in plain document messages, where it is the "Document filename, including extension" and drives the file icon ([document messages, accessed 2026-11-04](https://developers.facebook.com/documentation/business-messaging/whatsapp/messages/document-messages)). Send a test to your own phone before you depend on it.

Nothing in Meta's docs says whether the media you send must match the sample you uploaded at creation.

## Formats and size limits

Meta publishes no size table specific to template headers. The limits below are from the media page and apply to message media in general:

| Type | Formats | Max size |
| --- | --- | --- |
| Image | JPEG `image/jpeg`, PNG `image/png`, static WebP `image/webp` | 5 MB |
| Video | 3GPP `video/3gpp`, MP4 `video/mp4` | 16 MB |
| Document | txt, xls, xlsx, doc, docx, ppt, pptx, pdf | 100 MB |

The template side is narrower at creation. Resumable Upload accepts only pdf, jpeg, png and mp4, so a WebP or 3GPP file can't become a sample handle. By the same list, a document header's sample must be a PDF. Video must use H.264 and AAC, with one audio stream or none. Android clients don't support the H.264 "High" profile with B-frames, so encode "Main" without B-frames or "Baseline". Put the moov atom before mdat (`-movflags faststart`). The media page also rejects animated WebP and images over 4,096 pixels on an edge. The full list is in [supported media types and size limits](/academy/articles/whatsapp-media-messages-supported-types-size-limits/).

## Carousel cards

Carousel templates repeat the same pattern per card ([carousel templates, accessed 2026-11-04](https://developers.facebook.com/documentation/business-messaging/whatsapp/templates/marketing-templates/media-card-carousel-templates)). Each card takes an image or video header, never a document. Every card needs its own `header_handle` at creation, and Meta crops the media to a wide ratio. At send time, each card's header takes an `id` from `/media`. The page shows no `link` form for cards. The rest is in [carousel templates with media cards](/academy/articles/whatsapp-carousel-templates-media-cards/).

## If the send fails

Error 131053, "Unable to upload the media used in the message", points at the file. Read `error.error_data.details` in the failed message's webhook and confirm the media type is supported ([error codes, accessed 2026-11-04](https://developers.facebook.com/documentation/business-messaging/whatsapp/support/error-codes)). Error 131008 means "The request is missing a required parameter". On a media template, check first that the `header` component is in the send. Error 132012 means "Variable parameter values formatted incorrectly", so compare each parameter's `type` with the key that holds the media.

*Z-API Omni team*
