The SIP Trunks endpoint has operations that allow you to create, view, update, and remove SIP trunks.
Elastic SIP Trunk API (1.0.0)
This document provides a detailed user guide and reference documentation on the Sinch Elastic SIP Trunk API. For information on how to authenticate API requests, please check the Authentication section.
HTTP Basic authentication works on all Sinch REST APIs. Basic auth is often the preferred option for testing because it is simple and easy to use.
Basic authentication is intended for test purposes only, and should only be used for experimenting with APIs and building prototypes. API calls using basic authentication are heavily rate limited, and these limits may change at any time without warning. Production systems should use OAuth access tokens instead.
Basic authentication is sent in the authorization header with each call.
No matter the programming language, there are three main components for successful basic authentication in a request:
- The designation of authorization type, which is
basic - The
username, which in Sinch's case isYOUR_Key_ID, corresponding to your project - The
password, which isYOUR_Key_Secret, again, corresponding to the project
You can view and manage your API credentials here.
Check out this article for a walk-through on finding your key and secret.
To use basic auth in an API call, do the following:
First, create a new access key in the Sinch Build Dashboard by clicking Create Access Key.
Copy your project ID, key ID, and key secret.
Important!Keep your key secret somewhere safe as it is only viewable upon initial project creation. The project ID and key ID are always readily available in the Sinch Build Dashboard. If you misplace your key secret, simply generate a new key!
Use your key ID as the username (sometimes called the
client_id) and your key secret as the password (can be referred to as theclient_secret) in every call made to a Sinch API.
Achieve more secure API authentication with OAuth 2.0 access tokens.
Access tokens are short lived. Typically, they will only last one hour. This is done to keep your data (and ours) safer.
In exchanging credentials, you'll get a long string called an access token. This access token will serve as your bearer token in the authorization header of API calls.
Find your credentials in the Sinch Build Dashboard.
There are two pieces of information needed to obtain an access token: the key ID and key secret corresponding to your project ID.
To get an access token, do the following:
Login to the Sinch Build Dashboard to get your access keys.
Click on Create Access Key and when prompted, enter a display name, then click Confirm.
Does it have to be a new key?Not at all. If you have existing credentials saved, feel free to use them.
A Key ID and Key Secret will display. Save the project ID, key ID, and key secret someplace safe.
Important!The key secret is only viewable at the time of initial creation.
If you accidentally misplace they key secret, no worries! Create a new key.
Using the following curl command, get your access token using the key ID and key secret.
curl https://auth.sinch.com/oauth2/token \ -d grant_type=client_credentials \ -u YOUR_Key_ID:YOUR_Key_SecretYou'll see your new access token in the response. Now you're ready to use this token on calls to the API. The access token will be useable for one hour.
The access token is meant to be short lived for enhanced security. Generate one as often as it is necessary.
Elastic SIP Trunk API serves all endpoints from the following server:
https://elastic-trunking.api.sinch.com/v1/projects/{projectId}
The projectId is a required parameter you must include when making any API calls. You can find your project ID on your dashboard.
https://elastic-trunking.api.sinch.com/v1/projects/{projectId}/
Country Permissions
Country permissions are used to control which countries can be dialed from a specific SIP trunk. You can view, update, and remove country permissions. For beta, only US, CA and wild card are supported. Please note that these permissions are not per trunk but rather they are per project/account. In the future Sinch may extend these permissions to other voice and messaging products. If you are using sub-projects you can use the same country permissions for all sub-projects. You can also specify different country permissions for each sub-project that will override the parent country permissions.
A phone number that you want to use to filter results. You can pass a partial number to get all calls sent to numbers that start with the number you passed.
Only include calls made to this number or address. You can pass a partial number to get all calls sent to numbers that start with the number you passed.
Filter calls based on createTime. You make the query more precise, fewer results will be returned. For example, 2021-02-01 will return all calls from the first of February 2021, and 2021-02-01T14:00:00Z will return all calls after 14:00 on the first of February. This field also supports <= and >= to search for calls in a range ?createTime>=2021-10-01&createTime<=2021-10-30 to get a list if calls for october 2021 It is also possible to submit partial dates for example createTime=2021-02 will return all calls for February
Defaults to 24 hours
Internal notes If a customer submits = and not <> we should add min and max for the date range psueodo sql
createTime = 2021-02-01
select * from calls where createTime >= 2021-02-01 and createTime <= 2021-02-01T23:59:59Z
createTime = 2021-02-01T08
select * from calls where createTime >= 2021-02-01T08:00:00 and createTime <= 2021-02-01T08:59:59Zbut if they submit < or > we should just use the value they submitted and parse it a complete date
only include calls by on the callResult(s), example callResult=COMPLETED will return all calls which have completed normally.
| Enum Value | Description |
|---|---|
| COMPLETED | The call was completed successfully. |
| NO_ANSWER | The call timeout before the recipient answered. |
| CANCEL | The call was canceled. |
| BUSY | The recipient was busy. |
| FAILED | The call failed. |
only include calls by on the direction(s), example direction=INBOUND,OUTBOUND will return all calls that are inbound or outbound.
| Enum Value | Description |
|---|---|
| INBOUND | Somebody called your Sinch number. |
| OUTBOUND | You called somebody from your SIP device. |
https://elastic-trunking.api.sinch.com/v1/projects/{projectId}/calls
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X GET \
-u <username>:<password> \
'https://elastic-trunking.api.sinch.com/v1/projects/{projectId}/calls?from=string&to=string&trunkId=string&createTime=2021-02-01&callResult=COMPLETED&direction=INBOUND&page=string&pageSize=1'{ "calls": [ { … } ], "totalItems": 10000, "pageNumber": "1", "pageSize": 2000 }
Access Control List
The Access Control List (ACL) endpoint has operations that allow you to create, view, update, and remove ACLs. You use ACLs to control which IP addresses can send traffic to your SIP trunk. You can create multiple ACLs and assign them to multiple SIP trunks. In order to make outbound calls you need to have at least one ACL set up.