- Overview
- Inbound PSTN
- Outbound PSTN
- Inbound SIP
- Static PIN
- End Call
- Cancel Call
- Agora Gateway IPs
- Twilio Configuration
These REST APIs allow developers to trigger inbound and outbound PSTN and SIP calls which then connect into an Agora channel enabling end-users to participate with their phone for the audio leg of the conference call.
Please contact us to provision your appid with this service. We will provide you with an authorization header to include in the API requests below.
In this scenario, the end-user dials a phone number displayed to them and enters the PIN when prompted. With the correct PIN, they are connected into the Agora channel.
- URL:
https://sipcm.agora.io/v1/api/pstn
- Method:
POST
{
"action":"inbound",
"appid":"fs9f52d9dcc1f406b93d97ff1f43c554f",
"token":"006d2776fef40dc864dc7a438e3b871IACGnkorQsr0iCpBmzNwKEdzKuAv1b1zRcMy0cOradw6mHN/il8AAAAAIgCQqbAFeaVzZgQAAQDw0oBmAgDw0oBmAwDw0oBmBADw0oBm",
"uid":"123",
"channel":"pstn",
"region":"AREA_CODE_NA",
}
-
appid
(string) the Agora project appid -
token
(string) [optional]: a generated Agora RTC access token -
uid
(string or int) [optional]: a user uid -
channel
(string): an Agora channel name -
region
(string): the user's region where they will likely be located and calling from. Values:AREA_CODE_NA: North America AREA_CODE_EU: Europe AREA_CODE_AS: Asia, excluding Mainland China AREA_CODE_JP: Japan AREA_CODE_IN: India AREA_CODE_CN: Mainland China
Status Code: 200 OK
Content Type: application/json
Body:
{
"did": "17377583411",
"display": "+1 (737) 758 3411",
"pin": "780592",
}
did
the phone number to dialdisplay
the phone number to dial in a more friendly display formatpin
the pin to enter when prompted
401 Unauthorized
500 Missing Parameters
503 No resource currently available
Direct Inward Dialing (DID) providers such as Twilio allow you to buy a phone number and have the calls forwarded to a SIP address. We will provide you with the SIP address to forward your calls to when we provision you on this service. You will also be able to customise the voice prompts played to your end-users.
In this scenario, the end-user receives a phone call which connects them directly to the channel when they answer.
- URL:
https://sipcm.agora.io/v1/api/pstn
- Method:
POST
{
"action":"outbound",
"appid":"fs9f52d9dcc1f406b93d97ff1f43c554f",
"token":"006d2776fef40dc864dc7a438e3b871IACGnkorQsr0iCpBmzNwKEdzKuAv1b1zRcMy0cOradw6mHN/il8AAAAAIgCQqbAFeaVzZgQAAQDw0oBmAgDw0oBmAwDw0oBmBADw0oBm",
"uid":"123",
"channel":"pstn",
"region":"AREA_CODE_NA",
"prompt":"true",
"to":"+447712886400#333",
"from":"+1800222333",
"timeout":"3600",
"sip":"acme.pstn.ashburn.twilio.com"
}
-
appid
(string) the Agora project appid -
token
(string) [optional]: a generated access token -
uid
(string or int) [optional]: a user uid -
channel
(string): an Agora channel name -
prompt
(string): play the callee a voice prompt and wait for them to press a digit. If set to "lazy" then any DTMF may be pressed. -
to
(string): the end-user's phone number to dial. You can optionally add a # followed by numbers which will be played as DTMF once the call connects. -
from
(string): the calling number displayed on the end-user's phone during ringing -
sip
(string): termination sip uri or leave blank if being routed by this service -
timeout
(string) [optional]: max duration for outbound call in seconds. Default 3600 seconds which is 1 hour. -
region
(string): the user's region where they will likely be located and calling from. Values:AREA_CODE_NA: North America AREA_CODE_EU: Europe AREA_CODE_AS: Asia, excluding Mainland China AREA_CODE_JP: Japan AREA_CODE_IN: India AREA_CODE_CN: Mainland China
Status Code: 200 OK
Content Type: application/json
Body:
{
"success": true,
"callid": "88877-55Asdd7-55Asdd",
"reason": "Busy",
}
success
If 'true' the call has connected and 'callid' will be included in the response. If 'false' the call has failed and 'reason' will be included in the responsecallid
[optional] This can be used to end the callreason
[optional] The call failed because the user was 'Busy' or the destination was 'Invalid'
401 Unauthorized
500 Missing Parameters
503 No resource currently available
If this API returns success 'true' the call has been connected. If it returns success false there will be a reason
In this scenario, an inbound SIP address is requested. When the SIP address is dialled, the call will be routed to the requested user/channel session.
- URL:
https://sipcm.agora.io/v1/api/pstn
- Method:
POST
{
"action":"inboundsip",
"appid":"fs9f52d9dcc1f406b93d97ff1f43c554f",
"token":"006d2776fef40dc864dc7a438e3b871IACGnkorQsr0iCpBmzNwKEdzKuAv1b1zRcMy0cOradw6mHN/il8AAAAAIgCQqbAFeaVzZgQAAQDw0oBmAgDw0oBmAwDw0oBmBADw0oBm",
"uid":"123",
"channel":"test",
"region":"AREA_CODE_NA",
}
-
appid
(string) the Agora project appid -
token
(string) [optional]: a generated access token -
uid
(string or int) [optional]: a user uid -
channel
(string): an Agora channel name -
region
(string): the user's region where they will likely be located and calling from. Values:AREA_CODE_NA: North America AREA_CODE_EU: Europe AREA_CODE_AS: Asia, excluding Mainland China AREA_CODE_JP: Japan AREA_CODE_IN: India AREA_CODE_CN: Mainland China
Status Code: 200 OK
Content Type: application/json
Body:
{
"sip": "sip:pstn_783410988998@2.4.6.7:5080",
}
sip
the sip address to dial to join the call
401 Unauthorized
500 Missing Parameters
503 No resource currently available
Using this API you can bridge an outbound call from your provider with an inbound sip address into Agora.
If provisioned, the service can call out to an external REST endpoint providing the number dialed and pin entered. The REST endpoint can choose to accept the PIN and return the details needed to join the user to the channel or error status 404 if PIN not valid.
- URL:
https://example.customer.com/api/pinlookup
- Method:
POST
{
"did":"17177440111",
"pin":"334455",
}
did
the phone number dialedpin
the pin entered
Status Code: 200 OK
Content Type: application/json
Body:
{
"token":"006d2776fef40dc864dc7a438e3b871IACGnkorQsr0iCpBmzNwKEdzKuAv1b1zRcMy0cOradw6mHN/il8AAAAAIgCQqbAFeaVzZgQAAQDw0oBmAgDw0oBmAwDw0oBmBADw0oBm",
"uid":"123",
"channel":"test",
"appid":"fs9f52d9dcc1f406b93d97ff1f43c554f",
}
token
(string): a generated access token OR the appid if tokens are not enableduid
(string or int): a user uidchannel
(string): an Agora channel nameappid
(string): the Agora appid for your project
404 Not Found
This API allows you to give your users a pin that will not expire.
Use the callid returned by the outbound call API to terminate an outbound call.
- URL:
https://sipcm.agora.io/v1/api/pstn
- Method:
POST
{
"action":"endcall",
"appid":"fs9f52d9dcc1f406b93d97ff1f43c554f",
"callid":"f577605c-eb3a-4efe-af1b-ee66d5297569",
}
appid
(string) the Agora project appidcallid
(string) the call id of the ongoing call
Status Code: 200 OK
Content Type: application/json
Body:
{
"success":true
}
404 Not Found
This API allows you to stop an outbound call.
Pass the details returned by an Inbound PSTN or Inbound SIP API call request to cancel it. If the call is in progress it will be stopped.
- URL:
https://sipcm.agora.io/v1/api/pstn
- Method:
POST
{
"action":"cancelcall",
"appid":"fs9f52d9dcc1f406b93d97ff1f43c554f",
"sip":"sip:pstn_783410988998@2.4.6.7:5080",
"did":"17377583411",
"pin":"445566",
}
appid
(string) the Agora project appidsip
(string) [optional] the sip address returned by inboundsip apidid
(string) [optional] the did returned by inbound apipin
(string) [optional] the pin returned by inbound api
Status Code: 200 OK
Content Type: application/json
Body:
{
"success":true
}
404 Not Found
This API allows you to cancel a previous call setup request.
Please add the following IP addresses to any Access Control Lists which restrict outbound calling by IP.
3.9.67.24
52.3.185.227
52.9.29.181
34.233.232.16
Please point inbound calls at one of these IPs with the other being a failover.
52.3.185.227
52.9.29.181
Configure your own Twilio account to work with the Inbound and Outbound calling APIs above.