---
title: "Search CDRs"
method: POST
path: "/api/cdrs"
tags: ["CDRs"]
---

# Search CDRs

`POST /api/cdrs`

## Request

- Base URL: `https://your-instance.stats.pbx.commpeak.com`
- URL: `https://your-instance.stats.pbx.commpeak.com/api/cdrs`
- Auth: API key in header `X-API-KEY`

### API Request Description

This endpoint allows you to retrieve call detail records (CDRs) by submitting a POST request to the specified URL. The request should be in x-www-form-urlencoded format, and it supports various parameters for filtering and sorting the CDRs.

- `format`: The format of the response.
    
- `page`: The number of the page.
    
- `cdrs_per_page`: The amount of CDRs per page.
    
- `sort_by`: Sort by field.
    
- `sort_direction`: Sort in ascending or descending order.
    
- `from`: From what date to search (Default value: yesterday at 00:00:00).
    
- `till`: Till what date to search (Default value: now).
    
- `queue`: Search by queue IDs (e.g., 10,20,30...).
    
- `agent`: Search by agent IDs (e.g., 10,20,30...).
    
- `bridged_agent`: Search by bridged agent IDs (e.g., 10,20,30...).
    
- `country`: Search by country's ISO2 (e.g., IL,UA,US...).
    
- `direction`: Search by call direction.
    
- `call_type`: Search by call type.
    
- `destination`: Search by destination number.
    
- `source`: Search by source number.
    
- `extension`: Search by call type.
    
- `did`: Search by DID.
    
- `caller_id`: Search by caller id number.
    
- `hangup_cause`: Search by hangup cause (e.g., ANSWERED,BUSY,NO_ANSWER ...).
    
- `bill_duration_from`: Filter the bill duration from (in seconds).
    
- `successful`: Show only successful calls.
    
- `completed`: Show only completed calls.
    
- `transferred`: Show only transferred calls.
    
- `shift`: Search by shift ID.
    
- `by_shift_hour`: Search by shift ID.
    
- `uniqueid`: Search by unique id.
    
- `id`: Search by id (e.g., 5698 | 5000-6000).
    
- `{custom_field}`: Filter by custom fields (Key -> field name, Value -> field value).
    

### API Response (JSON Schema)

``` json
{
    "type": "object",
    "properties": {
        "cdrs": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "id": {"type": "string"},
                    "call_start": {"type": "string"},
                    "call_end": {"type": "string"},
                    "duration": {"type": "string"},
                    "bill_duration": {"type": "string"},
                    "type": {"type": "string"},
                    "destination": {"type": "string"},
                    "caller_id": {"type": "string"},
                    "country_name": {"type": "string"},
                    "agent_name": {"type": "string"},
                    "agent_pbxExtension": {"type": "string"},
                    "bridged_agent_name": {"type": "string"},
                    "bridged_agent_pbxExtension": {"type": "string"},
                    "hangup_cause": {"type": "string"},
                    "waiting_time": {"type": "string"},
                    "recording_link": {"type": "string"},
                    "queue_alias": {"type": "string"},
                    "queue_name": {"type": "string"},
                    "desks": {"type": "string"},
                    "custom_fields": {"type": "string"},
                    "cost": {"type": "string"}
                }
            }
        }
    }
}

 ```

## Request body `application/x-www-form-urlencoded`

- object
  - `agent` string
  - `bill_duration_from` string
  - `bridged_agent` string
  - `by_shift_hour` string
  - `call_type` string
  - `caller_id` string
  - `cdrs_per_page` string
  - `completed` string
  - `country` string
  - `destination` string
  - `did` string
  - `direction` string
  - `extension` string
  - `format` string
  - `from` string
  - `hangup_cause` string
  - `id` string
  - `page` string
  - `queue` string
  - `shift` string
  - `sort_by` string
  - `sort_direction` string
  - `source` string
  - `successful` string
  - `till` string
  - `transferred` string
  - `uniqueid` string
  - `{custom_field}` string

## Response `200`

successful operation

- object
  - `cdrs` object[]
    - `agent_name` string
    - `agent_pbxExtension` string
    - `bill_duration` string
    - `bridged_agent_name` string
    - `bridged_agent_pbxExtension` string
    - `call_end` string
    - `call_start` string
    - `caller_id` string
    - `cost` string
    - `country_name` string
    - `custom_fields` string
    - `desks` string
    - `destination` string
    - `duration` string
    - `hangup_cause` string
    - `id` string
    - `queue_alias` string
    - `queue_name` string
    - `recording_link` string
    - `type` string
    - `waiting_time` string

## Other responses

- `401`: Unauthorized

---

[API](https://skmtc.dev/commpeak/apis/pbx-stats-api.md) - [All operations](https://skmtc.dev/commpeak/apis/pbx-stats-api/llms.txt) - [OpenAPI document](https://skmtc.dev/commpeak/apis/pbx-stats-api/revisions/2f599eb625f8?raw)
