WhatsApp Business API Documentation

Complete guide to integrating WhatsApp Business API for messaging, verification, and customer engagement.

Quick Start

Base URL: https://api.tayaribykmg.com

Authentication: Bearer token required

Content-Type: application/json

Send Message

POST /api/whatsapp/messages

Request Body:

{
  "to": "+1234567890",
  "type": "text",
  "text": {
    "body": "Hello! Welcome to Tayari services."
  }
}

Response:

{
  "messaging_product": "whatsapp",
  "contacts": [
    {
      "input": "+1234567890",
      "wa_id": "1234567890"
    }
  ],
  "messages": [
    {
      "id": "wamid.xxx"
    }
  ]
}

Send Template Message

POST /api/whatsapp/messages

Request Body:

{
  "to": "+1234567890",
  "type": "template",
  "template": {
    "name": "hello_world",
    "language": {
      "code": "en_US"
    },
    "components": [
      {
        "type": "body",
        "parameters": [
          {
            "type": "text",
            "text": "World"
          }
        ]
      }
    ]
  }
}

Interactive Messages

POST /api/whatsapp/messages

Button Message:

{
  "to": "+1234567890",
  "type": "interactive",
  "interactive": {
    "type": "button",
    "body": {
      "text": "Choose an option:"
    },
    "action": {
      "buttons": [
        {
          "type": "reply",
          "reply": {
            "id": "option_1",
            "title": "Option 1"
          }
        },
        {
          "type": "reply",
          "reply": {
            "id": "option_2",
            "title": "Option 2"
          }
        }
      ]
    }
  }
}

Get Messages

GET /api/whatsapp/messages

Query Parameters:

  • limit - Number of messages to retrieve (default: 50)
  • offset - Number of messages to skip
  • from_date - Filter messages from date (ISO format)
  • to_date - Filter messages to date (ISO format)

Phone Number Verification

POST /api/whatsapp/verify

Request Body:

{
  "phone_number": "+1234567890",
  "verification_code": "123456"
}

Common Error Codes

400Bad Request - Invalid payload or missing required fields
401Unauthorized - Invalid or missing authentication token
403Forbidden - Insufficient permissions
429Rate Limit Exceeded - Too many requests
500Internal Server Error - Server-side error

SDKs & Libraries

JavaScript/Node.js

npm install tayari-whatsapp-sdk

Python

pip install tayari-whatsapp

PHP

composer require tayari/whatsapp

Java

maven: tayari-whatsapp-java