Skip to main content

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

PropertyValue
Objectailog
Primary path/ailogs
Path aliases/ailog, /ailogs, /ai_log, /ai_logs
Supported methodGET
Default formatjson
Export formatcsv
Source tableai_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 omit tenant to 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

ActionExample pattern
List AI logs as JSONGET https://pbx.example.com/pbx/openapi.php/ailogs?tenant=CANISTRACCI
Export AI logs as CSVGET https://pbx.example.com/pbx/openapi.php/ailogs?tenant=CANISTRACCI&format=csv
Use the CSV export pathGET https://pbx.example.com/pbx/openapi.php/ailogs/export?tenant=CANISTRACCI
Filter by date rangeGET 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 IDGET https://pbx.example.com/pbx/openapi.php/ailogs/123?tenant=CANISTRACCI
Compatibility query formGET https://pbx.example.com/pbx/openapi.php?object=ailogs&action=list&tenant=CANISTRACCI

Query Parameters

ParameterDescription
tenantTenant 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.
startStart 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.
endEnd 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.
idOne or more comma-separated ai_id values. A path value such as /ailogs/123 maps to this filter.
uniqueidOne or more comma-separated Asterisk unique ID values.
calleridOne or more comma-separated exact caller ID values.
customidOne or more comma-separated custom destination IDs from cu_customs.
formatjson or csv. The default is json. The /ailogs/export path defaults to csv.
keyOptional 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:

FieldDescription
ai_idInternal AI log row ID.
ai_te_idInternal tenant ID.
ai_cu_idInternal custom destination ID.
cu_nameName of the associated custom destination, when available.
ai_uniqueidAsterisk unique ID associated with the AI conversation.
ai_calleridCaller ID recorded for the conversation.
ai_startConversation start date and time.
ai_endConversation end date and time.
ai_durationConversation duration.
ai_talkConversation exchanged with the AI service.
ai_total_tokensTotal tokens reported for the AI request.
ai_input_tokensInput tokens reported for the AI request.
ai_output_tokensOutput 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, and DELETE are rejected.
  • Without id or uniqueid, the default range is the current day. Set start and end to export a different period.
  • When id or uniqueid is supplied, the date range is intentionally ignored.
  • A global key without a tenant parameter can return records from all tenants visible to that key.
  • The ai_talk field 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

ErrorMeaning
missing_api_keyNo API key was supplied in the query string, X-API-Key, or bearer token.
invalid_api_keyThe supplied key does not match the tenant or global API key.
api_ip_not_allowedIP filtering is enabled and the client address is not in the key's allowed IP or network list.
tenant_requiredA tenant code or tenant name is required when using a tenant API key.
tenant_not_foundThe tenant parameter did not match any visible tenant.
invalid_formatThe format value is not json or csv.
method_not_allowedThe endpoint is read-only and only supports GET.