# 通用api - 获取通话记录接口

#### 接口说明
客户主动拉取通话记录列表的接口。

#### 请求方式
POST，form-data格式

#### 请求参数

| 参数名          | 类型     | 是否必须 | 说明                                                                |
| :----------- | :----- | :--- | :---------------------------------------------------------------- |
| service      | string | 是    | App.Sip\_Cdr.GetBill                                              |
| token        | string | 是    | 通过授权接口获取的token                                                    |
| starttime    | string | 是    | (拔打)起始时间，格式：yyyy-mm-dd hh\:mm\:ss                                 |
| endtime      | string | 是    | (拔打)结束时间，格式：yyyy-mm-dd hh\:mm\:ss                                 |
| syncflag     | int    | 是    | 获取记录类型:1、获取未查询过的记录(默认)；2、获取已查询过的记录；3、获取全部记录。                      |
| direction    | int    | 是    | 呼叫方向：1、呼入； 2、呼出；3、全部（默认）。                                         |
| callmethod   | int    | 是    | 呼叫方法：0、不限；1、分机互拨；2、分机直拨（手拨）；3、API呼叫（默认）；4、API双呼；5、预测式外呼；6、IVR/群呼。 |
| currentpage  | int    | 是    | 页数，默认：1                                                           |
| itemsperpage | int    | 是    | 每页数量，默认：10，最小：1；最大：1000                                           |
| extnumber    | string | 是    | 分机号，多个分机号用英文逗号隔开，传空值时为全部                                          |
| destnumber   | string | 是    | 呼叫的目标号码，传空值时为全部                                                   |
| userid       | string | 是    | 自定义数据(员工ID)，可为空值                                                  |
| memberid     | string | 是    | 自定义数据(会员ID)，可为空值                                                  |
| ext   | string | 否    | 自定义数据(扩展参数)                                                        |
| customuuid   | string | 否    | 自定义数据(客户ID)                                                       |

#### 接口请求示例（PHP）

```
<?php
    $apiUrl = 'http://127.0.0.1:8080';
    $postFields = [
        'service'   => 'App.Sip_Cdr.GetBill',
        'token'     => 'ABCDEFG',
        'starttime'  => '2019-01-12 00:00:00',
        'endtime'    => '2020-12-12 00:00:00',
        'direction'  => 3
        'syncflag'   => 3,
        'callmethod' => 0,
        'currentpage'  => 1,
        'itemsperpage'  => 10,
    ];
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $apiUrl);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $postFields);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $response = curl_exec($curl);
    $curlError = curl_error($curl);
    curl_close($curl);
    var_dump($response);
?>

```

#### 返回数据结构示例

```
{
    "ret": 200,
    "data": {
        "status": 0,
        "desc": "获取成功",
        "result": {
            "totalitems": 8151,
            "currentpage": 1,
            "itemsperpage": 10,
            "bills": [
                {
                    "id": 263056202,
                    "companycode": "9513923",
                    "direction": "callout",
                    "type": "callout",
                    "callmethod": 6,
                    "starttime": "2025-10-16 17:31:13",
                    "answertime": "",
                    "endtime": "2025-10-16 17:31:21",
                    "duration": 8,
                    "billsec": 0,
                    "userid": "0",
                    "memberid": "0",
                    "chengshudu": "0",
                    "ext": "0",
                    "disnumber": "219513923001",
                    "destnumber": "81351111451",
                    "extnumber": "",
                    "recordfilename": "",
                    "downloadip": "",
                    "hangupdirection": 10040,
                    "hangupcause": 10020,
                    "uuid": "db4a44cc-aa72-11f0-ad78-1d7ff0749d07",
                    "userkey": "",
                    "customuuid": "76c33d997640d36b033d43b1d2d3964e",
                    "taskid": "",
                    "round": 0,
                    "recordurl": ""
                }
            ]
        },
        "reqtime": 1581502410,
        "rsptime": 1581502410
    },
    "msg": ""
}

```

#### 返回参数说明

| 参数名               | 类型     | 说明          |
| :---------------- | :----- | :---------- |
| result            | objest | 返回的结果集      |
| —totalitems       | int    | 记录总数        |
| —currentpage      | int    | 当前页码        |
| —itemsperpage     | int    | 每页数量        |
| —bills            | array  | 记录数组        |
| ——id              | int    | 记录id        |
| ——extnumber       | string | 分机号         |
| ——destnumber      | string | 目标号码        |
| ——disnumber       | string | 显示号码        |
| ——starttime       | string | 呼叫时间        |
| ——answertime      | string | 应答时间        |
| ——endtime         | string | 通话结束时间      |
| ——duration        | int    | 呼叫等待时长      |
| ——billsec         | int    | 通话时长        |
| ——direction       | string | 呼叫方向        |
| ——callmethod      | int    | 呼叫方式        |
| ——userid          | string | 自定义参数(用户id) |
| ——memberid        | string | 自定义参数(会员id) |
| ——chengshudu      | string | 自定义参数(成熟度)  |
| ——ext             | string | 自定义参数(扩展参数)  |
| ——customuuid      | string | 自定义参数(客户id) |
| ——recordfilename  | string | 通话记录文件名     |
| ——downloadip      | string | 下载ip        |
| ——hangupdirection | int    | 挂断方向        |
| ——hangupcause     | int    | 挂断原因        |
| ——userkey         | string | 用户按键        |
| ——customuuid      | string | 自定义参数      |
| ——taskid          | string | 任务id        |
| ——round           | string | 任务轮次      |
| ——recordurl       | string | 录音下载地址   |

#### Postman请求示例

[![c65b2c52d15ac1a4f5775e9b19f9cfe5.jpg](https://document.infin8linx.com/uploads/images/gallery/2025-08/scaled-1680-/c65b2c52d15ac1a4f5775e9b19f9cfe5.jpg)](https://document.infin8linx.com/uploads/images/gallery/2025-08/c65b2c52d15ac1a4f5775e9b19f9cfe5.jpg)