Skip to main content

Sending a Message

You can send messages either using the CarrierX Portal or programmatically with the help of Core API.

Reminder

Before sending messages from your phone number using the Core API, make sure that messaging is enabled for that DID and that you have received approval for your messages.

SMS vs MMS

Message sent with a value in the group_recipients or media_urls fields will be sent as an MMS, otherwise the message will be sent as an SMS. For details refer to the Core API documentation.

Sending a Message via Portal

We will first send a message through the Portal.

note
  • Sending SMS messages through the Portal is intended for testing purposes only. We do not recommend using this method for production purposes.
  • Currently you can only send SMS messages through the Portal; MMS is not supported.

In the left-hand navigation menu, select MESSAGING.

In the From DID field, select the phone number you want to send your SMS from.

Send an SMS via Portal

In the To DID field, enter the destination phone number you will send your SMS to, type in the message text and click the Send button.

This is my first message via CarrierX Portal.

This will send an SMS message from the selected phone number to the phone number you entered into the To DID form.

Sending an SMS Programmatically

In this section, we will use the Core API to send an SMS message.

Form a POST request, in the body include:

  • from - the phone number rented from CarrierX
  • to - the phone number to which you want to send the message
  • message - some text

Refer to the SMS Object section of the Core API Reference for a list of the other fields that exist in the SMS object.

curl -X POST \
'https://api.carrierx.com/core/v2/sms/messages' \
-H 'Content-Type: application/json' \
--data-binary '{"from":"15162065575","to":"15162065574","message":"Sent via the CarrierX API"}' \
-H 'Authorization: Bearer 5ebc03d6-8b2b-44ad-bf65-72d4f1491dda'
Sent via the CarrierX API

A successful request will return a 200 status code along with a response that looks like the following:

{
"date_changed": "2024-01-18T21:01:13.415Z",
"date_created": "2024-01-18T21:01:13.415Z",
"date_status_changed": null,
"direction": "outbound",
"from": "15162065575",
"group_recipients":[],
"mcc": null,
"media_urls":[],
"message": "Sent via the CarrierX API",
"message_segments": 1,
"message_sid": "097b49df-c54e-4eaf-97d0-89cf7d5a655b",
"mnc": null,
"partner_sid": "e00430c3-a7d0-4666-ab5c-f7202448382f",
"price": null,
"status": "queued",
"to": "15162065574",
"type":"sms",
"user_data":null
}

Sending an MMS Programmatically

Let's send an MMS that includes an image.

As with SMS, form a POST request and include:

  • from - the phone number rented from CarrierX
  • to - the phone number to which you want to send the message
  • message - some text
  • media_urls - the url(s) of the media to send. This is an array field, so remember to enclose the value(s) in square brackets, [ ].

For additional details see the API documentation. Note that the documentation refers to the SMS Object, but the details of MMS are included there as well.

curl -X POST \
'https://api.carrierx.com/core/v2/sms/messages' \
-H 'Content-Type: application/json' \
--data-binary '{"from":"15162065575","to":"15162065574","message":"Look! An image is included.","media_urls":["https://www.carrierx.com/images/carrierx-logo-horizontal-color.png"]}' \
-H 'Authorization: Bearer 5ebc03d6-8b2b-44ad-bf65-72d4f1491dda'
CarrierX Logo
Look! An image is included.

A successful request will return a 200 status code along with a response that looks like the following:

{
"date_changed": "2024-01-18T21:01:13.415Z",
"date_created": "2024-01-18T21:01:13.415Z",
"date_status_changed": null,
"direction": "outbound",
"from": "15162065575",
"group_recipients":[],
"mcc": null,
"media_urls":[
'https://www.carrierx.com/images/carrierx-logo-horizontal-color.png'
],
"message": "Look! An image is included.",
"message_segments": 1,
"message_sid": "097b49df-c54e-4eaf-97d0-89cf7d5a655b",
"mnc": null,
"partner_sid": "e00430c3-a7d0-4666-ab5c-f7202448382f",
"price": null,
"status": "queued",
"to": "15162065574",
"type":"mms",
"user_data":null
}