# Danh sách API (API List)

### Lấy token chứng thực ( **Get Authentication Token)** <a href="#lay-token-chung-thuc" id="lay-token-chung-thuc"></a>

Sử dụng cho việc nhận websocket về các signal của cuộc gọi

**URL**: /oapi/v1/voice/auth\_token

**METHOD**: POST

**Content Type**: application/json‌

**Headers**:

| Thuộc tính      | Kiểu dữ liệu | Giá trị                   |
| --------------- | ------------ | ------------------------- |
| x-auth-app-id   | String       | Định danh 3rd party       |
| x-auth-app-hash | String       | sha256(appId + appSecret) |

**Kết quả**:

| Status | Kết quả                                           |
| ------ | ------------------------------------------------- |
| 200    | { value: \<auth\_token>, expire: \<expire time> } |

### Click to call[​](https://developers.antbuddy.com/ring/danh-sach-api#click-to-call) <a href="#click-to-call" id="click-to-call"></a>

**URL**: /oapi/v1/call/click-to-call/:number

**METHOD**: POST

**Content Type**: application/json‌

**Headers**:

| Thuộc tính      | Kiểu dữ liệu | Giá trị                   |
| --------------- | ------------ | ------------------------- |
| x-auth-app-id   | String       | Định danh 3rd party       |
| x-auth-app-hash | String       | sha256(appId + appSecret) |

**Tham số**:

| Thuộc tính  | Kiểu dữ liệu | Giá trị                                  |
| ----------- | ------------ | ---------------------------------------- |
| sipUser     | String       | Device name thực hiện việc click to call |
| sipPassword | String       | Mật khẩu                                 |

**Kết quả**:‌

| Status | Kết quả                                 |
| ------ | --------------------------------------- |
| 200    | Device online, click to call thành công |
| 400    | Device offline, click to call thất bại  |

**note**

Để nhận được cuộc gọi, device sip cần register lên hệ thống, mã lỗi 400 là do device chưa register đến hệ thống

### Lấy danh sách cuộc gọi[​](https://developers.antbuddy.com/ring/danh-sach-api#l%E1%BA%A5y-danh-s%C3%A1ch-cu%E1%BB%99c-g%E1%BB%8Di) <a href="#lay-danh-sach-cuoc-goi" id="lay-danh-sach-cuoc-goi"></a>

**URL**: <https://openapi.antbuddy.com/oapi/v1/call/histories>

**METHOD**: GET‌

**Content Type**: application/json‌

**Tham số**:

| Thuộc tính    | Kiểu dữ liệu | Giá trị                                                      |
| ------------- | ------------ | ------------------------------------------------------------ |
| appId         | String       | Định danh 3rd party                                          |
| created\_from | String       | Ngày bắt đầu                                                 |
| created\_to   | String       | Ngày kết thúc                                                |
| limit         | Number       | Giới hạn số record trên 1 trang. Mặc định 20                 |
| page          | Number       | Trang hiện tại, mặc định 1                                   |
| hash          | String       | sha256(created\_from+created\_to+limit+page+appID+appSecret) |

**Trong đó**:‌

* Thời gian filter tối đa là 31 ngày
* Limit mặc định là 20 record, tối đa 100
* Page mặc định là 1

**Kết quả**:

