# Send an image (logo, product photo, poster) in a WhatsApp message

_Yes, with a template whose header is an IMAGE (JPEG or PNG): a sample at creation, the https URL of the real image on each send in header_image_url. A video header can be created but not sent._

Keywords: image, photo, logo, poster, flyer, product photo, image header, header image, header_image_url, header_image_base64, jpeg, png, webp, video, send an image, image in a template, banner

## Scenario

You want a notification message to open on an image: the shop logo, the photo of the ordered product, an event poster.

**Yes, through a template header.** Beyond the 24 h window, an image does not go out alone: it is the header of a template message. At creation you attach a sample image; on each send you give the **https address** of the image to show.

## Conversation

```text
You      : POST /v1/messages  to=+237690000001  variables=["Awa", "CMD-1042"]
           header_image_url=https://files.example.com/produits/robe-wax.jpg
Awa      : [ photo of the dress ]
           "Hello Awa, your order CMD-1042 is confirmed."
```

## Code

1. Create the template. `header_media_base64` is the sample image in base64 (`header_image_base64` is accepted too), `header_media_mime` its type:

```bash
# curl
curl -X POST "https://wa-api.geskap.com/v1/templates" \
  -H "Authorization: Bearer $GESKAP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "commande_confirmee_photo",
  "language": "fr",
  "category": "UTILITY",
  "body_text": "Bonjour {{1}}, votre commande {{2}} est confirmée.",
  "example_values": ["Awa", "CMD-1042"],
  "header_media_base64": "<VOTRE_IMAGE_D_EXEMPLE_EN_BASE64>",
  "header_media_mime": "image/jpeg"
}'
```

```js
// Node.js
const res = await fetch("https://wa-api.geskap.com/v1/templates", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.GESKAP_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "name": "commande_confirmee_photo",
    "language": "fr",
    "category": "UTILITY",
    "body_text": "Bonjour {{1}}, votre commande {{2}} est confirmée.",
    "example_values": ["Awa", "CMD-1042"],
    "header_media_base64": "<VOTRE_IMAGE_D_EXEMPLE_EN_BASE64>",
    "header_media_mime": "image/jpeg"
  }),
});
console.log(res.status, await res.json());
```

```php
// PHP
$ch = curl_init("https://wa-api.geskap.com/v1/templates");
curl_setopt_array($ch, [
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer " . getenv("GESKAP_API_KEY"),
    "Content-Type: application/json",
  ],
  CURLOPT_POSTFIELDS => json_encode([
    "name" => "commande_confirmee_photo",
    "language" => "fr",
    "category" => "UTILITY",
    "body_text" => "Bonjour {{1}}, votre commande {{2}} est confirmée.",
    "example_values" => ["Awa", "CMD-1042"],
    "header_media_base64" => "<VOTRE_IMAGE_D_EXEMPLE_EN_BASE64>",
    "header_media_mime" => "image/jpeg",
  ]),
]);
$res = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_HTTP_CODE), " ", $res;
```

```python
# Python
import os, requests

res = requests.request(
    "POST",
    "https://wa-api.geskap.com/v1/templates",
    headers={"Authorization": f"Bearer {os.environ['GESKAP_API_KEY']}"},
    json={
        "name": "commande_confirmee_photo",
        "language": "fr",
        "category": "UTILITY",
        "body_text": "Bonjour {{1}}, votre commande {{2}} est confirmée.",
        "example_values": ["Awa", "CMD-1042"],
        "header_media_base64": "<VOTRE_IMAGE_D_EXEMPLE_EN_BASE64>",
        "header_media_mime": "image/jpeg",
    },
    timeout=15,
)
print(res.status_code, res.json())
```

1. Once `APPROVED`, send it with the address of the image for **this** message:

```bash
# curl
curl -X POST "https://wa-api.geskap.com/v1/messages" \
  -H "Authorization: Bearer $GESKAP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "to": "+237690000001",
  "template": {
    "name": "commande_confirmee_photo",
    "language": "fr",
    "variables": ["Awa", "CMD-1042"],
    "header_image_url": "https://files.example.com/produits/robe-wax.jpg"
  },
  "idempotency_key": "photo-CMD-1042"
}'
```

