> ## 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 un message

> Envoi de texte ou média via requête POST.



## OpenAPI

````yaml /api/openapi.yaml post /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:
  /send:
    post:
      tags:
        - Messages
      summary: Envoyer un message
      description: Envoyer un message texte ou média via requête POST.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                number:
                  type: string
                  description: Numéro WhatsApp du destinataire
                type:
                  type: string
                  enum:
                    - text
                    - media
                message:
                  type: string
                media_url:
                  type: string
                  format: uri
                filename:
                  type: string
                instance_id:
                  type: string
                access_token:
                  type: string
              required:
                - number
                - type
                - instance_id
            examples:
              text:
                value:
                  number: 2299775xxxx
                  type: text
                  message: test message
                  instance_id: 609ACF283XXXX
                  access_token: 646116c7XXXX
              media:
                value:
                  number: 84933313xxx
                  type: media
                  message: test message
                  media_url: https://i.pravatar.cc
                  filename: file_test.jpg
                  instance_id: 609ACF283XXXX
                  access_token: 646116c7XXXX
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                  message_id:
                    type: string
                  message:
                    type: string
              examples:
                default:
                  value:
                    status: 200
                    message_id: MSG-112233
                    message: Message envoyé
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      x-codeSamples:
        - lang: curl
          label: cURL
          source: |
            curl -X POST 'https://api.wachap.com/v1/send' \
              -H 'Content-Type: application/json' \
              -d '{
                "number": "2299775xxxx",
                "type": "text",
                "message": "Hello from cURL",
                "instance_id": "609ACF283XXXX",
                "access_token": "646116c7XXXX"
              }'
        - lang: javascript
          label: JavaScript
          source: |
            const res = await fetch('https://api.wachap.com/v1/send', {
              method: 'POST',
              headers: { 'Content-Type': 'application/json' },
              body: JSON.stringify({
                number: '2299775xxxx',
                type: 'text',
                message: 'Hello from JS',
                instance_id: '609ACF283XXXX',
                access_token: '646116c7XXXX'
              })
            });
            const data = await res.json();
            console.log(data);
        - lang: python
          label: Python
          source: |
            import requests
            payload = {
              'number': '2299775xxxx',
              'type': 'text',
              'message': 'Hello from Python',
              'instance_id': '609ACF283XXXX',
              'access_token': '646116c7XXXX'
            }
            r = requests.post('https://api.wachap.com/v1/send', json=payload)
            print(r.json())
        - lang: php
          label: PHP
          source: >
            <?php

            $payload = [
              'number' => '2299775xxxx',
              'type' => 'text',
              'message' => 'Hello from PHP',
              'instance_id' => '609ACF283XXXX',
              'access_token' => '646116c7XXXX'
            ];

            $ch = curl_init('https://api.wachap.com/v1/send');

            curl_setopt($ch, CURLOPT_POST, true);

            curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type:
            application/json']);

            curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));

            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

            $response = curl_exec($ch);

            curl_close($ch);

            echo $response;

            ?>
        - lang: go
          label: Go
          source: |
            package main
            import (
              "bytes"
              "encoding/json"
              "fmt"
              "net/http"
              "io/ioutil"
            )
            func main() {
              payload := map[string]string{
                "number": "2299775xxxx",
                "type": "text",
                "message": "Hello from Go",
                "instance_id": "609ACF283XXXX",
                "access_token": "646116c7XXXX",
              }
              b, _ := json.Marshal(payload)
              resp, err := http.Post("https://api.wachap.com/v1/send", "application/json", bytes.NewBuffer(b))
              if err != nil { panic(err) }
              defer resp.Body.Close()
              body, _ := ioutil.ReadAll(resp.Body)
              fmt.Println(string(body))
            }
        - lang: jsx
          label: React
          source: |
            async function sendMessage() {
              const payload = {
                number: '2299775xxxx',
                type: 'text',
                message: 'Hello from React',
                instance_id: '609ACF283XXXX',
                access_token: '646116c7XXXX',
              };
              const res = await fetch('https://api.wachap.com/v1/send', {
                method: 'POST',
                headers: { 'Content-Type': 'application/json' },
                body: JSON.stringify(payload),
              });
              console.log(await res.json());
            }
        - lang: typescript
          label: Next.js
          source: |
            // app/api/send/route.js
            export async function POST() {
              const payload = {
                number: '2299775xxxx',
                type: 'text',
                message: 'Hello from Next.js',
                instance_id: '609ACF283XXXX',
                access_token: '646116c7XXXX',
              };
              const res = await fetch('https://api.wachap.com/v1/send', {
                method: 'POST',
                headers: { 'Content-Type': 'application/json' },
                body: JSON.stringify(payload),
              });
              return new Response(await res.text(), { status: res.status });
            }
components:
  schemas:
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: Message d’erreur
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````