<table><thead><tr><th>Thuộc tính</th><th>Ví dụ</th><th>Mô tả</th></tr></thead><tbody><tr><td>caller</td><td><pre><code>{
  number:"01693608879",
  type:"realnumber"
}
</code></pre></td><td>Mô tả người gọi. Đối với <strong>type=user</strong>, có thêm trường username để định danh user.</td></tr><tr><td>callee</td><td><pre><code>{
  number:"thutranhtkbee",
  type:"user",
  username:"thutran"
}
</code></pre></td><td>Mô tả người nhận. Đối với <strong>type=user</strong>, có thêm trường username để định danh user.</td></tr><tr><td>class</td><td>trunking</td><td><strong>one_one</strong>: gọi nội bộ. <strong>trunking</strong>: gọi ra hoặc gọi vào hệ thống</td></tr><tr><td>did_number</td><td>02873019555</td><td>Số DID của công ty. Null: nếu gọi nội bộ hoặc gọi ra</td></tr><tr><td>direction</td><td>from_ab</td><td><strong>from_ab</strong>: gọi ra. to_ab: gọi vào</td></tr><tr><td>status_detail</td><td>SUCCESS</td><td><strong>IVR</strong>: Cuộc gọi vào / ra đến hệ thống đầu cuối nhưng người nhận chưa bắt máy. <strong>SUCCESS</strong>: Cuộc gọi thành công. <strong>CANCELLED</strong>: Thực hiện cuộc gọi ra và gác máy trước khi người nhận nhận cuộc gọi. <strong>BUSY</strong>: Thực hiện cuộc gọi ra nhưng đầu nhận bận máy. <strong>UNSUCCESS</strong>: Các lỗi khác</td></tr><tr><td>duration_seconds</td><td>50</td><td>Thời gian cuộc gọi ( tính bằng giây)</td></tr><tr><td>unix_timestamp</td><td>1519639917</td><td>Thời điểm xảy ra cuộc gọi. Tính theo unix timestamp</td></tr><tr><td>billing_seconds</td><td>43</td><td>Thời gian đàm thoại của cuộc gọi ( tính bằng giây)</td></tr><tr><td>recording</td><td>call_recording_dl5m5j5hfh4n8njj1oor.mp3</td><td>File ghi âm. Trường hợp không có ghi âm thì trường này rỗng.</td></tr></tbody></table>

**Giới hạn**:‌ Chỉ cho phép lấy lịch sử cuộc gọi tối đa 31 ngày‌

### Lấy file ghi âm[​](https://developers.antbuddy.com/ring/danh-sach-api#l%E1%BA%A5y-file-ghi-%C3%A2m) <a href="#lay-file-ghi-am" id="lay-file-ghi-am"></a>

**URL**: <https://openapi.antbuddy.com/oapi/v1/call/play_recording>

**METHOD**: GET‌

**Content Type**: application/json‌

**Tham số**:

| Tham số | Kiểu dữ liệu | Mô tả                           |
| ------- | ------------ | ------------------------------- |
| appId   | String       | Định danh 3rd party             |
| media   | String       | Tên file recording              |
| hash    | String       | sha256(appId +media+ appSecret) |

**Kết quả**:‌

Đường dẫn URL của file media

