> For the complete documentation index, see [llms.txt](https://docs.voicecloud.my/pbx/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.voicecloud.my/pbx/apis-guide/document.md).

# Document

CRM wants to connect to the API and needs the URLs to receive data in URL or JSON format

**Below are some example URLs for reference**<br>

Contents

* <mark style="color:blue;">**Incoming Call**</mark>
* <mark style="color:blue;">**End Call**</mark>
* [<mark style="color:blue;">**Call Information**</mark>](#user-content-fn-1)[^1]
* <mark style="color:blue;">**Missed Call**</mark>
* <mark style="color:blue;">**Agent No Answer**</mark>
* <mark style="color:blue;">**Outgoing Call**</mark>
* <mark style="color:blue;">**Update Real-Time Agent Status**</mark>
* <mark style="color:blue;">**Click2Call Event**</mark>
* <mark style="color:blue;">**Check Extension Status**</mark>
* <mark style="color:blue;">**Spy Call Event**</mark>
* <mark style="color:blue;">**Event to Get Extension List in Queue**</mark>
* <mark style="color:blue;">**Change Extension Status in Queue**</mark>

### <mark style="color:blue;">**Incoming Call**</mark>

When there is an incoming call to the PBX, it will ring to the employee’s phone (e.g., extension 101):

{% code overflow="wrap" %}

```
https://{CRM_URL}/api/callcenter/call_in?phone=0938363739&queue=999&extension=101&callid=5e012a75-121b-4c10-bdb4-c4b235b6a677&event=ANSWER&did=19002028
```

{% endcode %}

With paramete&#x72;**:**

* `{CRM_URL}`**:** Provided by CRM
* `phone`**:** The incoming phone number
* `queue`**:** The queue of the internal number (if applicable)
* `extension`**:** The internal number of the agent
* `callid`**:** The call ID
* `event`**:** The call status (ANSWER, RINGING)
* `did`**:** The PBX phone number

### [<mark style="color:blue;">**End Call**</mark>](#user-content-fn-1)[^1]

This is the event that informs the CRM that the call has ended:

{% code overflow="wrap" %}

```
https://{CRM_URL}/api/callcenter/hangup?callid=5e012a75-121b-4c10-bdb4-c4b235b6a677
```

{% endcode %}

With paramete&#x72;**:**

* `{CRM_URL}`**:** Provided by CRM
* `callid`**:** The call ID

### <mark style="color:blue;">**Call Information**</mark>

When the call ends, the PBX can return detailed call information:

{% code overflow="wrap" %}

```
https://{CRM_URL}/api/callcenter/calldata?callid=5e012a75-121b-4c10-bdb4-c4b235b6a677&calldate=2024-03-01 13:15:40&duration=50&billsec=37&status=ANSWER&did=19002028&extension=101&phone=0938363739&direction=Inbound&recordingfile=https://portal.voicecloud.vn/play_audio/data/5e012a75-121b-4c10-bdb4-c4b235b6a677
```

{% endcode %}

With paramete&#x72;**:**

* `{CRM_URL}`**:** Provided by CRM
* `callid`**:** The call ID
* `calldate`**:** The start time of the call (format: y-m-d hms)
* `duration`**:** The total call duration
* `billsec`**:** The duration of the talk time
* `status`**:** The call status (ANSWER, BUSY, etc.)
* `did`**:** The PBX phone number
* `extension`**:** The agent’s internal number
* `phone`**:** The customer’s phone number
* `direction`**:** The call direction (Inbound or Outbound)
* `recordingfile`**:** The path to the call recording file

### <mark style="color:blue;">**Missed Call**</mark>

{% code overflow="wrap" %}

```
https://{CRM_URL}/api/callcenter/calldata?callid=5e012a75-121b-4c10-bdb4-c4b235b6a677&holdtime=60&status=ABANDON&queue=999&phone=0938363739
```

{% endcode %}

With paramete&#x72;**:**

* `{CRM_URL}`**:** Provided by CRM
* `callid`**:** The call ID
* `holdtime`**:** The customer's hold time (in seconds)
* `status`**:** The call status (ABANDON)
* `queue`**:** The name of the queue
* `phone`**:** The customer's phone number

### <mark style="color:blue;">**Agent No Answer**</mark>

{% code overflow="wrap" %}

```
https://{CRM_URL}/api/callcenter/calldata?callid=5e012a75-121b-4c10-bdb4-c4b235b6a677&status=NOANSWER&queue=999&extension=101&phone=0938363739
```

{% endcode %}

With paramete&#x72;**:**

* `{CRM_URL}`**:** Provided by CRM
* `callid`**:** The call ID
* `status`**:** The call status (NOANSWER)
* `queue`**:** The name of the queue
* `extension`**:** The agent’s internal number
* `phone`**:** The customer’s phone number

### <mark style="color:blue;">**Outgoing Call**</mark>

Synchronize data to inform the CRM of an outgoing call from the PBX:

{% code overflow="wrap" %}

```
https://{CRM_URL}/api/callcenter/init?extension=101&phone=0938363739&callid=5e012a75-121b-4c10-bdb4-c4b235b6a677&event=ANSWER
```

{% endcode %}

With paramete&#x72;**:**

* `{CRM_URL}`**:** Provided by CRM
* `extension`**:** Agent's internal number
* `phone`**:** Outgoing phone number
* `callid`**:** Call ID
* `event`**:** Call status (ANSWER, RINGING)

### <mark style="color:blue;">**Update Real-Time Status of Agent**</mark>

{% code overflow="wrap" %}

```
https://{CRM_URL}/api/Agent/ChangeStatus?extension=101&status=talk
```

{% endcode %}

With paramete&#x72;**:**

`{CRM_URL}`**:** Provided by CRM\
`extension`**:** Agent's internal number\
`status`**:** Agent's status (\*)

**(\*) Extension Status Values**

| **Values** | **Describe**               |
| ---------- | -------------------------- |
| off        | Agent (phone) not register |
| on         | Agent (phone) available    |
| pause      | Agent (phone) pause        |
| ring       | Agent (phone) ringring     |
| talk       | Agent (phone) talking      |

### <mark style="color:blue;">**Click2call Event**</mark>

CRM runs this URL with the GET method, using URL-encoded data:

{% code overflow="wrap" %}

```
https://{PBX_URL}/api/CallControl/dial/from_number/{extension}/to_number/{phone}/key/{key}/domain/{domain}
```

{% endcode %}

With paramete&#x72;**:**

* `{PBX_URL}`: Provided by the PBX system.
* `api/CallControl/dial`: API method name for making calls in the system.
* `extension`: Internal extension number to call (e.g., 101).
* `phone`: Customer phone number to call (e.g., 0938363739).
* `key`: Company key provided by the PBX system.
* `domain`: Company domain name provided by the PBX system.

### &#x20;<mark style="color:blue;">Check the status of the extension</mark>

CRM runs this path using POST method with JSON data type:

{% code overflow="wrap" %}

```
https://{PBX_URL}/api/Agent/status/format/json
```

{% endcode %}

—-

```javascript
Data :
{
  "key" : "98589afb123863cf4d5cd4ec2c41072",
  "list" :
   [
    {"ext" : "100"},
    {"ext" : "200"}
   ]
}
```

With paramete&#x72;**:**

* `{PBX_URL}`: Provided by the PBX system.
* `api/Agent/status/format/json`: The API method name of the system.
* `key`: The company's key provided by the PBX system.
* `ext`: The extension to be checked.

### <mark style="color:blue;">**SPY Call Event**</mark>

CRM runs this path using POST method with JSON data type:

{% code overflow="wrap" %}

```
https://{PBX_URL}/api/Agent/spy/format/json
```

{% endcode %}

—-

```javascript
Data :
{
 "key" : "98589afb123863cf4d5cd4ec2c41072",
 "src" : "100",
 "dst" : "101",
 "mode" : "whisper"
}
```

With paramete&#x72;**:**

* `{PBX_URL}`: Provided by the PBX system.
* `api/Agent/spy/format/json`: The API method name of the system.
* `key`: The company's key provided by the PBX system.
* `src`: The extension of the person initiating the spy call.
* `dst`: The extension of the person being listened to.
* `mode`:
  * `whisper`: listen only
  * `threeway`: talk to both
  * `caller`: talk to the caller
  * `callee`: talk to the callee

### <mark style="color:blue;">**Event to Retrieve Extension List in Queue**</mark>

CRM runs this path using POST method with JSON data type:

{% code overflow="wrap" %}

```
https://{PBX_URL}/api/Agent/all_members/format/json
```

{% endcode %}

—-

{% code overflow="wrap" %}

```javascript
Data :
{
 "key" : "98589afb123863cf4d5cd4ec2c41072"
}
```

{% endcode %}

With paramete&#x72;**:**

* `{PBX_URL}`: Provided by the PBX system.
* `api/Agent/all_members/format/json`: The API method name of the system.
* `key`: The company's key provided by the PBX system.

### <mark style="color:blue;">**Change Extension Status in Queue**</mark>

CRM runs this path using POST method with JSON data type:

{% code overflow="wrap" %}

```
https://{PBX_URL}/api/Agent/update_status
```

{% endcode %}

—

{% code overflow="wrap" %}

```javascript
Data :
{
 "key" : "98589afb123863cf4d5cd4ec2c41072",
 "exten" : "100",
 "status" : "0"
}
```

{% endcode %}

With paramete&#x72;**:**

* `{PBX_URL}`: Provided by the PBX system.
* `api/Agent/update_status`: The API method name of the system.
* `key`: The company's key provided by the PBX system.
* `exten`: The extension number to be changed.
* `status`: The status of the extension. (0: unpaused, 1: paused)

### <mark style="color:blue;">**Retrieve Call Data**</mark>

CRM runs this path using POST method with JSON data type:

{% code overflow="wrap" %}

```
https://{PBX_URL}/internal/Reports/cdr/format/json
```

{% endcode %}

—

{% code overflow="wrap" %}

```javascript
Data :
{
 "key" : "98589afb123863cf4d5cd4ec2c41072",
 "callid" : "fb80cc79-e179-1234-92d7-04748b9bb475",
 "startdate" : "2022-09-23",
 "enddate" : "2022-09-23"
}
```

{% endcode %}

With paramete&#x72;**:**

* `{PBX_URL}`: Provided by the PBX system.
* `internal/Reports/cdr/format/json`: The API method name of the system.
* `key`: The company's key provided by the PBX system.
* `callid`: The call ID.
* `startdate – enddate`: The time range. (Format: YYYY-MM-DD)

[^1]:
