AI Logs
The AI Logs endpoint exports records from ai_ailogs. It is a read-only OpenAPI endpoint that supports JSON responses and downloadable CSV files.
Use this endpoint to report on conversations handled by the Talk with AI custom destination, including the conversation text, duration, caller ID, and token usage. To retrieve call transcripts, summaries, and sentimental analysis instead, use the /aianalysis endpoint.
Object Summary
| Property | Value |
|---|---|
| Object | ailog |
| Primary path | /ailogs |
| Path aliases | /ailog, /ailogs, /ai_log, /ai_logs |
| Supported method | GET |
| Default format | json |
| Export format | csv |
| Source table | ai_ailogs |
Authentication and Tenant Scope
The endpoint accepts tenant full API keys, tenant read-only API keys, global full API keys, and global read-only API keys. Supply the key in the X-API-Key header, as a bearer token, or in the key query parameter.
- A tenant API key can return records only for its own tenant.
- A global API key can select one tenant by code or name, use a
%wildcard, or omittenantto return records from all tenants. - If IP filtering is enabled for the selected key, the request must originate from an allowed IP address or network.
Endpoint Patterns
| Action | Example pattern |
|---|---|
| List AI logs as JSON | GET https://pbx.example.com/pbx/openapi.php/ailogs?tenant=CANISTRACCI |
| Export AI logs as CSV | GET https://pbx.example.com/pbx/openapi.php/ailogs?tenant=CANISTRACCI&format=csv |
| Use the CSV export path | GET https://pbx.example.com/pbx/openapi.php/ailogs/export?tenant=CANISTRACCI |
| Filter by date range | GET https://pbx.example.com/pbx/openapi.php/ailogs?tenant=CANISTRACCI&start=2026-08-01%2000:00:00&end=2026-08-31%2023:59:59 |
| Get one row by path ID | GET https://pbx.example.com/pbx/openapi.php/ailogs/123?tenant=CANISTRACCI |
| Compatibility query form | GET https://pbx.example.com/pbx/openapi.php?object=ailogs&action=list&tenant=CANISTRACCI |
Query Parameters
| Parameter | Description |
|---|---|
tenant | Tenant code or tenant name. Tenant API keys are restricted to their tenant. Global API keys can use a code, name, % wildcard, or omit this parameter to search all tenants. |
start | Start date and time applied to ai_start. The default is today at 00:00:00. The date filter is not applied when id or uniqueid is supplied. |
end | End date and time applied to ai_start. The default is today at 23:59:59. The date filter is not applied when id or uniqueid is supplied. |
id | One or more comma-separated ai_id values. A path value such as /ailogs/123 maps to this filter. |
uniqueid | One or more comma-separated Asterisk unique ID values. |
callerid | One or more comma-separated exact caller ID values. |
customid | One or more comma-separated custom destination IDs from cu_customs. |
format | json or csv. The default is json. The /ailogs/export path defaults to csv. |
key | Optional API key query parameter. Prefer the X-API-Key header or bearer token for new integrations. |
Response and CSV Fields
JSON objects and CSV columns use the following fields in this order:
| Field | Description |
|---|---|
ai_id | Internal AI log row ID. |
ai_te_id | Internal tenant ID. |
ai_cu_id | Internal custom destination ID. |
cu_name | Name of the associated custom destination, when available. |
ai_uniqueid | Asterisk unique ID associated with the AI conversation. |
ai_callerid | Caller ID recorded for the conversation. |
ai_start | Conversation start date and time. |
ai_end | Conversation end date and time. |
ai_duration | Conversation duration. |
ai_talk | Conversation exchanged with the AI service. |
ai_total_tokens | Total tokens reported for the AI request. |
ai_input_tokens | Input tokens reported for the AI request. |
ai_output_tokens | Output tokens reported for the AI request. |
Examples
List Current-Day AI Logs
When no ID or date filter is supplied, the endpoint returns records started during the current day.
curl -H "X-API-Key: TENANT_READ_ONLY_API_KEY" \
"https://pbx.example.com/pbx/openapi.php/ailogs?tenant=CANISTRACCI"
Export a Date Range as CSV
curl -H "X-API-Key: TENANT_READ_ONLY_API_KEY" \
-o ai-logs.csv \
"https://pbx.example.com/pbx/openapi.php/ailogs/export?tenant=CANISTRACCI&start=2026-08-01%2000:00:00&end=2026-08-31%2023:59:59"
Get Logs by Unique ID
Supplying uniqueid disables the default current-day filter, so an older record can be retrieved without also setting a date range.
curl -H "Authorization: Bearer TENANT_API_KEY" \
"https://pbx.example.com/pbx/openapi.php/ailogs?tenant=CANISTRACCI&uniqueid=1787740000.42"
Example JSON Response
[
{
"ai_id": 123,
"ai_te_id": 12,
"ai_cu_id": 34,
"cu_name": "AI Receptionist",
"ai_uniqueid": "1787740000.42",
"ai_callerid": "+390212345678",
"ai_start": "2026-08-26 09:30:00",
"ai_end": "2026-08-26 09:31:15",
"ai_duration": 75,
"ai_talk": ">> I need sales.\n<< I will connect you.",
"ai_total_tokens": 420,
"ai_input_tokens": 280,
"ai_output_tokens": 140
}
]
Important Notes
- The endpoint is read-only.
POST,PUT,PATCH, andDELETEare rejected. - Without
idoruniqueid, the default range is the current day. Setstartandendto export a different period. - When
idoruniqueidis supplied, the date range is intentionally ignored. - A global key without a
tenantparameter can return records from all tenants visible to that key. - The
ai_talkfield can contain sensitive conversation content. Store exports securely and restrict access to API keys. - Use
/aianalysis, not/ailogs, for recorded-call transcripts, summaries, and sentimental analysis.
Common Errors
| Error | Meaning |
|---|---|
missing_api_key | No API key was supplied in the query string, X-API-Key, or bearer token. |
invalid_api_key | The supplied key does not match the tenant or global API key. |
api_ip_not_allowed | IP filtering is enabled and the client address is not in the key's allowed IP or network list. |
tenant_required | A tenant code or tenant name is required when using a tenant API key. |
tenant_not_found | The tenant parameter did not match any visible tenant. |
invalid_format | The format value is not json or csv. |
method_not_allowed | The endpoint is read-only and only supports GET. |