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

# Envoyer une image

> Envoyez une image via URL à un contact WhatsApp

### Endpoint

<ParamField method="POST" path="/v1/whatsapp/messages/send" />

### Headers

<ParamField header="Authorization" type="string" required>
  Bearer token avec votre Secret Key (format: `Bearer sk_...`)
</ParamField>

### Body Parameters

<ParamField body="data.accountId" type="string" required>
  ID du compte WhatsApp
</ParamField>

<ParamField body="data.to" type="string" required>
  Numéro destinataire
</ParamField>

<ParamField body="data.type" type="string" required>
  Doit être "image"
</ParamField>

<ParamField body="data.imageUrl" type="string" required>
  URL publique de l'image
</ParamField>

<ParamField body="data.caption" type="string">
  Légende de l'image
</ParamField>

<ParamField body="data.buttons" type="array">
  Jusqu’à trois boutons interactifs. Une `caption` non vide est requise lorsque des boutons sont présents.
</ParamField>

<ParamField body="data.footerText" type="string">
  Pied affiché sous les boutons, limité à 60 caractères.
</ParamField>

### Formats supportés

* JPG / JPEG
* PNG
* GIF
* WebP

**Taille maximum** : 10 MB

### Exemples de requêtes

<CodeGroup>
  ```bash BASH theme={null}
  curl -X POST https://api.wachap.com/v1/whatsapp/messages/send \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer token" \
    -d '{
    "data": {
      "accountId": "account_123",
      "to": "+33612345678",
      "type": "image",
      "imageUrl": "https://example.com/image.jpg",
      "caption": "Souhaitez-vous voir les détails ?",
      "buttons": [
        {"id": "details", "text": "Voir les détails", "type": "url", "url": "https://wachap.com/details"}
      ],
      "footerText": "WaChap",
      "isCampaign": false
    }
  }
  '
  ```

  ```javascript JAVASCRIPT theme={null}
  const response = await fetch('https://api.wachap.com/v1/whatsapp/messages/send', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer token',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      data: {
        accountId: 'account_123',
        to: '+33612345678',
        type: 'image',
        imageUrl: 'https://picsum.photos/800/600',
        caption: 'Voici une image 📸'
      }
    })
  });

  const data = await response.json();
  console.log(data);
  ```

  ```python PYTHON theme={null}
  import requests

  url = "https://api.wachap.com/v1/whatsapp/messages/send"
  headers = {
      "Authorization": "Bearer token",
      "Content-Type": "application/json"
  }
  payload = {
      "data": {
          "accountId": "account_123",
          "to": "+33612345678",
          "type": "image",
          "imageUrl": "https://picsum.photos/800/600",
          "caption": "Voici une image 📸"
      }
  }

  response = requests.post(url, json=payload, headers=headers)
  print(response.json())
  ```

  ```php PHP theme={null}
  <?php
  $curl = curl_init();

  $payload = [
      "data" => [
          "accountId" => "account_123",
          "to" => "+33612345678",
          "type" => "image",
          "imageUrl" => "https://picsum.photos/800/600",
          "caption" => "Voici une image 📸"
      ]
  ];

  curl_setopt_array($curl, [
    CURLOPT_URL => "https://api.wachap.com/v1/whatsapp/messages/send",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => json_encode($payload),
    CURLOPT_HTTPHEADER => [
      "Authorization: Bearer token",
      "Content-Type: application/json"
    ],
  ]);

  $response = curl_exec($curl);
  curl_close($curl);
  echo $response;
  ?>
  ```
</CodeGroup>

Consultez [Boutons interactifs](/fr/messages/interactive-buttons) pour les types `reply`, `url` et `call`, ainsi que leurs limites.


## OpenAPI

````yaml POST /whatsapp/messages/send
openapi: 3.0.3
info:
  title: WaChap API
  version: 2.0.0
servers:
  - url: https://api.wachap.com/v1
    description: WaChap API server
security:
  - BearerAuth: []
tags:
  - name: Instances
    description: Créer et gérer des instances WhatsApp
  - name: Webhook
    description: Configuration des webhooks de réception
  - name: Messages
    description: Envoyer des messages WhatsApp
  - name: Comptes
    description: Gérer vos comptes WhatsApp connectés
  - name: SMS
    description: Service SMS de WaChap (V4) via FCM
  - name: Étiquettes WhatsApp
    description: Créer et associer des étiquettes aux conversations WhatsApp
