Skip to content

Template media headers

When creating or editing a template with a media header (IMAGE, VIDEO, GIF, DOCUMENT), you have four mutually exclusive modes to provide the media. They apply only to non-TEXT headers.

The four modes

ModeDescriptionUse case
urlPublic https URL of the mediaThe file is already hosted
base64Media base64-encoded in the bodyYou have the file bytes
handlerExisting Meta handler (4::...)You already uploaded the media before
fileMultipart with a binary file partDirect upload from the client
header_source and header_handle are mutually exclusive. If you send both, the API returns 400 with header_source and header_handle are mutually exclusive for media headers.

url mode

{
  "name": "test_img",
  "language": "es",
  "category": "MARKETING",
  "components": [
    {
      "type": "HEADER",
      "format": "IMAGE",
      "example": {
        "header_source": {
          "mode": "url",
          "value": "https://cdn.example.com/banner.jpg"
        }
      }
    },
    {
      "type": "BODY",
      "text": "Check out our new collection {{1}}.",
      "example": { "body_text": [["Spring"]] }
    }
  ]
}

base64 mode

{
  "type": "HEADER",
  "format": "IMAGE",
  "example": {
    "header_source": {
      "mode": "base64",
      "value": "/9j/4AAQSkZJRgABAQAAAQABAAD/..."
    }
  }
}

handler mode

{
  "type": "HEADER",
  "format": "IMAGE",
  "example": {
    "header_source": {
      "mode": "handler",
      "value": "4::1234567890"
    }
  }
}

file mode (multipart)

The request must be multipart/form-data with two parts: template (JSON) and file (binary):

curl --request POST \
  --url 'https://api.chattigo.com/v1/templates/{did}' \
  --header 'Authorization: Bearer <token>' \
  -F 'template={
    "name": "test_img",
    "language": "es",
    "category": "MARKETING",
    "components": [{
      "type": "HEADER",
      "format": "IMAGE",
      "example": { "header_source": { "mode": "file" } }
    }]
  };type=application/json' \
  -F 'file=@/path/banner.jpg'

Validation rules

RuleDetail
HTTPS requiredmode=url with http://400
No private IPsmode=url pointing to a private/loopback IP → 400 (blocked for security)
Size limitsEach category has a configurable cap (media.upload.max_bytes)
TEXT header ignores header_sourceIf the header is TEXT, header_source is ignored
file requires multipartmode=file with application/json400
Missing partsMultipart without template or without file part → 400
Multipart bombfile part exceeding the cap → 413
GIFMarketing Messages API only, MP4, max 3.5MB

Media categories and sizes

FormatMax sizeMIME
IMAGEper category (configurable)image/*
VIDEOper category (configurable)video/*
DOCUMENTper category (configurable)application/*
GIF3.5MBvideo/mp4 (Marketing Messages API)