```js
// Node.js
const res = await fetch("https://wa-api.geskap.com/v1/messages", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.GESKAP_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "to": "+237690000001",
    "template": {
      "name": "commande_confirmee_photo",
      "language": "fr",
      "variables": ["Awa", "CMD-1042"],
      "header_image_url": "https://files.example.com/produits/robe-wax.jpg"
    },
    "idempotency_key": "photo-CMD-1042"
  }),
});
console.log(res.status, await res.json());
```

```php
// PHP
$ch = curl_init("https://wa-api.geskap.com/v1/messages");
curl_setopt_array($ch, [
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer " . getenv("GESKAP_API_KEY"),
    "Content-Type: application/json",
  ],
  CURLOPT_POSTFIELDS => json_encode([
    "to" => "+237690000001",
    "template" => [
      "name" => "commande_confirmee_photo",
      "language" => "fr",
      "variables" => ["Awa", "CMD-1042"],
      "header_image_url" => "https://files.example.com/produits/robe-wax.jpg",
    ],
    "idempotency_key" => "photo-CMD-1042",
  ]),
]);
$res = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_HTTP_CODE), " ", $res;
```

```python
# Python
import os, requests

res = requests.request(
    "POST",
    "https://wa-api.geskap.com/v1/messages",
    headers={"Authorization": f"Bearer {os.environ['GESKAP_API_KEY']}"},
    json={
        "to": "+237690000001",
        "template": {
            "name": "commande_confirmee_photo",
            "language": "fr",
            "variables": ["Awa", "CMD-1042"],
            "header_image_url": "https://files.example.com/produits/robe-wax.jpg",
        },
        "idempotency_key": "photo-CMD-1042",
    },
    timeout=15,
)
print(res.status_code, res.json())
```

## Exact rules

| Item | Rule |
|---|---|
| Image types | JPEG (`image/jpeg`) and PNG (`image/png`) only |
| Sample size | 5 MB at most |
| Sending | `header_image_url`: a public `https` address (no `localhost`, no private address) |
| One header only | `header_image_url` **or** `header_document_url`, never both (`422`) |

> **Pitfall:** WebP is refused as a header (WhatsApp only accepts it for stickers): convert to PNG or JPEG before creating the template.

> **Pitfall:** the sample image is **not** what the customer sees. It lets Meta validate the layout. The image sent is the one at the URL you give on each send, which Meta fetches: it must be reachable from the Internet.

