Web API
The Web API exposes most Aysali Bot admin features over HTTP. Every call is a POST to include/api.php on your bot host, with an admin token and a function name plus that function’s arguments.
Endpoint URL
Use the Admin URL from your tenant portal (for example https://360-bot.aysali.com). The API file path is:
https://YOUR-BOT-HOST/include/api.php
Replace YOUR-BOT-HOST with the hostname shown under Aysali Bot → Open admin in the portal.
Admin token
- Open your bot admin panel.
- Go to Users and open the profile box of an admin user.
- Copy the API token shown there.
Send the token on every request either:
- In the JSON or form body as
token, or - As an HTTP header named
token.
Only admin tokens are accepted for the Web API. Keep the token secret.
See Authentication for error codes and response format.
Request format
- Method:
POST - Content-Type:
application/jsonorapplication/x-www-form-urlencoded - Body: must include
function(method name) andtoken, plus any parameters documented for that function.
JSON fields that are objects or arrays (for example attachments, settings, user_ids) may be sent as JSON strings; the server decodes them automatically.
PHP example
function aysali_bot_api(array $query): array {
$ch = curl_init('https://YOUR-BOT-HOST/include/api.php');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_POST => true,
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_POSTFIELDS => http_build_query(array_merge(['token' => 'YOUR-ADMIN-TOKEN'], $query)),
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true) ?: [];
}
// Example: get user 123
$result = aysali_bot_api(['function' => 'get-user', 'user_id' => '123']);
cURL example
curl -sS -X POST "https://YOUR-BOT-HOST/include/api.php" \
-H "Content-Type: application/json" \
-d '\{"token":"YOUR-ADMIN-TOKEN","function":"get-user","user_id":"123"}'
Cron endpoints (GET, no token)
These maintenance URLs use GET query flags on the same api.php file (no admin token):
| Query flag | Purpose |
|---|---|
?cron | General maintenance cron |
?piping | Email piping sync |
?email-notifications | Email notification cron |
?open-ai-training | Server-side OpenAI training (cloud: limited frequency) |
Documented in the API reference under Cron.
Protected functions
Some methods expect an active admin context. When documented, set before the call:
$GLOBALS['SB_FORCE_ADMIN'] = true;
// call API-related logic
$GLOBALS['SB_FORCE_ADMIN'] = false;
To act as a specific user in server-side code:
$GLOBALS['SB_LOGIN'] = [
'id' => '',
'first_name' => '',
'last_name' => '',
'email' => '',
'user_type' => '',
'department' => '',
];
Interactive reference
Browse all functions with Try it in the Bot Web API Swagger UI (new tab), or open the Interactive API page in this site.