paths:
  /whatsapp/messages/send:
    post:
      tags:
        - Messages
      summary: Envoyer un message
      description: >-
        Envoyer un message (Texte, Image, Audio, Vidéo, Document, Location,
        Contact).
      operationId: sendWhatsAppMessage
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - data
              properties:
                data:
                  type: object
                  required:
                    - accountId
                    - to
                    - type
                  properties:
                    accountId:
                      type: string
                    to:
                      type: string
                    type:
                      type: string
                      enum:
                        - text
                        - image
                        - audio
                        - video
                        - document
                        - location
                        - contact
                    content:
                      type: string
                    imageUrl:
                      type: string
                    audioUrl:
                      type: string
                    videoUrl:
                      type: string
                    documentUrl:
                      type: string
                    filename:
                      type: string
                    caption:
                      type: string
                    buttons:
                      type: array
                      minItems: 1
                      maxItems: 3
                      description: Boutons disponibles pour text, image, video et document.
                      items:
                        $ref: '#/components/schemas/InteractiveButton'
                    footerText:
                      type: string
                      maxLength: 60
                      description: >-
                        Pied facultatif, utilisé uniquement lorsque buttons est
                        non vide.
                    latitude:
                      type: number
                    longitude:
                      type: number
                    name:
                      type: string
                    address:
                      type: string
                    contact:
                      type: object
                      properties:
                        fullName:
                          type: string
                        phoneNumber:
                          type: string
                        organization:
                          type: string
            examples:
              text:
                summary: Message texte
                value:
                  data:
                    accountId: a1233b-a1233b-a1233b-a1233b-a1233bcdjdg9878
                    to: '+33612345678'
                    type: text
                    content: Souhaitez-vous confirmer ?
                    buttons:
                      - id: 'yes'
                        text: Oui
                        type: reply
                      - id: website
                        text: Voir le site
                        type: url
                        url: https://wachap.com
                    footerText: WaChap
              image:
                summary: Message image
                value:
                  data:
                    accountId: a1233b-a1233b-a1233b-a1233b-a1233bcdjdg9878
                    to: '+33612345678'
                    type: image
                    imageUrl: https://example.com/image.jpg
                    caption: Regardez cette image !
                    buttons:
                      - id: details
                        text: Voir les détails
                        type: url
                        url: https://wachap.com/details
              video:
                summary: Message vidéo
                value:
                  data:
                    accountId: a1233b-a1233b-a1233b-a1233b-a1233bcdjdg9878
                    to: '+33612345678'
                    type: video
                    videoUrl: https://example.com/video.mp4
                    caption: Ma vidéo
              audio:
                summary: Message audio
                value:
                  data:
                    accountId: a1233b-a1233b-a1233b-a1233b-a1233bcdjdg9878
                    to: '+33612345678'
                    type: audio
                    audioUrl: https://example.com/audio.mp3
              document:
                summary: Message document
                value:
                  data:
                    accountId: a1233b-a1233b-a1233b-a1233b-a1233bcdjdg9878
                    to: '+33612345678'
                    type: document
                    documentUrl: https://example.com/document.pdf
                    filename: contrat.pdf
                    caption: Consultez le contrat
                    buttons:
                      - id: received
                        text: Bien reçu
                        type: reply
              location:
                summary: Message localisation
                value:
                  data:
                    accountId: a1233b-a1233b-a1233b-a1233b-a1233bcdjdg9878
                    to: '+33612345678'
                    type: location
                    latitude: 48.8566
                    longitude: 2.3522
                    name: Tour Eiffel
                    address: Champ de Mars, Paris
              contact:
                summary: Message contact
                value:
                  data:
                    accountId: a1233b-a1233b-a1233b-a1233b-a1233bcdjdg9878
                    to: '+33612345678'
                    type: contact
                    contact:
                      fullName: Jean Dupont
                      phoneNumber: '+33612345678'
                      organization: WaChap Inc
      responses:
        '200':
          description: OK
        '400':
          description: Bad Request
components:
  schemas:
    InteractiveButton:
      type: object
      required:
        - text
      properties:
        id:
          type: string
          description: >-
            Identifiant unique du bouton dans le message. Généré automatiquement
            s’il est omis.
        text:
          type: string
          minLength: 1
          maxLength: 20
          description: Libellé affiché dans WhatsApp.
        type:
          type: string
          enum:
            - reply
            - url
            - call
          default: reply
        url:
          type: string
          format: uri
          pattern: ^https?://
          description: URL HTTP(S) requise pour un bouton de type url.
        phoneNumber:
          type: string
          pattern: ^\+?[1-9][0-9]{5,14}$
          description: Numéro international requis pour un bouton de type call.
      example:
        id: confirm
        text: Confirmer
        type: reply
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````