> **Limit:** a **video** header can be created (MP4 or 3GPP, 16 MB at most), but sending through the API has no video parameter: a template with a video header goes out without its video. To attach a file, use a [PDF header](https://console.geskap.com/docs/document-pdf-en-tete?lang=en); for a picture, this recipe.

> **Pitfall:** an image template that sells or follows up is category `MARKETING`: it answers `403` until marketing sends are enabled (see [Marketing and promo](https://console.geskap.com/docs/marketing-panier-promo?lang=en)). An order confirmation stays `UTILITY`.

The template is created once; only the URL changes from one send to the next. First send, statuses and errors: [Message a customer who never wrote to you](https://console.geskap.com/docs/ecrire-premier-message?lang=en). If Meta rejects the template: [Template rejected: the causes](https://console.geskap.com/docs/template-refuse-causes?lang=en).

_Proof — verified in the API source: api_schemas.py, api_send.py._

---

# Envoyer une image (logo, photo de produit, affiche) dans un message WhatsApp

_Oui, avec un template dont l'en-tête est une IMAGE (JPEG ou PNG) : un exemple à la création, l'URL https de la vraie image à chaque envoi dans header_image_url. Un en-tête vidéo se crée mais ne s'envoie pas._

Mots-clés: image, photo, logo, affiche, flyer, photo produit, en-tête image, header image, header_image_url, header_image_base64, jpeg, png, webp, vidéo, video, envoyer une image, image dans un template, bannière

## Scénario

Vous voulez qu'un message de notification s'ouvre sur une image : le logo de la boutique, la photo du produit commandé, l'affiche d'un événement.

**Oui, via l'en-tête d'un template.** Hors des 24 h, une image ne part pas seule : elle est l'en-tête d'un message à template. À la création vous joignez une image d'exemple ; à chaque envoi vous donnez l'**adresse https** de l'image à montrer.

## Conversation

```text
Vous    : POST /v1/messages  to=+237690000001  variables=["Awa", "CMD-1042"]
          header_image_url=https://files.example.com/produits/robe-wax.jpg
Awa     : [ photo de la robe ]
          « Bonjour Awa, votre commande CMD-1042 est confirmée. »
```

## Code

1. Créez le template. `header_media_base64` est l'image d'exemple en base64 (`header_image_base64` est accepté aussi), `header_media_mime` son type :

```bash
# curl
curl -X POST "https://wa-api.geskap.com/v1/templates" \
  -H "Authorization: Bearer $GESKAP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "commande_confirmee_photo",
  "language": "fr",
  "category": "UTILITY",
  "body_text": "Bonjour {{1}}, votre commande {{2}} est confirmée.",
  "example_values": ["Awa", "CMD-1042"],
  "header_media_base64": "<VOTRE_IMAGE_D_EXEMPLE_EN_BASE64>",
  "header_media_mime": "image/jpeg"
}'
```

```js
// Node.js
const res = await fetch("https://wa-api.geskap.com/v1/templates", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.GESKAP_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "name": "commande_confirmee_photo",
    "language": "fr",
    "category": "UTILITY",
    "body_text": "Bonjour {{1}}, votre commande {{2}} est confirmée.",
    "example_values": ["Awa", "CMD-1042"],
    "header_media_base64": "<VOTRE_IMAGE_D_EXEMPLE_EN_BASE64>",
    "header_media_mime": "image/jpeg"
  }),
});
console.log(res.status, await res.json());
```

```php
// PHP
$ch = curl_init("https://wa-api.geskap.com/v1/templates");
curl_setopt_array($ch, [
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer " . getenv("GESKAP_API_KEY"),
    "Content-Type: application/json",
  ],
  CURLOPT_POSTFIELDS => json_encode([
    "name" => "commande_confirmee_photo",
    "language" => "fr",
    "category" => "UTILITY",
    "body_text" => "Bonjour {{1}}, votre commande {{2}} est confirmée.",
    "example_values" => ["Awa", "CMD-1042"],
    "header_media_base64" => "<VOTRE_IMAGE_D_EXEMPLE_EN_BASE64>",
    "header_media_mime" => "image/jpeg",
  ]),
]);
$res = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_HTTP_CODE), " ", $res;
```

```python
# Python
import os, requests

res = requests.request(
    "POST",
    "https://wa-api.geskap.com/v1/templates",
    headers={"Authorization": f"Bearer {os.environ['GESKAP_API_KEY']}"},
    json={
        "name": "commande_confirmee_photo",
        "language": "fr",
        "category": "UTILITY",
        "body_text": "Bonjour {{1}}, votre commande {{2}} est confirmée.",
        "example_values": ["Awa", "CMD-1042"],
        "header_media_base64": "<VOTRE_IMAGE_D_EXEMPLE_EN_BASE64>",
        "header_media_mime": "image/jpeg",
    },
    timeout=15,
)
print(res.status_code, res.json())
```

1. Une fois `APPROVED`, envoyez-le avec l'adresse de l'image de **ce** message :

```bash
# curl
curl -X POST "https://wa-api.geskap.com/v1/messages" \
  -H "Authorization: Bearer $GESKAP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "to": "+237690000001",
  "template": {
    "name": "commande_confirmee_photo",
    "language": "fr",
    "variables": ["Awa", "CMD-1042"],
    "header_image_url": "https://files.example.com/produits/robe-wax.jpg"
  },
  "idempotency_key": "photo-CMD-1042"
}'
```

```js
// Node.js
const res = await fetch("https://wa-api.geskap.com/v1/messages", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.GESKAP_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "to": "+237690000001",
    "template": {
      "name": "commande_confirmee_photo",
      "language": "fr",
      "variables": ["Awa", "CMD-1042"],
      "header_image_url": "https://files.example.com/produits/robe-wax.jpg"
    },
    "idempotency_key": "photo-CMD-1042"
  }),
});
console.log(res.status, await res.json());
```

```php
// PHP
$ch = curl_init("https://wa-api.geskap.com/v1/messages");
curl_setopt_array($ch, [
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer " . getenv("GESKAP_API_KEY"),
    "Content-Type: application/json",
  ],
  CURLOPT_POSTFIELDS => json_encode([
    "to" => "+237690000001",
    "template" => [
      "name" => "commande_confirmee_photo",
      "language" => "fr",
      "variables" => ["Awa", "CMD-1042"],
      "header_image_url" => "https://files.example.com/produits/robe-wax.jpg",
    ],
    "idempotency_key" => "photo-CMD-1042",
  ]),
]);
$res = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_HTTP_CODE), " ", $res;
```

```python
# Python
import os, requests

res = requests.request(
    "POST",
    "https://wa-api.geskap.com/v1/messages",
    headers={"Authorization": f"Bearer {os.environ['GESKAP_API_KEY']}"},
    json={
        "to": "+237690000001",
        "template": {
            "name": "commande_confirmee_photo",
            "language": "fr",
            "variables": ["Awa", "CMD-1042"],
            "header_image_url": "https://files.example.com/produits/robe-wax.jpg",
        },
        "idempotency_key": "photo-CMD-1042",
    },
    timeout=15,
)
print(res.status_code, res.json())
```

## Règles exactes

| Élément | Règle |
|---|---|
| Types d'image | JPEG (`image/jpeg`) et PNG (`image/png`) seulement |
| Taille de l'exemple | 5 Mo au plus |
| Envoi | `header_image_url` : adresse `https` publique (pas de `localhost`, pas d'adresse privée) |
| Un seul en-tête | `header_image_url` **ou** `header_document_url`, jamais les deux (`422`) |

> **Piège :** le WebP est refusé en en-tête (WhatsApp ne l'accepte que pour les autocollants) : convertissez en PNG ou JPEG avant de créer le template.

> **Piège :** l'image d'exemple n'est **pas** celle que le client voit. Elle sert à Meta pour valider le gabarit. L'image envoyée est celle de l'URL que vous donnez à chaque envoi, que Meta va chercher : elle doit être joignable depuis Internet.

> **Limite :** un en-tête **vidéo** peut être créé (MP4 ou 3GPP, 16 Mo au plus), mais l'envoi par l'API n'a pas de paramètre vidéo : un template à en-tête vidéo part sans sa vidéo. Pour un fichier à joindre, utilisez un [PDF en en-tête](https://console.geskap.com/docs/document-pdf-en-tete) ; pour une image, ce modèle.

> **Piège :** un template à image qui vend ou relance est de catégorie `MARKETING` : il répond `403` tant que l'envoi marketing n'est pas activé (voir [Marketing et promo](https://console.geskap.com/docs/marketing-panier-promo)). Une confirmation de commande reste `UTILITY`.

Le template se crée une fois ; seule l'URL change d'un envoi à l'autre. Premier envoi, statuts et erreurs : [Écrire à un client qui ne vous a jamais écrit](https://console.geskap.com/docs/ecrire-premier-message). Si Meta refuse le template : [Template refusé : les causes](https://console.geskap.com/docs/template-refuse-causes).

_Preuve — vérifié dans le code de l'API : api_schemas.py, api_send.py._

Support: WhatsApp +237 6 56 09 88 31 · All recipes: https://wa-api.geskap.com/llms.txt
