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.

Best Practices

  • Securely store JWT tokens
  • Validate phone numbers
  • Implement retry logic
  • Cache template IDs
  • Respect rate limits (60 requests/minute)

Rate Limiting

All API endpoints are rate limited to prevent abuse and ensure fair usage.

Property Value
Rate Limit 60 requests per minute
Tracking By authenticated user ID or IP address
Error Response HTTP 429 (Too Many Requests)
Headers Not currently implemented (X-RateLimit-* headers)

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"
  }
}

Team Management API

Manage your team members (staff) with full CRUD operations. Use these endpoints to add, update, and view team members.

Team vs Staff Assignment: Use /team for managing staff members (add/edit/view). Use /assign-staff to assign a conversation to a specific team member.
Pagination: Returns 10 team members per page (fixed, not customizable via query parameters).

Get All Team Members

GET https://mazbot.net/api/team

Returns a list of all team members.

PHP Example
$curl = curl_init();
curl_setopt_array($curl, [
  CURLOPT_URL => 'https://mazbot.net/api/team',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer your_jwt_token'
  ],
]);

$response = curl_exec($curl);
curl_close($curl);
$teamData = json_decode($response, true);

Add Team Member

POST https://mazbot.net/api/team-store
Request Parameters
Field Type Required Description
first_name string Yes Team member's first name
last_name string Yes Team member's last name
phone string No Phone number with country code
email string Yes Email address
password string Yes Account password
permissions array No List of permission strings
PHP Example
$teamData = [
  'first_name' => 'Ahmed',
  'last_name' => 'Mohamed',
  'phone' => '+201234567890',
  'email' => '[email protected]',
  'password' => 'securePassword123',
  'permissions' => ['read:team', 'write:contacts']
];

$curl = curl_init();
curl_setopt_array($curl, [
  CURLOPT_URL => 'https://mazbot.net/api/team-store',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_POSTFIELDS => json_encode($teamData),
  CURLOPT_HTTPHEADER => [
    'Content-Type: application/json',
    'Authorization: Bearer your_jwt_token'
  ],
]);

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

Update Team Member

POST https://mazbot.net/api/team-update/{id}

Updates an existing team member's information.

WhatsApp API

Manage WhatsApp contacts and contact lists.

Get All Contacts

GET https://mazbot.net/api/whatsapp-contact

Returns a list of all WhatsApp contacts.

Add Contact

POST https://mazbot.net/api/whatsapp-contact-store
Request Parameters
Field Type Required Description
name string Yes Contact name
phone string Yes Phone number with country code
country_id integer No Country ID
status integer No 1 = Active, 0 = Inactive
PHP Example
$contactData = [
  'name' => 'Ahmed Mohamed',
  'phone' => '+201234567890',
  'country_id' => 1,
  'status' => 1
];

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

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

Get All Contact Lists

GET https://mazbot.net/api/whatsapp-contact-list

Returns a list of all WhatsApp contact lists.

Contact Management API

Manage contacts with full CRUD operations, pagination, and block functionality.

Get All Contacts

GET https://mazbot.net/api/contacts

Retrieve a paginated list of all contacts.

PHP Example
$curl = curl_init();
curl_setopt_array($curl, [
  CURLOPT_URL => 'https://mazbot.net/api/contacts?page=1',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer your_jwt_token'
  ],
]);

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

$data = json_decode($response, true);
print_r($data['data']['contacts']);
JSON Response Example
{
  "status": true,
  "message": "data_retrieved_successfully",
  "data": {
    "contacts": [
      {
        "id": 101,
        "name": "Ahmed Mohamed",
        "phone": "+201234567890",
        "email": "[email protected]",
        "type": "whatsapp",
        "status": 1
      }
    ],
    "paginate": {
      "total": 150,
      "current_page": 1,
      "per_page": 10,
      "last_page": 15,
      "next_page_url": "https://mazbot.net/api/contacts?page=2"
    }
  }
}

Create Contact

POST https://mazbot.net/api/contacts

Add a new contact to the system.

