> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kapso.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Media header

> Create and send templates with image, video, or document headers

## Create

<CodeGroup>
  ```typescript Create template - TypeScript SDK icon="square-js" theme={null}
  import { WhatsAppClient } from '@kapso/whatsapp-cloud-api';

  const client = new WhatsAppClient({
    baseUrl: 'https://api.kapso.ai/meta/whatsapp',
    kapsoApiKey: process.env.KAPSO_API_KEY!
  });

  await client.templates.create({
    businessAccountId: '123456789',
    name: 'limited_time_offer',
    category: 'MARKETING',
    language: 'en_US',
    parameterFormat: 'NAMED',
    components: [
      {
        type: 'HEADER',
        format: 'IMAGE',
        example: {
          header_handle: ['4::aW1hZ2UvanBlZw==:ARa1ZDhwbLZM3EENeeg']
        }
      },
      {
        type: 'BODY',
        text: 'Exclusive offer for {{customer_name}}! Get {{discount_amount}} off with code {{discount_code}}.',
        example: {
          body_text_named_params: [
            { param_name: 'customer_name', example: 'Mark' },
            { param_name: 'discount_amount', example: '25%' },
            { param_name: 'discount_code', example: 'SUMMER25' }
          ]
        }
      }
    ]
  });
  ```

  ```bash Create template - REST API icon="code" theme={null}
  curl -X POST 'https://api.kapso.ai/meta/whatsapp/v24.0/123456789/message_templates' \
    -H 'X-API-Key: YOUR_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
      "name": "limited_time_offer",
      "category": "MARKETING",
      "language": "en_US",
      "parameter_format": "NAMED",
      "components": [
        {
          "type": "HEADER",
          "format": "IMAGE",
          "example": {
            "header_handle": ["4::aW1hZ2UvanBlZw==:ARa1ZDhwbLZM3EENeeg"]
          }
        },
        {
          "type": "BODY",
          "text": "Exclusive offer for {{customer_name}}! Get {{discount_amount}} off with code {{discount_code}}.",
          "example": {
            "body_text_named_params": [
              { "param_name": "customer_name", "example": "Mark" },
              { "param_name": "discount_amount", "example": "25%" },
              { "param_name": "discount_code", "example": "SUMMER25" }
            ]
          }
        }
      ]
    }'
  ```
</CodeGroup>

## Send

<CodeGroup>
  ```typescript Send template - TypeScript SDK icon="square-js" theme={null}
  import { WhatsAppClient } from '@kapso/whatsapp-cloud-api';

  const client = new WhatsAppClient({
    baseUrl: 'https://api.kapso.ai/meta/whatsapp',
    kapsoApiKey: process.env.KAPSO_API_KEY!
  });

  await client.messages.sendTemplate({
    phoneNumberId: '647015955153740',
    to: '15551234567',
    template: {
      name: 'limited_time_offer',
      language: { code: 'en_US' },
      components: [
        {
          type: 'header',
          parameters: [
            {
              type: 'image',
              image: {
                link: 'https://example.com/summer-sale.jpg'
              }
            }
          ]
        },
        {
          type: 'body',
          parameters: [
            { type: 'text', parameterName: 'customer_name', text: 'Mark' },
            { type: 'text', parameterName: 'discount_amount', text: '25%' },
            { type: 'text', parameterName: 'discount_code', text: 'SUMMER25' }
          ]
        }
      ]
    }
  });
  ```

  ```bash Send template - REST API icon="code" theme={null}
  curl -X POST 'https://api.kapso.ai/meta/whatsapp/v24.0/647015955153740/messages' \
    -H 'X-API-Key: YOUR_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
      "messaging_product": "whatsapp",
      "to": "15551234567",
      "type": "template",
      "template": {
        "name": "limited_time_offer",
        "language": {
          "code": "en_US"
        },
        "components": [
          {
            "type": "header",
            "parameters": [
              {
                "type": "image",
                "image": {
                  "link": "https://example.com/summer-sale.jpg"
                }
              }
            ]
          },
          {
            "type": "body",
            "parameters": [
              { "type": "text", "parameter_name": "customer_name", "text": "Mark" },
              { "type": "text", "parameter_name": "discount_amount", "text": "25%" },
              { "type": "text", "parameter_name": "discount_code", "text": "SUMMER25" }
            ]
          }
        ]
      }
    }'
  ```
</CodeGroup>
