Using the REST API
This section describes how to obtain credentials to use the API, what types of requests the system recognizes, and the format of the responses. It also holds reference information about pagination, filtering, and callbacks.
Using Postman
This documentation contains cURL commands that you will run in your terminal. Rather than use these commands, you can explore the API using Postman, a stand-alone client with a user-friendly interface. Postman is widely used for API development and allows you to test requests.
You will need to download the Postman client to your computer. To do so, visit the Postman website and click Download. Click Run in Postman to import this collection to the Postman app.
:::
Insert Postman button here
:::
For more information, refer to our Getting Started with Postman quick start guide.
Main Conventions
The following conventions are used in the sections, which contain the tables with objects attributes, their types, and descriptions:
create | The attribute can be set when the user creates the object using the POST method. |
update | The attribute can be modified when the user updates the object using either PATCH or PUT methods. |
read only | The attribute is set by the system and the user can neither set nor modify it. |
required | The path/query argument is required in the request. |
deprecated | The API method is deprecated. |
beta | The attribute is part of the feature that is still in development and is not recommended to use in production. |
Authentication
All CarrierX API requests require authentication. The first step to using CarrierX API is obtaining a CarrierX account and gaining credentials. To do so, please submit a request through our Contact Us page.
Currently, CarrierX API requests use two types of authentication:
- Bearer token, used by the requests to the Core API.
- Basic HTTP authentication with login and password, used by the requests to the endpoint APIs (Conference, FlexML, and Mediator).
Your API credentials carry various privileges for CarrierX access. Be sure to keep them secure and do not share them in publicly accessible areas such as source code management systems, client-side code, etc.
With the credentials you receive from CarrierX team, you can gain access to the Portal, where you will be able to create a security token. The security token allows you to work with the Core API and retrieve the endpoint login credentials for Conference, FlexML, and Mediator.
Follow the steps of our Create a Security Token quick start guide to create a token.
While the system allows request authentications for any users registered with CarrierX, the specific requests are limited by the scopes associated with the OAuth token that you use for the requests. This means that you might be eligible to make requests to CarrierX API, but not authorized to make a specific request, e.g., you can only view objects but not allowed to create, modify, or delete them.
You can create OAuth tokens with restricted access permissions (scopes) if you need that for a specific application. Refer to the Generate OAuth Bearer Token section for more details on this.
Prior to making requests to a Conference, FlexML, or Mediator endpoint, you need to create an application endpoint. Refer to the Configure an Application Endpoint quick start guide for step-by-step instructions on creating an endpoint. Dedicated quick start guides are also available to configure:
Note that at this time, you can only use tokens for the Core API. Each of the application endpoints has different login
and password
values. Entering the Core API token credentials instead of the endpoint-specific credentials when working with the Conference, FlexML, or Mediator APIs will return the unauthorized
error.
Example
The following curl command will return a list of all of the endpoints of the CarrierX account associated with the login credentials. Use your Core API token in the query below. The endpoint login
and password
values are listed in the returned JSON object.
curl -X GET \
'https://api.carrierx.com/core/v2/endpoints' \
-H 'Authorization: Bearer 5ebc03d6-8b2b-44ad-bf65-72d4f1491dda'
The credentials of a specific endpoint are found in the properties attribute of the nested object. Locate the login
and password
values.
{
"count": 1,
"has_more": false,
"items": [
{
"addresses": [],
"attributes": {},
"capacity": 0,
"endpoint_sid": "844346ef-93e9-4fa8-a4ab-e3015af94573",
"name": "flexml",
"out_sip_password": null,
"out_sip_username": null,
"partner_sid": "ed437757-002d-4ecc-aa5a-efdf5e50dba0",
"properties": {
"account_sid": "1d4adc32-45d1-4789-9780-928049e2bce1",
"api_url": "https://api.carrierx.com/flexml/v1",
"container_sid": "null",
"login": "sample_login",
"password": "sample_password"
},
"transformations": [],
"type": "flexml",
"voip_token": null
}
],
"limit": 1000,
"offset": 0,
"pagination": {},
"total": 1
}
Requests
The requests in CarrierX API are made using the standard REST notation, typical for web services.
A simplest request will have the following structure:
-
The request URL to which the request will be sent. The URL will be different for the Core API methods and for the main endpoint-related requests (conference, FlexML, mediator).
-
The request method or the verb used for the REST over HTTP request.
-
One or several headers or user/password authentication.
- At least one header---
-H 'Authorization: Bearer 5ebc03d6-8b2b-44ad-bf65-72d4f1491dda'
---is required to access the Core API. - For the requests to the conference, FlexML, or mediator endpoints, CarrierX uses the basic HTTP authentication with login and password (cURL
-u
option).
Refer to the Authentication section for more details on this.
- At least one header---
All the above elements are required for all CarrierX API requests.
Other request may have additional structure elements which include:
-
Path arguments are required with some methods to access specific objects (
GET
the object by secure ID,PATCH
/PUT
, andDELETE
objects). -
Body payload is required with
POST
andPATCH
/PUT
. Even if the object method does not require any body arguments (e.g.,POST
for some objects), the payload must still include an empty object (--data-binary '{}'
).noteIf the request includes body payload, you must use the
Content-Type: application/json
header with it. Otherwise it will return the 415 Unsupported media type error status code. -
Query arguments may be either optional or required for some requests. Refer to the objects sections below to see which object methods require the presence of the query arguments. The optional query arguments available with some
GET
requests include pagination, result filtering, and field filtering. -
Form data is required with some
POST
methods, e.g., uploading a file to the container usingmultipart/form-data
content type.
Sample
A sample request to create a Conference endpoint:
curl -X POST \
'https://api.carrierx.com/core/v2/endpoints' \
-H 'Content-Type: application/json' \
--data-binary '{"name":"my_conf", "type":"conference"}' \
-H 'Authorization: Bearer 5ebc03d6-8b2b-44ad-bf65-72d4f1491dda'
Request URL
The usual path to the API objects includes the base URL to the API used with the object (Core API base URL for the objects used throughout the CarrierX products, or specific API base URLs used for FlexML, Mediator, or Conference), and the path to the object collections and the object items.
If the action targets the specific object, the path to it will include the object secure ID (SID), which allows to distinguish the targeted object from the other ones in the same collection.
- The Core API has the following base URL:
https://api.carrierx.com/core/v2
- The Conference API has the following base URL:
https://api.carrierx.com/conference/v2
- The FlexML API has the following base URL:
https://api.carrierx.com/flexml/v1
- The Mediator API has the following base URL:
https://api.carrierx.com/mediator/v1
The system only accepts HTTPS requests, and not HTTP requests.
Request Methods
CarrierX API uses five main verbs (methods) of REST over HTTP for the requests: POST
, GET
, PUT
, PATCH
, and DELETE
. These methods are used to create the objects, get the information about the objects, modify the objects, and delete them.
Not all the objects can be created. Some of them are created automatically by the system. You can only view them, and cannot add, modify, or delete.
CarrierX partners need to have special permissions (or scopes) to use API methods on various objects. Refer to the available_scopes table for the complete list of the scopes that define the partner's permissions on objects and collections.
Please contact technical support at support@carrierx.com in the case you need some additional scopes enabled for your account.