> ## 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.

# Configurer le webhook

> Définit l’URL et l’état du webhook de réception.



## OpenAPI

````yaml /api/openapi.yaml get /set_webhook
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:
  /set_webhook:
    get:
      tags:
        - Webhook
      summary: Configurer le webhook de réception
      description: Définir l’URL du webhook pour recevoir les événements.
      parameters:
        - name: webhook_url
          in: query
          required: true
          schema:
            type: string
            format: uri
          description: URL du webhook
        - name: enable
          in: query
          required: true
          schema:
            type: boolean
          description: Activer ou désactiver le webhook
        - name: instance_id
          in: query
          required: true
          schema:
            type: string
          description: Identifiant de l'instance
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                  success:
                    type: boolean
                  message:
                    type: string
              examples:
                default:
                  value:
                    status: 200
                    success: true
                    message: Webhook configuré
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      x-codeSamples:
        - lang: curl
          label: cURL
          source: >
            curl
            "https://api.wachap.com/v1/set_webhook?webhook_url=https%3A%2F%2Fexample.com%2Fwachap&enable=true&instance_id=609ACF283XXXX&access_token=646116c7XXXX"
        - lang: javascript
          label: JavaScript
          source: >
            const params = new URLSearchParams({
              webhook_url: 'https://example.com/wachap',
              enable: 'true',
              instance_id: '609ACF283XXXX',
              access_token: '646116c7XXXX',
            });

            const res = await
            fetch(`https://api.wachap.com/v1/set_webhook?${params}`);

            const data = await res.json();

            console.log(data);
        - lang: python
          label: Python
          source: >
            import requests

            params = {
              'webhook_url': 'https://example.com/wachap',
              'enable': 'true',
              'instance_id': '609ACF283XXXX',
              'access_token': '646116c7XXXX'
            }

            r = requests.get('https://api.wachap.com/v1/set_webhook',
            params=params)

            print(r.json())
        - lang: php
          label: PHP
          source: |
            <?php
            $params = http_build_query([
              'webhook_url' => 'https://example.com/wachap',
              'enable' => 'true',
              'instance_id' => '609ACF283XXXX',
              'access_token' => '646116c7XXXX'
            ]);
            $url = 'https://api.wachap.com/v1/set_webhook?' . $params;
            $ch = curl_init($url);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $response = curl_exec($ch);
            curl_close($ch);
            echo $response;
            ?>
        - lang: go
          label: Go
          source: |
            package main
            import (
              "fmt"
              "net/http"
              "net/url"
              "io/ioutil"
            )
            func main() {
              params := url.Values{}
              params.Add("webhook_url", "https://example.com/wachap")
              params.Add("enable", "true")
              params.Add("instance_id", "609ACF283XXXX")
              params.Add("access_token", "646116c7XXXX")
              resp, err := http.Get("https://api.wachap.com/v1/set_webhook?" + params.Encode())
              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 setWebhook() {
              const params = new URLSearchParams({
                webhook_url: 'https://example.com/wachap',
                enable: 'true',
                instance_id: '609ACF283XXXX',
                access_token: '646116c7XXXX',
              });
              const res = await fetch(`https://api.wachap.com/v1/set_webhook?${params}`);
              console.log(await res.json());
            }
        - lang: typescript
          label: Next.js
          source: |
            // app/api/set-webhook/route.js
            export async function GET() {
              const params = new URLSearchParams({
                webhook_url: 'https://example.com/wachap',
                enable: 'true',
                instance_id: '609ACF283XXXX',
                access_token: '646116c7XXXX',
              });
              const res = await fetch(`https://api.wachap.com/v1/set_webhook?${params}`);
              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

````