MazBot API Documentation

Version 2.0 | Updated: April 2025

Introduction

The MazBot API enables seamless WhatsApp messaging integration for your applications. Explore endpoints, request/response formats, and examples below.

Note: Authentication via API key and JWT token is required for all requests.

Authentication

Authenticate to obtain a JWT token for API requests.

Login Endpoint

POST https://mazbot.net/api/login
Request Parameters
Parameter Type Description
email string Registered MazBot email
password string MazBot account password
Request Headers
Header Value
apiKey Your MazBot API Key
PHP Example
curl_setopt_array($curl, [
  CURLOPT_URL => 'https://mazbot.net/api/login',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_POSTFIELDS => http_build_query([
    'email' => '[email protected]',
    'password' => 'your_password'
  ]),
  CURLOPT_HTTPHEADER => ['apiKey: your_api_key'],
]);

$response = curl_exec($curl);
curl_close($curl);

$loginResponse = json_decode($response, true);
$jwtToken = $loginResponse['data']['token'] ?? null;

if (!$jwtToken) {
  throw new Exception('Login failed: ' . ($loginResponse['message'] ?? 'Unknown error'));
}
Success Response
{
  "success": true,
  "data": {
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
  }
}
Error Response
{
  "success": false,
  "message": "Invalid credentials"
}

Sending WhatsApp Messages

Use your JWT token to send WhatsApp template messages.

Note: You can find the template_id by visiting https://mazbot.net/client/templates and hovering over the "Edit" button for your desired template.
Template Variables: If your template includes placeholders (e.g., {{1}}, {{2}}), you must include the body_values and body_matchs arrays in your request to map values to these placeholders. The number of variables in your template determines the structure of these arrays.
Example Template:
Payment Reminder:

Account Name: {{1}}
Current Plan Expiry Date: {{2}}

Please make the payment now to avoid service interruption.

Kindly ignore this message if you have already made the payment.
For this template, use the following code:
$templateData = [
  'template_id' => '93',
  'mobile' => '20123456789',
  'body_values' => [
    '1' => 'Ahmed',
    '2' => '2024-09-01'
  ],
  'body_matchs' => [
    '1' => 'input_value',
    '2' => 'input_value'
  ]
];
Important: Adjust the body_values and body_matchs arrays to match the number of placeholders in your template. For example, a template with three placeholders ({{1}}, {{2}}, {{3}}) requires three entries in each array.

Send Template Endpoint

POST https://mazbot.net/api/whatsapp/send-template
Request Parameters
Field Type Description
template_id string Template ID from MazBot dashboard
mobile string Recipient's phone number (e.g., 20123456789)
body_values array Optional template placeholder values
body_matchs array Optional placeholder match labels
Request Headers
Header Value
apiKey Your MazBot API Key
Authorization Bearer YOUR_JWT_TOKEN
Content-Type application/json
PHP Example (With Variables)
$templateData = [
  'template_id' => '93',
  'mobile' => '20123456789',
  'body_values' => [
    '1' => 'Ahmed',
    '2' => '2024-09-01'
  ],
  'body_matchs' => [
    '1' => 'input_value',
    '2' => 'input_value'
  ]
];

$curl = curl_init();
curl_setopt_array($curl, [
  CURLOPT_URL => 'https://mazbot.net/api/whatsapp/send-template',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_POSTFIELDS => json_encode($templateData),
  CURLOPT_HTTPHEADER => [
    'Content-Type: application/json',
    'apiKey: your_api_key',
    'Authorization: Bearer your_jwt_token'
  ],
]);

$response = curl_exec($curl);
curl_close($curl);
echo $response;
Success Response
{
  "success": true,
  "data": {
    "message_id": "ABEGkYZI4pQIDAgASkQw",
    "status": "sent"
  }
}

Error Handling

Common errors and solutions:

401 Unauthorized

Invalid or expired JWT token. Re-authenticate to refresh it.

400 Bad Request

Invalid parameters. Verify request body format.

403 Forbidden

Invalid API key or insufficient permissions.

Best Practices

  • Securely store JWT tokens
  • Validate phone numbers
  • Implement retry logic
  • Cache template IDs

Ready to Integrate!

Start building with the MazBot API. Contact support for assistance.