Create an SMS campaign using the API

If you haven't already, first review the general overview of using the create and send campaign methods to send messages via the API.

To create an SMS you will need to add an SMS message in your POST params when calling the create method. Parameters used in SMS message content are listed below: 

Parameters

ParameterDescription
messagesSet to number 9 for SMS i.e., "messages": { "9": { SMS_CONTENT PARAMS } }

A JSON object containing the SMS params
sms"sms": { "from": "xtremepush", "text": "Hello"}
fromThe from header that is used to identify your brand
textThe body text of the SMS message

📘

SMS from names

SMS from names replaces the sender number in your SMS message seen by your audience and are captured by the from parameter. These need to be pre-configured from the SMS settings page.

Example

The SMS channel is turned on with "sms": 1 and the SMS type 9 is added to the messages object with parameters for the SMS content. In this example "broadcast": 1 is used to target your entire available user base. Conditions that target a subsection of your audience, and scheduling and other options can be added as described in the campaign model guide.

In this example a personalisation tag has been added in the SMS text to pull in the users' first names.

curl --request POST \
  --url https://external-api.xtremepush.com/api/external/create/campaign \
  --header 'content-type: application/json' \
  --data '{
    "apptoken": "YOUR_APPTOKEN",
    "title": "SMS example via API",
    "sms": 1,
    "broadcast": 1,
    "messages": {
      "9": {
        "sms": {
          "from": "xtremepush",
          "text": "{{first_name}}, check out our SMS API test"
				}
      }
    }
  }'

Your resulting SMS from above would look something like this one:

750