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

/api/sessions/directly?extension_number=1001&password=A1s2d3f4&caller=1001&callee=1002&domain=test.io&send_sdp=true

URL Parameters

Response

{
    "id": "884757570370146304"
}

Initiate a call

POST /sessions

Use this REST API to initiate a call, the access_token is required for this API.

Headers

Body

Example of the body

{
"caller" : "1001",
"callee" : "1002",
 "send_sdp" : true
}

Response

{
    "id": "884757570370146304"
}

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

/api/sessions/884761305393664000/destroy

Headers

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

/api/sessions/884761305393664000/hold

Headers

Body

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

/api/sessions/884761305393664000/unhold

Headers

Body

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

Body

Example

1001 has established a call. Use the following body payload to blind transfer extension 1001 to the number 0033187691:

{
"extension_number" : "1001",
"refer_to" : "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

Body

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.

{
"session_1" : "0",
"refer_to_1" : "1002",
"session_2" : "0",
"refer_to_2" : "1003"
}

Response

Last updated