Data API (function calling)
Unlike the rest of this reference, the Data API is an outbound integration: you implement a single endpoint, and the Vexar AI calls it in real time to fetch your live data (products, orders, accounts). Configure it in Chatbot Settings → Data API.
How it works
- A visitor asks: “Do you have red sneakers under $50?”
- The AI decides to call
search_productswith{"query":"red sneakers","max_price":50}. - Vexar sends a POST to your endpoint; your server returns matching items.
- The AI turns the result into a natural reply.
Setup
Enable and point Vexar at your endpoint via the chatbot config (see Chatbot Settings):
| Param | Description |
|---|---|
data_api_enabled | Turn the Data API on/off |
data_api_url | Your endpoint URL (POST, JSON) |
data_api_key | Secret sent as Bearer token to your endpoint |
data_api_timeout | Request timeout, 3–30 sec (default 5) |
Request your endpoint receives
POST {your data_api_url}
Authorization: Bearer {your data_api_key}
Content-Type: application/json
User-Agent: VexarChat-DataAPI/1.0
{
"action": "search_products",
"params": { "query": "red sneakers", "max_price": 50, "in_stock": true }
}
Response your endpoint returns
{
"success": true,
"data": [
{ "id": 123, "name": "Nike Air Max Red", "price": 45.99, "currency": "USD", "url": "https://…", "in_stock": true }
]
}
// on error:
{ "success": false, "error": "Product not found" }
Actions
Implement the actions your chatbot needs (at minimum ping). Each action sends an action name and a params object.
| Action | Params | Description |
|---|---|---|
ping | — | Health check. Return {"success":true,"data":{"status":"ok"}}. |
search_products | query, category, min_price, max_price, in_stock, limit | Search products/services. Return an array of items. |
get_product | product_id | Details of one product. |
get_categories | — | List of categories. |
check_availability | product_id | Stock or booking availability. |
check_order_status | order_id, email | Order status (at least one identifier). |
lookup_account | account_id, phone, email, contract_number | Account/subscription lookup (ISP, telecom, SaaS…). Return any relevant fields. |
Test your connection
Vexar exposes one authenticated endpoint to test your Data API endpoint (it sends a ping):
POST
/api/v1/data-api/test AuthSend a ping to the given URL and report the result.
Request body
{ "url": "https://your-site.com/vexar-api", "api_key": "your-key", "timeout": 5 }Response
{ "success": true, "message": "Connection successful", "data": { "status": "ok" } }Example endpoint (PHP)
<?php
header('Content-Type: application/json');
$auth = $_SERVER['HTTP_AUTHORIZATION'] ?? '';
if (str_replace('Bearer ', '', $auth) !== 'YOUR_SECRET_KEY') {
http_response_code(401);
echo json_encode(['success' => false, 'error' => 'Unauthorized']); exit;
}
$in = json_decode(file_get_contents('php://input'), true);
switch ($in['action'] ?? '') {
case 'ping':
echo json_encode(['success' => true, 'data' => ['status' => 'ok']]); break;
case 'search_products':
// … query your DB, return ['success'=>true,'data'=>[…]]
default:
echo json_encode(['success' => false, 'error' => 'Unknown action']);
}
Rules & limits
| Max items per response | 10 |
| Timeout | 5 s default, 30 s max |
| Method / format | POST, JSON only |
| Max tool calls per message | 3 |
| Supported AI providers | OpenAI, Anthropic (Claude), Google Gemini — not DeepSeek |
Live demos: e-commerce and ISP sample endpoints.