Call Control APIs
This section describes the Call Control API portion of the PortSIP PBX REST API and provides guidance for developers building 3rd applications. You can use this API to write agent applications that provide a variety of call-related features, from agent state management and call control to supervisor monitoring and call recording.
Authentication
Before calling the REST API to make the call, and control the call, we need to authenticate with the PortSIP PBX to obtain the access_token
. Please refer to the REST API.
Initiate a call directly
GET
/sessions/directly
Use the GET method to initiate a call directly. This API does not require an access_token
. Some hardware is not programmable and only allows pasting the URL to initiate the call. This API is designed for that purpose.
Example
URL Parameters
Name | Value |
---|---|
extension_number | An extension number |
password | The extension password is used by the PBX for authentication instead of the |
caller | The caller number, it's can be either an extension number or a PSTN number. (required) |
callee | The callee number, it's can be either an extension number or a PSTN number. (required) |
domain | The sip domain of the tenant. (required) |
send_sdp | Include the SDP in the INVITE message to initiate the call, true or false. (required) |
caller_display_name | Specify the display name for caller. (optional) |
trunk | This is a trunk name used to indicate that this call should be routed through the specified trunk. If the specified trunk is not available, the call will fail.(optional) |
rewrite_from | Specify when to send this call to the trunk. Use |
rewrite_pai | Specify when to send this call to the trunk. Use |
rewrite_rpi | Specify when to send this call to the trunk. Use |
user_data | Use this key to pass the additional information to the call. This information will be stored in the CDR, allowing you to easily track and analyze the call.(optional) |
additional_header | Specifies whether to add an additional SIP header (RFC 5373) to the INVITE SIP message. The possible values are:
(optional) |
header_direction | Specifies which party of the call should receive the additional_header. If the additional_header is not specified, this parameter will be ignored. The possible values are:
(optional) |
Response
Initiate a call
POST
/sessions
Use this REST API to initiate a call, the access_token
is required for this API.
Headers
Name | Value |
---|---|
Content-Type |
|
Authorization |
|
Body
Name | Type | Description |
---|---|---|
caller | string | The caller number, it's can be either an extension number or a PSTN number. (required) |
callee | string | The callee number, it's can be either an extension number or a PSTN number. (required) |
send_sdp | boolean | Include the SDP in the INVITE message to initiate the call, true or false. (required) |
caller_display_name | Specify the display name for caller. (optional) | |
trunk | string | This is a trunk name used to indicate that this call should be routed through the specified trunk. If the specified trunk is not available, the call will fail.(optional) |
rewrite_from | string | Age of the user |
rewrite_pai | string | Specify when to send this call to the trunk. Use |
rewrite_rpi | Specify when to send this call to the trunk. Use | |
user_data | string | Use this key to pass the additional information to the call. This information will be stored in the CDR, allowing you to easily track and analyze the call.(optional) |
additional_header | string enum | Specifies whether to add an additional SIP header (RFC 5373) to the INVITE SIP message. The possible values are:
(optional) |
additional_header | string enum. | Specifies which party of the call should receive the additional_header. If the additional_header is not specified, this parameter will be ignored. The possible values are:
(optional) |
Example of the body
Response
Hang up a call
POST
/sessions/{id}/destroy
Use this API to hang up a call by specifying the session ID. Pass the call session ID to the URL parameter ID.
Example
Headers
Name | Value |
---|---|
Content-Type |
|
Authorization |
|
Response
Hold a call
POST
/sessions/{id}/hold
Use this API to hold a call by specifying the session ID. Pass the call session ID to the URL parameter ID.
Example
Headers
Name | Value |
---|---|
Content-Type |
|
Authorization |
|
Body
Name | Type | Description |
---|---|---|
| string | The |
Response
Unhold a call
POST
/sessions/{id}/unhold
Use this API to unhold a call by specifying the session ID. Pass the call session ID to the URL parameter ID.
Example
Headers
Name | Value |
---|---|
Content-Type |
|
Authorization |
|
Body
Name | Type | Description |
---|---|---|
| string | The |
Response
Blind transfer a call
POST
/sessions/{id}/refer
Use this API to blind transfer a call by specifying the session ID. Pass the call session ID to the URL parameter ID.
Headers
Name | Value |
---|---|
Content-Type |
|
Authorization |
|
Body
Name | Type | Description |
---|---|---|
| string | To transfer a call to a specific |
| string | The target number to which the call will be transferred. (required) |
Example
1001 has established a call. Use the following body payload to blind transfer extension 1001 to the number 0033187691:
Response
Attended transfer a call
POST
/sessions/{id}/attended_refer
Use this API to attended transfer a call by specifying the session ID. Pass the current call session ID to the URL parameter ID.
Consider this scenario: Extension 1001 establishes calls with both 1002 and 1003. Now, use this API to perform an attended transfer, which will connect the call between 1002 and 1003, and extension 1001 will be disconnected from the calls.
Headers
Name | Value |
---|---|
Content-Type |
|
Authorization |
|
Body
Name | Type | Description |
---|---|---|
| string | To do attended transfer, you need to specify the |
session_1 | string | The session ID of the call which will be transffered. The PBX will match the call leg by both |
refer_to_1 | string | If the |
session_2 | string | The session ID of the call which will be transffered. The PBX will match the call leg by both |
refer_to_2 | string | If the |
Example
Extension 1001 establishes calls with both 1002 and 1003. Now, use this API to perform an attended transfer, which will connect the call between 1002 and 1003, and extension 1001 will be disconnected from the calls.
Response
Last updated