{
 "openapi": "3.1.0",
 "info": {
  "title": "API de messagerie Warilo",
  "version": "1.0.0",
  "description": "Envoyez des SMS et des messages WhatsApp avec une seule API, avec bascule automatique vers le SMS, codes à usage unique et webhooks signés.",
  "x-en": "Send SMS and WhatsApp messages with a single API, with automatic SMS fallback, one-time codes and signed webhooks.",
  "contact": {
   "name": "Warilo",
   "email": "contact@warilo.com",
   "url": "https://warilo.com/developpeurs.html"
  }
 },
 "servers": [
  {
   "url": "https://api.warilo.com",
   "description": "Production et test (selon la clé utilisée)"
  }
 ],
 "security": [
  {
   "bearer": []
  }
 ],
 "tags": [
  {
   "name": "Messages",
   "description": "Envoi et suivi des SMS et messages WhatsApp.",
   "x-en": "Sending and tracking SMS and WhatsApp messages."
  },
  {
   "name": "OTP",
   "description": "Codes de vérification à usage unique.",
   "x-en": "One-time verification codes."
  },
  {
   "name": "WhatsApp",
   "description": "Modèles de messages WhatsApp.",
   "x-en": "WhatsApp message templates."
  },
  {
   "name": "Webhooks",
   "description": "Notifications envoyées à votre application.",
   "x-en": "Notifications sent to your application."
  },
  {
   "name": "Compte",
   "description": "Solde et état du service.",
   "x-en": "Balance and service status."
  },
  {
   "name": "Sandbox",
   "description": "Outils réservés aux clés de test.",
   "x-en": "Tools for test keys only."
  }
 ],
 "paths": {
  "/v1/messages": {
   "post": {
    "tags": [
     "Messages"
    ],
    "operationId": "sendMessage",
    "summary": "Envoyer un message",
    "x-en-summary": "Send a message",
    "description": "Crée un message et le met en file d'envoi. La réponse arrive avant la remise : suivez le statut avec GET /v1/messages/{id} ou par webhook. Avec channel auto, le message part sur WhatsApp et bascule en SMS (fallback_text) si le destinataire n'utilise pas WhatsApp ou ne l'a pas reçu.",
    "x-en": "Creates a message and queues it for sending. The response arrives before delivery: track the status with GET /v1/messages/{id} or by webhook. With channel auto, the message goes out on WhatsApp and falls back to SMS (fallback_text) if the recipient does not use WhatsApp or did not receive it.",
    "parameters": [
     {
      "$ref": "#/components/parameters/IdempotencyKey"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/NewMessage"
       },
       "examples": {
        "sms": {
         "summary": "SMS",
         "value": {
          "channel": "sms",
          "to": "+237673713115",
          "from": "WARILO",
          "text": "Votre commande C-1042 est prête.",
          "reference": "commande-1042"
         }
        },
        "whatsapp_template": {
         "summary": "Modèle WhatsApp",
         "value": {
          "channel": "whatsapp",
          "to": "+237673713115",
          "template": {
           "name": "suivi_commande",
           "language": "fr",
           "variables": [
            "Awa",
            "C-1042"
           ]
          }
         }
        },
        "auto": {
         "summary": "WhatsApp avec bascule SMS",
         "value": {
          "channel": "auto",
          "to": "+237673713115",
          "template": {
           "name": "suivi_commande",
           "language": "fr",
           "variables": [
            "Awa",
            "C-1042"
           ]
          },
          "fallback_text": "Bonjour Awa, votre commande C-1042 est en route."
         }
        }
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "Message créé et mis en file",
      "x-en": "Message created and queued",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Message"
        }
       }
      }
     },
     "200": {
      "description": "Même clé d'idempotence : le message déjà créé est renvoyé",
      "x-en": "Same idempotency key: the message already created is returned",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Message"
        }
       }
      }
     },
     "402": {
      "$ref": "#/components/responses/Error"
     },
     "422": {
      "$ref": "#/components/responses/Error"
     },
     "429": {
      "$ref": "#/components/responses/Error"
     }
    }
   },
   "get": {
    "tags": [
     "Messages"
    ],
    "operationId": "listMessages",
    "summary": "Lister les messages",
    "x-en-summary": "List messages",
    "description": "Messages du plus récent au plus ancien. Paginez avec starting_after (identifiant du dernier message reçu).",
    "x-en": "Messages from newest to oldest. Paginate with starting_after (ID of the last message received).",
    "parameters": [
     {
      "name": "limit",
      "in": "query",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 100,
       "default": 20
      },
      "description": "Nombre de messages (1 à 100)",
      "x-en": "Number of messages (1 to 100)"
     },
     {
      "name": "starting_after",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Identifiant à partir duquel continuer",
      "x-en": "ID to continue from"
     },
     {
      "name": "status",
      "in": "query",
      "schema": {
       "$ref": "#/components/schemas/Status"
      },
      "description": "Filtrer par statut",
      "x-en": "Filter by status"
     },
     {
      "name": "channel",
      "in": "query",
      "schema": {
       "type": "string",
       "enum": [
        "sms",
        "whatsapp"
       ]
      },
      "description": "Filtrer par canal",
      "x-en": "Filter by channel"
     },
     {
      "name": "to",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Filtrer par destinataire (E.164)",
      "x-en": "Filter by recipient (E.164)"
     },
     {
      "name": "reference",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Filtrer par votre référence",
      "x-en": "Filter by your reference"
     }
    ],
    "responses": {
     "200": {
      "description": "Liste paginée",
      "x-en": "Paginated list",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/MessageList"
        }
       }
      }
     }
    }
   }
  },
  "/v1/messages/batch": {
   "post": {
    "tags": [
     "Messages"
    ],
    "operationId": "sendBatch",
    "summary": "Envoyer un lot de messages",
    "x-en-summary": "Send a batch of messages",
    "description": "Jusqu'à 100 messages par appel. Chaque message est validé séparément : la réponse (207) indique, pour chacun, le message créé ou l'erreur.",
    "x-en": "Up to 100 messages per call. Each message is validated separately: the response (207) gives, for each one, the created message or the error.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "messages"
        ],
        "properties": {
         "messages": {
          "type": "array",
          "maxItems": 100,
          "items": {
           "$ref": "#/components/schemas/NewMessage"
          }
         }
        }
       },
       "example": {
        "messages": [
         {
          "to": "+237673713115",
          "text": "Rappel : réunion demain à 9 h."
         },
         {
          "to": "+22676138952",
          "text": "Rappel : réunion demain à 9 h."
         }
        ]
       }
      }
     }
    },
    "responses": {
     "207": {
      "description": "Résultat message par message",
      "x-en": "Result for each message",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "results": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "index": {
              "type": "integer"
             },
             "message": {
              "$ref": "#/components/schemas/Message"
             },
             "error": {
              "$ref": "#/components/schemas/ErrorBody"
             }
            }
           }
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/v1/messages/{id}": {
   "get": {
    "tags": [
     "Messages"
    ],
    "operationId": "getMessage",
    "summary": "Consulter un message",
    "x-en-summary": "Retrieve a message",
    "description": "Statut à jour, erreur éventuelle et, en cas de bascule, l'identifiant du SMS de secours (fallback_id).",
    "x-en": "Current status, any error and, after a fallback, the ID of the backup SMS (fallback_id).",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "example": "msg_3f2a9c0d1e4b5a6f7c8d"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Le message",
      "x-en": "The message",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Message"
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/v1/otp": {
   "post": {
    "tags": [
     "OTP"
    ],
    "operationId": "sendOtp",
    "summary": "Envoyer un code de vérification",
    "x-en-summary": "Send a verification code",
    "description": "Génère un code, l'envoie par SMS ou WhatsApp (modèle d'authentification) et le conserve sous forme d'empreinte uniquement. Avec une clé de test, la réponse contient le code pour automatiser vos tests. Cinq codes au plus par numéro et par dix minutes.",
    "x-en": "Generates a code, sends it by SMS or WhatsApp (authentication template) and only stores its hash. With a test key, the response includes the code so you can automate your tests. At most five codes per number every ten minutes.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/NewOtp"
       },
       "example": {
        "to": "+237673713115",
        "channel": "sms",
        "brand": "MaBanque",
        "length": 6,
        "ttl": 300
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "Code envoyé",
      "x-en": "Code sent",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Otp"
        }
       }
      }
     },
     "422": {
      "$ref": "#/components/responses/Error"
     },
     "429": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/v1/otp/{id}/verify": {
   "post": {
    "tags": [
     "OTP"
    ],
    "operationId": "verifyOtp",
    "summary": "Vérifier un code",
    "x-en-summary": "Verify a code",
    "description": "Un code n'est valable qu'une fois, jusqu'à son expiration, avec cinq essais au plus.",
    "x-en": "A code is valid only once, until it expires, with at most five attempts.",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "example": "otp_9a8b7c6d5e4f3a2b1c0d"
      }
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "code"
        ],
        "properties": {
         "code": {
          "type": "string"
         }
        }
       },
       "example": {
        "code": "482913"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Résultat de la vérification",
      "x-en": "Verification result",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/OtpCheck"
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Error"
     },
     "409": {
      "$ref": "#/components/responses/Error"
     },
     "410": {
      "$ref": "#/components/responses/Error"
     },
     "429": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/v1/whatsapp/templates": {
   "get": {
    "tags": [
     "WhatsApp"
    ],
    "operationId": "listTemplates",
    "summary": "Lister les modèles",
    "x-en-summary": "List templates",
    "description": "Modèles du compte WhatsApp Business et leur statut d'approbation par Meta. Avec une clé de test : modèles d'exemple.",
    "x-en": "Templates of the WhatsApp Business account and their Meta approval status. With a test key: sample templates.",
    "responses": {
     "200": {
      "description": "Liste des modèles",
      "x-en": "List of templates",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/Template"
           }
          }
         }
        }
       }
      }
     }
    }
   },
   "post": {
    "tags": [
     "WhatsApp"
    ],
    "operationId": "submitTemplate",
    "summary": "Soumettre un modèle à Meta",
    "x-en-summary": "Submit a template to Meta",
    "description": "Le modèle est examiné par Meta avant de pouvoir être utilisé ; son statut passe de pending à approved ou rejected. Variables : {{1}}, {{2}}…",
    "x-en": "The template is reviewed by Meta before it can be used; its status changes from pending to approved or rejected. Variables: {{1}}, {{2}}…",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Template"
       },
       "example": {
        "name": "rappel_paiement",
        "language": "fr",
        "category": "utility",
        "components": [
         {
          "type": "BODY",
          "text": "Bonjour {{1}}, votre échéance de {{2}} FCFA arrive le {{3}}.",
          "example": {
           "body_text": [
            [
             "Awa",
             "25 000",
             "5 novembre"
            ]
           ]
          }
         }
        ]
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "Modèle soumis",
      "x-en": "Template submitted",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Template"
        }
       }
      }
     },
     "422": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  },
  "/v1/webhook": {
   "get": {
    "tags": [
     "Webhooks"
    ],
    "operationId": "getWebhook",
    "summary": "Consulter le webhook",
    "x-en-summary": "Retrieve the webhook",
    "description": "Adresse qui reçoit les événements du compte.",
    "x-en": "Address that receives the account's events.",
    "responses": {
     "200": {
      "description": "Configuration",
      "x-en": "Configuration",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Webhook"
        }
       }
      }
     }
    }
   },
   "put": {
    "tags": [
     "Webhooks"
    ],
    "operationId": "setWebhook",
    "summary": "Configurer le webhook",
    "x-en-summary": "Set the webhook",
    "description": "Adresse https:// publique. La réponse contient le secret de signature, affiché une seule fois. Une nouvelle configuration remplace le secret.",
    "x-en": "Public https:// address. The response contains the signing secret, shown only once. A new configuration replaces the secret.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "url"
        ],
        "properties": {
         "url": {
          "type": "string",
          "format": "uri"
         }
        }
       },
       "example": {
        "url": "https://exemple.cm/webhooks/warilo"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Webhook configuré",
      "x-en": "Webhook set",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Webhook"
        }
       }
      }
     },
     "422": {
      "$ref": "#/components/responses/Error"
     }
    }
   },
   "delete": {
    "tags": [
     "Webhooks"
    ],
    "operationId": "deleteWebhook",
    "summary": "Désactiver le webhook",
    "x-en-summary": "Disable the webhook",
    "description": "Plus aucun événement n'est envoyé.",
    "x-en": "No more events are sent.",
    "responses": {
     "200": {
      "description": "Webhook désactivé",
      "x-en": "Webhook disabled"
     }
    }
   }
  },
  "/v1/webhook/test": {
   "post": {
    "tags": [
     "Webhooks"
    ],
    "operationId": "testWebhook",
    "summary": "Envoyer un événement de test",
    "x-en-summary": "Send a test event",
    "description": "Envoie un événement webhook.test à l'adresse configurée.",
    "x-en": "Sends a webhook.test event to the configured address.",
    "responses": {
     "202": {
      "description": "Événement mis en file",
      "x-en": "Event queued"
     }
    }
   }
  },
  "/v1/balance": {
   "get": {
    "tags": [
     "Compte"
    ],
    "operationId": "getBalance",
    "summary": "Consulter le solde",
    "x-en-summary": "Retrieve the balance",
    "description": "Crédits restants (clé live) et coût unitaire par type de message. Les envois en mode test ne consomment aucun crédit.",
    "x-en": "Remaining credits (live key) and unit cost per message type. Test-mode sends use no credits.",
    "responses": {
     "200": {
      "description": "Solde",
      "x-en": "Balance",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Balance"
        }
       }
      }
     }
    }
   }
  },
  "/v1/health": {
   "get": {
    "tags": [
     "Compte"
    ],
    "operationId": "health",
    "security": [],
    "summary": "État du service",
    "x-en-summary": "Service status",
    "description": "Sans authentification.",
    "x-en": "No authentication.",
    "responses": {
     "200": {
      "description": "Service disponible",
      "x-en": "Service available"
     }
    }
   }
  },
  "/v1/sandbox/inbound": {
   "post": {
    "tags": [
     "Sandbox"
    ],
    "operationId": "simulateInbound",
    "summary": "Simuler une réponse WhatsApp",
    "x-en-summary": "Simulate a WhatsApp reply",
    "description": "Clé de test uniquement. Simule un message reçu de ce contact : la fenêtre de 24 heures s'ouvre et un webhook message.received est envoyé.",
    "x-en": "Test key only. Simulates a message received from this contact: the 24-hour window opens and a message.received webhook is sent.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "from"
        ],
        "properties": {
         "from": {
          "type": "string"
         },
         "text": {
          "type": "string"
         }
        }
       },
       "example": {
        "from": "+237673713115",
        "text": "Bonjour, où en est ma commande ?"
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "Message simulé",
      "x-en": "Simulated message",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Inbound"
        }
       }
      }
     },
     "403": {
      "$ref": "#/components/responses/Error"
     }
    }
   }
  }
 },
 "webhooks": {
  "message.sent": {
   "post": {
    "summary": "Message transmis à l'opérateur ou à WhatsApp",
    "x-en-summary": "Message handed to the operator or WhatsApp",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Event"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Accusé"
     }
    }
   }
  },
  "message.delivered": {
   "post": {
    "summary": "Message remis au destinataire",
    "x-en-summary": "Message delivered to the recipient",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Event"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Accusé"
     }
    }
   }
  },
  "message.read": {
   "post": {
    "summary": "Message WhatsApp lu",
    "x-en-summary": "WhatsApp message read",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Event"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Accusé"
     }
    }
   }
  },
  "message.undelivered": {
   "post": {
    "summary": "Message non remis (téléphone éteint trop longtemps, numéro inactif…)",
    "x-en-summary": "Message not delivered (phone off too long, inactive number…)",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Event"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Accusé"
     }
    }
   }
  },
  "message.failed": {
   "post": {
    "summary": "Envoi impossible ; fallback_id indique le SMS de secours éventuel",
    "x-en-summary": "Sending failed; fallback_id gives the backup SMS, if any",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Event"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Accusé"
     }
    }
   }
  },
  "message.received": {
   "post": {
    "summary": "Message WhatsApp reçu d'un contact (ouvre la fenêtre de 24 heures)",
    "x-en-summary": "WhatsApp message received from a contact (opens the 24-hour window)",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Event"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Accusé"
     }
    }
   }
  }
 },
 "components": {
  "securitySchemes": {
   "bearer": {
    "type": "http",
    "scheme": "bearer",
    "description": "Clé wk_test_… (aucun envoi réel) ou wk_live_… (côté serveur uniquement).",
    "x-en": "wk_test_… key (no real sending) or wk_live_… key (server side only)."
   }
  },
  "parameters": {
   "IdempotencyKey": {
    "name": "Idempotency-Key",
    "in": "header",
    "schema": {
     "type": "string",
     "maxLength": 120
    },
    "description": "Clé unique de votre côté : rejouer la requête avec la même clé ne crée pas de second message.",
    "x-en": "A unique key on your side: replaying the request with the same key does not create a second message."
   }
  },
  "responses": {
   "Error": {
    "description": "Erreur",
    "x-en": "Error",
    "content": {
     "application/json": {
      "schema": {
       "type": "object",
       "properties": {
        "error": {
         "$ref": "#/components/schemas/ErrorBody"
        }
       }
      },
      "example": {
       "error": {
        "code": "invalid_number",
        "message": "Le numéro doit être au format international, par exemple +237673713115"
       }
      }
     }
    }
   }
  },
  "schemas": {
   "Status": {
    "type": "string",
    "enum": [
     "queued",
     "sending",
     "sent",
     "delivered",
     "read",
     "undelivered",
     "failed"
    ]
   },
   "NewMessage": {
    "type": "object",
    "required": [
     "to"
    ],
    "properties": {
     "channel": {
      "type": "string",
      "enum": [
       "sms",
       "whatsapp",
       "auto"
      ],
      "default": "sms",
      "description": "auto : WhatsApp, puis SMS en cas d'échec",
      "x-en": "auto: WhatsApp, then SMS on failure"
     },
     "to": {
      "type": "string",
      "description": "Numéro au format international E.164",
      "x-en": "Number in international E.164 format",
      "example": "+237673713115"
     },
     "text": {
      "type": "string",
      "description": "Texte du SMS, ou message WhatsApp libre (dans la fenêtre de 24 heures)",
      "x-en": "SMS text, or free-form WhatsApp message (within the 24-hour window)"
     },
     "from": {
      "type": "string",
      "description": "SMS : nom d'expéditeur déclaré (11 caractères au plus)",
      "x-en": "SMS: registered sender name (11 characters max)"
     },
     "template": {
      "$ref": "#/components/schemas/TemplateRef"
     },
     "media": {
      "type": "object",
      "properties": {
       "type": {
        "type": "string",
        "enum": [
         "image",
         "document",
         "audio",
         "video"
        ]
       },
       "url": {
        "type": "string",
        "format": "uri"
       },
       "caption": {
        "type": "string"
       },
       "filename": {
        "type": "string"
       }
      },
      "description": "WhatsApp : fichier accessible en https://",
      "x-en": "WhatsApp: file reachable over https://"
     },
     "fallback_text": {
      "type": "string",
      "description": "Texte du SMS de secours (channel auto)",
      "x-en": "Text of the backup SMS (channel auto)"
     },
     "reference": {
      "type": "string",
      "maxLength": 120,
      "description": "Votre référence, renvoyée dans les webhooks",
      "x-en": "Your reference, returned in webhooks"
     }
    }
   },
   "TemplateRef": {
    "type": "object",
    "required": [
     "name"
    ],
    "properties": {
     "name": {
      "type": "string"
     },
     "language": {
      "type": "string",
      "default": "fr"
     },
     "variables": {
      "type": "array",
      "items": {
       "type": "string"
      },
      "description": "Valeurs de {{1}}, {{2}}…",
      "x-en": "Values for {{1}}, {{2}}…"
     }
    }
   },
   "Message": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string",
      "example": "msg_3f2a9c0d1e4b5a6f7c8d"
     },
     "object": {
      "const": "message"
     },
     "channel": {
      "type": "string",
      "enum": [
       "sms",
       "whatsapp"
      ]
     },
     "to": {
      "type": "string"
     },
     "from": {
      "type": [
       "string",
       "null"
      ]
     },
     "status": {
      "$ref": "#/components/schemas/Status"
     },
     "error": {
      "oneOf": [
       {
        "type": "null"
       },
       {
        "$ref": "#/components/schemas/ErrorBody"
       }
      ]
     },
     "segments": {
      "type": "integer",
      "description": "SMS facturés",
      "x-en": "Billed SMS segments"
     },
     "encoding": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "gsm7",
       "ucs2",
       null
      ]
     },
     "cost": {
      "type": "integer",
      "description": "Crédits",
      "x-en": "Credits"
     },
     "reference": {
      "type": [
       "string",
       "null"
      ]
     },
     "fallback_id": {
      "type": [
       "string",
       "null"
      ]
     },
     "parent_id": {
      "type": [
       "string",
       "null"
      ]
     },
     "test": {
      "type": "boolean"
     },
     "text": {
      "type": [
       "string",
       "null"
      ]
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "updated_at": {
      "type": "string",
      "format": "date-time"
     }
    },
    "example": {
     "id": "msg_3f2a9c0d1e4b5a6f7c8d",
     "object": "message",
     "channel": "sms",
     "to": "+237673713115",
     "from": "WARILO",
     "status": "queued",
     "error": null,
     "segments": 1,
     "encoding": "gsm7",
     "cost": 1,
     "reference": "commande-1042",
     "fallback_id": null,
     "parent_id": null,
     "test": true,
     "text": "Votre commande C-1042 est prête.",
     "created_at": "2026-10-28T09:12:03Z",
     "updated_at": "2026-10-28T09:12:03Z"
    }
   },
   "MessageList": {
    "type": "object",
    "properties": {
     "data": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Message"
      }
     },
     "has_more": {
      "type": "boolean"
     }
    }
   },
   "NewOtp": {
    "type": "object",
    "required": [
     "to"
    ],
    "properties": {
     "to": {
      "type": "string"
     },
     "channel": {
      "type": "string",
      "enum": [
       "sms",
       "whatsapp",
       "auto"
      ],
      "default": "sms"
     },
     "brand": {
      "type": "string",
      "description": "Nom affiché dans le message",
      "x-en": "Name shown in the message"
     },
     "length": {
      "type": "integer",
      "minimum": 4,
      "maximum": 8,
      "default": 6
     },
     "ttl": {
      "type": "integer",
      "minimum": 60,
      "maximum": 1800,
      "default": 300,
      "description": "Durée de validité en secondes",
      "x-en": "Validity in seconds"
     },
     "language": {
      "type": "string",
      "enum": [
       "fr",
       "en"
      ],
      "default": "fr"
     }
    }
   },
   "Otp": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string"
     },
     "to": {
      "type": "string"
     },
     "channel": {
      "type": "string"
     },
     "message_id": {
      "type": "string"
     },
     "status": {
      "type": "string"
     },
     "expires_at": {
      "type": "string",
      "format": "date-time"
     },
     "code": {
      "type": "string",
      "description": "Clé de test uniquement",
      "x-en": "Test key only"
     }
    },
    "example": {
     "id": "otp_9a8b7c6d5e4f3a2b1c0d",
     "object": "otp",
     "to": "+237673713115",
     "channel": "sms",
     "message_id": "msg_1b2c3d4e5f6a7b8c9d0e",
     "status": "pending",
     "expires_at": "2026-10-28T09:17:03Z",
     "test": true,
     "code": "482913"
    }
   },
   "OtpCheck": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string"
     },
     "valid": {
      "type": "boolean"
     },
     "status": {
      "type": "string"
     },
     "attempts_left": {
      "type": "integer"
     }
    },
    "example": {
     "id": "otp_9a8b7c6d5e4f3a2b1c0d",
     "object": "otp",
     "valid": true,
     "status": "verified"
    }
   },
   "Template": {
    "type": "object",
    "properties": {
     "name": {
      "type": "string"
     },
     "language": {
      "type": "string"
     },
     "category": {
      "type": "string",
      "enum": [
       "marketing",
       "utility",
       "authentication"
      ]
     },
     "status": {
      "type": "string",
      "enum": [
       "pending",
       "approved",
       "rejected",
       "paused",
       "disabled"
      ]
     },
     "components": {
      "type": "array",
      "items": {
       "type": "object"
      }
     }
    }
   },
   "Webhook": {
    "type": "object",
    "properties": {
     "url": {
      "type": [
       "string",
       "null"
      ]
     },
     "enabled": {
      "type": "boolean"
     },
     "secret": {
      "type": "string",
      "description": "Affiché une seule fois",
      "x-en": "Shown only once"
     }
    },
    "example": {
     "object": "webhook",
     "url": "https://exemple.cm/webhooks/warilo",
     "enabled": true,
     "secret": "whsec_…"
    }
   },
   "Balance": {
    "type": "object",
    "properties": {
     "balance": {
      "type": [
       "integer",
       "null"
      ]
     },
     "unit": {
      "type": "string"
     },
     "prices": {
      "type": "object"
     }
    },
    "example": {
     "object": "balance",
     "balance": 12500,
     "unit": "credit",
     "test": false,
     "prices": {
      "sms_segment": 1,
      "whatsapp_template": 1,
      "whatsapp_session": 0
     }
    }
   },
   "Inbound": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string"
     },
     "from": {
      "type": "string"
     },
     "text": {
      "type": [
       "string",
       "null"
      ]
     },
     "window_expires_at": {
      "type": "string",
      "format": "date-time"
     }
    }
   },
   "Event": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string"
     },
     "type": {
      "type": "string"
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "test": {
      "type": "boolean"
     },
     "data": {
      "type": "object"
     }
    },
    "example": {
     "id": "evt_5c4b3a29180f7e6d5c4b",
     "type": "message.delivered",
     "created_at": "2026-10-28T09:12:07Z",
     "test": false,
     "data": {
      "id": "msg_3f2a9c0d1e4b5a6f7c8d",
      "object": "message",
      "channel": "sms",
      "to": "+237673713115",
      "status": "delivered",
      "reference": "commande-1042"
     }
    }
   },
   "ErrorBody": {
    "type": "object",
    "required": [
     "code",
     "message"
    ],
    "properties": {
     "code": {
      "type": "string"
     },
     "message": {
      "type": "string"
     },
     "provider_code": {
      "description": "Code d'origine de l'opérateur ou de Meta",
      "x-en": "Original operator or Meta code"
     }
    }
   }
  }
 }
}