| Thuộc tính | Ví dụ                                                                                                                                                                                                                                                                                                                                                                                                                                 | Mô tả                 |
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- |
| media      | ​[https://abs1.antbuddy.com/nkrecord/call\_recording\_F5879958-1A1211E8-A55AA457-72574952%40172.16.0.204.mp3?AWSAccessKeyId=E7IPYE4LN28Y4I6T4400\&Expires=1519640615\&Signature=wXNENYxr0OJR8vA26kvOOwsttzU%3D​](https://abs1.antbuddy.com/nkrecord/call_recording_F5879958-1A1211E8-A55AA457-72574952%40172.16.0.204.mp3?AWSAccessKeyId=E7IPYE4LN28Y4I6T4400\&Expires=1519640615\&Signature=wXNENYxr0OJR8vA26kvOOwsttzU%3D%E2%80%8B) | Đường dẫn file ghi âm |

*(*

*Used for receiving websocket signals for call events.Comment*

* ***URL**: `/oapi/v1/voice/auth_token`Comment*
* ***METHOD**: POSTComment*
* ***Content Type**: `application/json`Comment*

*Comment**Headers**:Comment*

| Property        | Data Type | Value                     |
| --------------- | --------- | ------------------------- |
| x-auth-app-id   | String    | 3rd party identifier      |
| x-auth-app-hash | String    | sha256(appId + appSecret) |

*Comment**Response**:Comment*

| Status | Result                                           |
| ------ | ------------------------------------------------ |
| 200    | `{ value: <auth_token>, expire: <expire time> }` |

*Comment*

***

*Comment**2. Click to Call**Comment*

* ***URL**: `/oapi/v1/call/click-to-call/:number`Comment*
* ***METHOD**: POSTComment*
* ***Content Type**: `application/json`Comment*

*Comment**Headers**:Comment*

| Property        | Data Type | Value                     |
| --------------- | --------- | ------------------------- |
| x-auth-app-id   | String    | 3rd party identifier      |
| x-auth-app-hash | String    | sha256(appId + appSecret) |

*Comment**Parameters**:Comment*

| Property    | Data Type | Value                         |
| ----------- | --------- | ----------------------------- |
| sipUser     | String    | Device name for click to call |
| sipPassword | String    | Password                      |

***Response**:*

| Status | Result                                  |
| ------ | --------------------------------------- |
| 200    | Device online, click to call successful |
| 400    | Device offline, click to call failed    |

***Note**: To receive the call, the SIP device must be registered on the system. Error 400 occurs when the device is not registered.*

***

***3. Get Call History***

* ***URL**:* [*https://openapi.antbuddy.com/oapi/v1/call/histories*](https://openapi.antbuddy.com/oapi/v1/call/histories)
* ***METHOD**: GET*
* ***Content Type**: `application/json`*

***Parameters**:*

| Property      | Data Type | Value                                                        |
| ------------- | --------- | ------------------------------------------------------------ |
| appId         | String    | 3rd party identifier                                         |
| created\_from | String    | Start date                                                   |
| created\_to   | String    | End date                                                     |
| limit         | Number    | Limit of records per page, default 20                        |
| page          | Number    | Current page, default 1                                      |
| hash          | String    | sha256(created\_from+created\_to+limit+page+appID+appSecret) |

***Notes**:*

* *Maximum time filter is 31 days.*
* *Default limit is 20 records, maximum 100.*
* *Default page is 1.*

***Response**:*

| Property          | Example                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | Description                                                                                |
| ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| caller            | `{number: "01693608879", type: "realnumber"}`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | Caller details, with username if type=user                                                 |
| callee            | `{number: "thutranhtkbee", type: "user", username: "thutran"}`                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | Callee details, with username if type=user                                                 |
| class             | `trunking`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | Call type: `one_one` for internal, `trunking` for inbound/outbound calls                   |
| did\_number       | `02873019555`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | DID number for the company. Null if internal or outbound                                   |
| direction         | `from_ab`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | `from_ab` for outbound calls, `to_ab` for inbound                                          |
| status\_detail    | `SUCCESS`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | Call status: `IVR` (system call not answered), `SUCCESS`, `CANCELLED`, `BUSY`, `UNSUCCESS` |
| duration\_seconds | 50                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | Duration of the call in seconds                                                            |
| unix\_timestamp   | 1519639917                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | Call timestamp in Unix format                                                              |
| billing\_seconds  | 43                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | Talk time for the call in seconds                                                          |
| recording         | `call_recording_dl5m5j5hfh4n8njj1oor.mp3`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | File path for the recording, empty if no recording                                         |
| queue\_stat       | `[ { "_id": "65fa9d8c1b2e4a7c9e001234", "call_id": "call_1707286400@pbx.antbuddy", "queue_id": "queue_support_01", "__v": 0, "org": "org_625e200826e8844fa2cd673c", "wait_time": 12, "caller_id_number": "0987654321", "caller_id_name": "0987654321", "status": "processed", "entered_timestamp": 1707286388, "handled_timestamp": 1707286400, "processed_timestamp": 1707286520, "agent_id": "agent_support01", "username": "support01", "talk_time": 95, "hung_up_by": "agent", "end_call_reason": "agent_hungup", "misses": [] } ]` | When there is no queue: \[]                                                                |

***Limit**: The call history can only be retrieved for a maximum of 31 days.*

***

***4. Get Call Recording***

* ***URL**:* [*https://openapi.antbuddy.com/oapi/v1/call/play\_recording*](https://openapi.antbuddy.com/oapi/v1/call/play_recording)
* ***METHOD**: GET*
* ***Content Type**: `application/json`*

***Parameters**:*

| Property | Data Type | Description                       |
| -------- | --------- | --------------------------------- |
| appId    | String    | 3rd party identifier              |
| media    | String    | Recording file name               |
| hash     | String    | sha256(appId + media + appSecret) |

***Response**:*

| Property | Example                                                                                                                                                                                                    | Description                    |
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ |
| media    | `https://abs1.antbuddy.com/nkrecord/call_recording_F5879958-1A1211E8-A55AA457-72574952%40172.16.0.204.mp3?AWSAccessKeyId=E7IPYE4LN28Y4I6T4400&Expires=1519640615&Signature=wXNENYxr0OJR8vA26kvOOwsttzU%3D` | URL link to the recording file |

***

***5. Get Dashboard***

* ***URL**:* [*https://openapi.antbuddy.com/oapi/v1/call/dashboard*](https://openapi.antbuddy.com/oapi/v1/call/play_recording)
* ***METHOD**: GET*
* ***Content Type**: `application/json`*

***Parameters:***

| Property | Data Type | Description                          |
| -------- | --------- | ------------------------------------ |
| appId    | String    | 3rd party identifier                 |
| domain   | String    | Recording file name                  |
| email    | String    | Email thuộc công ty                  |
| hash     | String    | sha256(appID+domain+email+appSecret) |

***Response***

| Property | Example                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | Description                                                                                |
| -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| agent    | `{ "ready": 2, "logged_out": 1, "wrapup": 0, "logged_in": 3, "connected": 0, "paused": 0, "status_details": [ { "timestamp": 63936806933, "status": "ready", "id": "df67983ccdeee7d834e8f5d345db1f45::63936806933", "agent_id": "df67983ccdeee7d834e8f5d345db1fe5", "start_idle_time": 63936806933, "idle_time": 765140, "waiting_calls": [], "unix_timestamp": 1769587733, "username": "nguyenvana", "name": "Nguyễn Văn A" }, ] }`                                                                                                                | The number of employees by status and status details; if not in the list, then logged out. |
| queue    | <p>  <code>{</code></p><p>    <code>"abandoned": 0,</code></p><p>    <code>"abandoned\_detail": {},</code></p><p>    <code>"offered": 12,</code></p><p>    <code>"handled": 12,</code></p><p>    <code>"avg\_waiting": 6,</code></p><p>    <code>"max\_waiting": 15,</code></p><p>    <code>"avg\_talking": 180,</code></p><p>    <code>"abandoned\_calls": 0,</code></p><p>    <code>"received": 12,</code></p><p>    <code>"status\_details": \[],</code></p><p>    <code>"waiting\_call\_logs": \[]</code></p><p>  <code>}</code></p><p><br></p> | Total calls (calls that have been added to the group)                                      |

***

***6. Get queue(Group)***

* ***URL**:* [*https://openapi.antbuddy.com/oapi/v1/queues*](https://openapi.antbuddy.com/oapi/v1/queues)
* ***METHOD**: GET*
* ***Content Type**: `application/json`*

***Parameters***

| Property | Data Type | Description                          |
| -------- | --------- | ------------------------------------ |
| appId    | String    | 3rd party identifier                 |
| domain   | String    | Recording file name                  |
| email    | String    | Email thuộc công ty                  |
| hash     | String    | sha256(appID+domain+email+appSecret) |

***Response***

| Property | Example                                                                                                                                             | Description         |
| -------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- |
| name     | `"Staging Queue"`                                                                                                                                   | queue name          |
| agents   | <p><code>\[               "Eab4ebf976c53d22d393e94f3ed085dc",</code></p><p><code>"da80ca52e8ab9d6b26b7f2eb960545ae"</code></p><p><code>]</code></p> | Agents in the queue |

***

***7. Get agents***

* ***URL**:* [*https://openapi.antbuddy.com/oapi/v1/agents*](https://openapi.antbuddy.com/oapi/v1/agents)
* ***METHOD**: GET*
* ***Content Type**: `application/json`*

***Parameters***

| Property | Data Type | Description                          |
| -------- | --------- | ------------------------------------ |
| appId    | String    | 3rd party identifier                 |
| domain   | String    | Recording file name                  |
| email    | String    | Email thuộc công ty                  |
| hash     | String    | sha256(appID+domain+email+appSecret) |

***Response***

<table data-header-hidden><thead><tr><th></th><th width="240"></th><th></th></tr></thead><tbody><tr><td>Property</td><td>Example</td><td>Description</td></tr><tr><td>anttel.userId</td><td><code>“eab4ebf976c53d22d393e94f3ed085dc“</code></td><td>Id agent</td></tr><tr><td>username</td><td><code>"userstaging2"</code></td><td>user name</td></tr><tr><td>name</td><td><code>"User Staging 2"</code></td><td>agent name</td></tr><tr><td>ext</td><td><code>[‘8000’, ‘8001’]</code></td><td>Internal number</td></tr></tbody></table>
