Project

General

Profile

API - Call Detail Records - CDR

CDR API is used to read the list of calls from the PBX

API URL

https://[YOUR-PBX-URL]/api/cdr

Data is sent via POST or GET and must be of the form:

Array
(
    [page] => 1
    [filters] => Array
        (
            [date_between] => Array
                (
                    [0] => 2024-01-01 00:00:00
                    [1] => 2024-01-15 23:59:59
                )
            [project_id] =>
            [user_id] =>
            [inbound_route_id] => 
            [direction] => 
            [call_status] => 
            [telephone_like] => 
            [telephone] => 
            [source] => 
            [destination] => 
            [hour_between] => 
            [from_id] => 
            [uniqueid] => 
            [linkedid] => 
            [external_id] => 
            [external_info] => 
            [has_transcription] => 
            [has_monitor_file] => 
            [has_recording_file] => 
        )

    [api_hash] => 07112231a9c89f5b108af08608a97b07
)

The page parameter defaults to 1 and is incremented up to pagination.max_page (a page greater than max_page still returns the last page). Calls are returned 100 per page, sorted by ID in descending order; new calls that appear during pagination can shift rows between pages, so remove duplicates by id.

HTTP Headers:

Content-Type: application/json
Authorization: Bearer <token>

Filters:

  • date_between: [from, to], format Y-m-d H:i:s (a date without time means 00:00:00, so the last day is not included)
  • hour_between: [from, to], format HH:MM:SS
  • project_id: project ID in the PBX (a single ID)
  • user_id: user ID in the PBX (a single ID)
  • inbound_route_id: Inbound route IDs (array or comma-separated values)
  • direction: call type: IN or OUT
  • call_status: call status: NO ANSWER, CONGESTION, FAILED, BUSY or ANSWERED
  • telephone_like: partial search in the source, destination and called number (DID)
  • telephone: search by number in the source or destination (text or number)
  • source: partial search in the number the call was initiated from
  • destination: partial search in the number the call was initiated to; for IN calls the called number (DID) is searched
  • from_id: returns calls with ID >= from_id; for synchronization send the last synchronized ID + 1
  • uniqueid: call IDs (array or comma-separated values)
  • linkedid: related call IDs (array or comma-separated values)
  • external_id: external IDs (array or comma-separated values), eg: sent to API - OriginateCall
  • external_info: external info (exact match)
  • has_transcription: 1 = only calls with a transcription
  • has_monitor_file: 1 = only calls with a recording file
  • has_recording_file: 1 = only calls with a voicemail message

Empty values, 0 or false ignore the filter. Any other filter returns the Invalid filter error.

Example of parameters generation:

$params = [
    'action' => 'read', // optional, defaults to read
    'page' => 1,
    'filters' => [
        'date_between' => ['2024-01-01 00:00:00', '2024-01-15 23:59:59'], // [from, to], format Y-m-d H:i:s
        'hour_between' => null, // [from, to]
        'project_id' => null,
        'user_id' => null,
        'inbound_route_id' => null, // [1,2,3,4] Inbound Routes IDs
        'direction' => null, // IN, OUT
        'call_status' => null, // NO ANSWER, CONGESTION, FAILED, BUSY, ANSWERED
        'telephone_like' => null, // Wildcard search for source OR destination
        'telephone' => null, // Exact search for source OR destination
        'source' => null, // Wildcard search for source
        'destination' => null, // Wildcard search for destination
        'from_id' => null, // >= id
        'uniqueid' => [],
        'linkedid' => [],
        'external_id' => [],
        'external_info' => null,
        'has_transcription' => null,
        'has_monitor_file' => null,
        'has_recording_file' => null,
    ]
];

Example of hash generation:

$params['api_hash'] = md5(json_encode($params) . 'your_api_key'); // make hash

Example of sending data:

$url = 'https://[YOUR-PBX-URL]/api/cdr';
$token = 'your_api_token';
echo curlPost($url, json_encode($params), array("Authorization: Bearer {$token}", "Content-Type: application/json"));

Data sent JSON:

{
  "page": 1,
  "filters": {
    "date_between": [
      "2024-01-01 00:00:00",
      "2024-01-15 23:59:59" 
    ],
    "project_id": null,
    "user_id": null,
    "inbound_route_id": null,
    "direction": null,
    "call_status": null,
    "telephone_like": null,
    "telephone": null,
    "source": null,
    "destination": null,
    "hour_between": null,
    "from_id": null,
    "uniqueid": [],
    "linkedid": [],
    "has_transcription": null,
    "has_monitor_file": null,
    "has_recording_file": null,
    "external_id": [],
    "external_info": null
  },
  "api_hash": "ff9a6b157cb1f79db73e7507635f878a" 
}

Response

If successful:

{

    "has_error": false,
    "messages": [ ],
    "pagination": {
        "row_count": 1,
        "page_size": 100,
        "current_page": 1,
        "max_page": 1
    },
  "results": [
    {
      "id": "29056",
      "uniqueid": "1710401324.480",
      "linkedid": "1710401324.480",
      "time": "2024-03-14 09:28:44",
      "time_end": "2024-03-14 09:29:00",
      "caller_id": "\"John Doe\" <0312000000>",
      "source": "0312285000",
      "destination": "0700000000",
      "direction": "OUT",
      "channel_formatted": "PJSIP/john-doe",
      "dstchannel_formatted": "",
      "dcontext": "internal",
      "customer_id": null,
      "user_id": "5",
      "user_fullname": "John Doe",
      "user_username": "john-doe",
      "user_remote_id": null,
      "queue": null,
      "queue_id": null,
      "code": "outbound",
      "call_status": "FAILED",
      "call_status_info": "DS:CONGESTION|HC:34|HI:SIP 503 Service Unavailable",
      "call_codes": "out no answer",
      "accounting_code": null,
      "accounting_value": null,
      "comments": null,
      "monitor_files": null,
      "monitor_urls": null,
      "recording_file": null,
      "recording_url": null,
      "transfers": null,
      "project": "My Project",
      "project_alias": "my-project",
      "inbound_route": null,
      "inbound_route_id": null,
      "queue_log": null,
      "ivr_log": null,
      "external_id": null,
      "external_info": null,
      "agent_details": null,
      "is_recovered": null,
      "transcription_ids": null,
      "transcription_text": null,
      "bill_duration": "00:00:00",
      "duration": "00:00:15",
      "bill_minutes": 0,
      "ivr_duration": "00:00:00",
      "hold_time": "00:00:00",
      "ring_time": "00:00:00" 
    }
  ]
}

The fields crm_contact_id, crm_contact_name, crm_custom_fields appear only if the CRM module is active; accounting_value and custom_tag only if they are configured. Durations are in HH:MM:SS format; monitor_urls contains the URLs separated by a new line.

Or in case of error:

{

    "has_error": true,
    "messages": [
        "Invalid filter: from_idxx" 
    ],
    "pagination": [ ],
    "results": [ ]

}

Available in other languages: RO