Core Concepts
This section outlines core concepts having to do with the Core API.
Batch Operations
The Batch API allows you to create, update, and delete tasks. Tasks are bulk operations that modify one or more phonenumber, prefix or file. When you create a batch task, you will have the option to review the items if you set the review field to boolean true value. In this case, your returned JSON status will be pending_review.
If the changes look correct, you can make a PATCH or PUT request to change the status from pending_review to approved. If the items look incorrect, the batch request can be prevented from proceeding by changing the status to cancelled.
Refer to the Batch section of the API for comprehensive information about each of the request types and corresponding returned data.
Callbacks
The CarrierX API enables callbacks to be sent to a URL. The callbacks are triggered when a specific action occurs, such as when either sending or receiving an SMS, calling into a conference, etc. The callback data will be the object that was affected. For example, if an SMS was sent to or from a phone number associated with a callback URL, the callback will be the SMS object.
Callbacks are assigned on either the DID object or the Partner object. If a callback URL is assigned on both the DID object level and the Partner object level, the DID object callback URL will override the Partner object callback URL.
On the Partner object, you can set the following callbacks
- for SMS activity use the
smsfield in thecallbacksobject; - for the mediator endpoints activity use the
app_mediatorfield; - for the conference endpoints activity use the
app_conference_callandapp_conference_meetingfields. - to get a callback confirming that a DID from an external provider has been rented successfully, use the
phonenumber_orderfield. - to get a callback when a batch task completes, use the
batch_task_completedfield.
On the DID object, set the value of the callback_url field for the callbacks related to SMS activity.
sms and callback_url Callback
The system sends sms and callback_url callbacks when an action related to an SMS event occurs.
| Attribute | Data Type | Description |
|---|---|---|
| date_changed | string | The date and time when the message was last changed. |
| date_created | string | The date and time when the system created the message object. |
| date_status_changed | string | The date and time when the system changed the message status. |
| direction | string | The message direction. |
| from | string | The phone number which was used to send the message. Note, that legacy users may still see the old naming instead (from_did). |
| group_recipients | array | The list of phone numbers that an inbound or outbound mms group message is delivered to, in E.164 format |
| mcc | integer | The mobile country code that was used by the operator when sending the message. |
| media_urls | array | The list of URLs for media resources, if type of message is mms. |
| message | string | The message text. It can be empty when sending multimedia messages (MMS) or contain some text which was sent to the receiving party. |
| message_segments | integer | The number of segments which the message contains. |
| message_sid | string | The secure ID of the message which the system uses to identify the message among other messages. |
| mnc | integer | The mobile network code that was used by the operator when sending the message. |
| partner_sid | string | The secure ID of the partner associated with the message. |
| price | number | The message price. It is calculated as (the rate for the message) × (the number of the message segments). |
| status | string | The status of the message at the moment when the system sent the callback. |
| to | string | The phone number which was used to receive the message. Note, that legacy users may still see the old naming instead (to_did). |
| type | string | The type of message. Values returned in this field are mms and sms. |
| user_data | string | Some additional user-defined data added to the message. |
| wireless_handset_status | string | The status of the message as it relates to the handset of a wireless DID. It is null for non-wireless DIDs. Refer to Wireless DID Approval for more information. |
A sample callback response. Refer to the SMS object for more information about each attribute and value.
{
"date_changed":"2023-09-04T17:37:38.852Z",
"date_created":"2023-09-04T17:37:36.123Z",
"date_status_changed":"2023-09-04T17:37:00.000Z",
"direction":"outbound",
"from": "15162065319",
"group_recipients":[],
"mcc":250,
"media_urls":[],
"message": "This is a test inbound message delivered by CarrierX",
"message_segments": 1,
"message_sid": "e405fa47-48f5-4dc5-bbba-77231587188e",
"mnc": null,
"partner_sid": "QLJ79xlC2vP-UEx3hS0R4rldas8.G1UB",
"price": "1",
"status": "received",
"to": "15162065318",
"type":"sms",
"user_data":null,
"wireless_handset_status":null
}
Refer to our Set up SMS Callbacks Using CarrierX Portal quick start guide for more information about the SMS/MMS callbacks and how you can set them using CarrierX portal.
app_mediator Callback
The app_mediator callback is triggered when a call is made to a Mediator binding or from a Mediator dialout.
| Attribute | Data Type | Description |
|---|---|---|
| attributes | object | The mediator attributes. |
| date_insert | string | The date and time when the Call Detail Record was processed and added to the database. |
| date_start | string | The date and time when the call started. |
| date_stop | string | The date and time when the call stopped. |
| date_talk | string | The date and time when the call is answered. |
| direction | string | The direction of the call, either inbound or outbound. |
| dr_sid | string | The secure ID of the record. |
| dtmf | string | The DTMF sequence of the binding. |
| duration | integer | The duration of the call. |
| endpoint_sid | string | The endpoint secure ID. |
| endpoint_type | string | The type of endpoint that triggered the callback. |
| event_type | string | The event type. |
| number_dst | string | The destination phone number. |
| number_redirect | string | The redirect phone number. |
| number_src | string | The source phone number. |
| partner_sid | string | The partner secure ID. |
| reference_sid | string | The binding_sid or the dialout_sid that was matched for the call. |
| type | string | The endpoint type. |
| version | integer | The API version. |
A sample app_mediator callback response:
{
"attributes":{},
"date_insert":"2024-01-25T18:12:10.770Z",
"date_start":"2024-01-25T18:08:23.000Z",
"date_stop":"2024-01-25T18:09:08.000Z",
"date_talk":"2024-01-25T18:08:44.000Z",
"direction":"inbound",
"dr_sid":"2a217f8d-df41-4e3d-bece-c72eaa2a8e2a",
"dtmf":null,
"duration":45,
"endpoint_sid":"632ec9ba-5bef-4ed3-a36d-56feec8ffd41",
"endpoint_type":"mediator",
"event_type":"binding",
"number_dst":"15162065344",
"number_redirect":"15162065346",
"number_src":"15162065345",
"partner_sid":"ed437757-002d-4ecc-aa5a-efdf5e50dba0",
"reference_sid":"05561bef-ce48-4823-a847-bf10f7837a42",
"type":"mediator",
"version":2
}
Refer to our Set up Mediator Callbacks Using CarrierX Portal quick start guide for more information about the Mediator endpoint callbacks and how you can set them using CarrierX portal.