PHP Example
$contactData = [
  'phone' => '01234567890',
  'country_id' => 1,
  'name' => 'Ahmed Mohamed',
  'email' => '[email protected]'
];

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

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

Update Contact

PUT https://mazbot.net/api/contacts/{id}

Update an existing contact's information.

Block Contact

POST https://mazbot.net/api/block/{id}

Block or unblock a contact to prevent/allow messaging.

Chat Management API

Manage chat rooms and messages.

Get Chat Rooms

GET https://mazbot.net/api/chat-rooms

Retrieve a list of chat rooms with search and filter options.

PHP Example
$curl = curl_init();
curl_setopt_array($curl, [
  CURLOPT_URL => 'https://mazbot.net/api/chat-rooms?page=1&type=whatsapp',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer your_jwt_token'
  ],
]);

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

$data = json_decode($response, true);
print_r($data['data']['chat_rooms']);
JSON Response Example
{
  "status": true,
  "message": "chat_retrieved_successfully",
  "data": {
    "chat_rooms": [
      {
        "id": 1,
        "contact_name": "Ahmed Mohamed",
        "phone": "+201234567890",
        "last_message": "Hello, how can I help you?",
        "unread_count": 3,
        "last_conversation_at": "2025-12-29T10:30:00Z"
      }
    ],
    "total_unread_messages": 12,
    "next_page_url": true
  }
}

Get Messages

GET https://mazbot.net/api/chatroom-messages/{id}

Get all messages for a specific contact/chatroom.

PHP Example
$contactId = 123;
$curl = curl_init();
curl_setopt_array($curl, [
  CURLOPT_URL => "https://mazbot.net/api/chatroom-messages/{$contactId}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer your_jwt_token'
  ],
]);

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

Clear Chat

POST https://mazbot.net/api/clear-chat/{id}

Delete all messages in a chat room.

Media & Files API

Manage shared files and media in conversations.

Get Shared Files

GET https://mazbot.net/api/shared-files/{id}

Delete File

DELETE https://mazbot.net/api/delete-file/{id}

AI Auto-Reply API

Manage AI auto-reply settings for contacts.

Toggle AI Auto-Reply

POST https://mazbot.net/api/toggle-contact-ai-reply

Enable or disable AI auto-reply for a specific contact.

Request Parameters
Field Type Required Description
contact_id integer Yes Contact ID
ai_reply_enabled boolean No True to enable, false to disable. If omitted, toggles current state.
PHP Example
$data = [
  'contact_id' => 123,
  'ai_reply_enabled' => true
];

$curl = curl_init();
curl_setopt_array($curl, [
  CURLOPT_URL => 'https://mazbot.net/api/toggle-contact-ai-reply',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_POSTFIELDS => json_encode($data),
  CURLOPT_HTTPHEADER => [
    'Content-Type: application/json',
    'Authorization: Bearer your_jwt_token'
  ],
]);

$response = curl_exec($curl);
curl_close($curl);
JSON Response Example
{
  "success": true,
  "message": "AI auto-reply enabled for this contact",
  "ai_reply_enabled": true,
  "contact_id": 123
}

Client & Staff API

Assign staff to contacts and view contact details.

Assign Staff

POST https://mazbot.net/api/assign-staff

Assign a staff member to handle a specific contact.

PHP Example
$data = [
  'contact_id' => 101,
  'staff_id' => 5
];

$curl = curl_init();
curl_setopt_array($curl, [
  CURLOPT_URL => 'https://mazbot.net/api/assign-staff',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_POSTFIELDS => json_encode($data),
  CURLOPT_HTTPHEADER => [
    'Content-Type: application/json',
    'Authorization: Bearer your_jwt_token'
  ],
]);

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

Contact Details

GET https://mazbot.net/api/contacts-details/{id}

Get detailed information about a specific contact including notes and tags.

Ticket System API

Create and manage support tickets.

Get All Tickets

GET https://mazbot.net/api/ticket

Create Ticket

POST https://mazbot.net/api/ticket-store

Reply to Ticket

POST https://mazbot.net/api/ticket-reply/{id}

Ready to Integrate!

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