Send SMS with Dotdigital's Omnichannel API using PHP

This tutorial will show you how to send SMS using Dotdigital's Omnichannel API and PHP. Click the "Start" button below to start the tutorial.

Start Tutorial

Sending SMS using Dotdigital Omnichannel API and PHP

This short tutorial will show you how to send SMS using the Dotdigital Omnichannel API; it's quick and easy!

The tutorial's navigation controls are located above this text. Use to move to the next step of the tutorial. Use to move to the previous step of the tutorial (if there is one). Use to see an overview of all the steps in the tutorial.

To begin with you will need the following prerequisites installed:

Enter your details

To get the tutorial code to run successfully you need to enter your Dotdigital API user credentials and a target mobile number.

To create an API User please see this tutorial

Enter you mobile number

Enter your mobile number in international format, which is:

  • Your country code i.e. 44 for the UK
  • Your mobile number with any leading zeros removed e.g. if your local number is 07123 123 123 you would use 71234123123
  • Remove any non numeric characters

e.g. If you lived in the UK and had a mobile number of 07123 123123 then in international format it would be 447123123123

Running the code

You are now ready to run the code and send an SMS, but please ensure you have Pay As You Go billing enabled on your account first; talk to your account manager if you need this enabling please.

To run simply press play within Visual Studio and a console will open.

When prompted type single to send a single SMS message.

You should receive your SMS shortly, if a successful response was returned.

Understanding the code

The Dotdigital Omnichannel API is very easy to use, we'll just explain what the code is this tutorial does.


The Dotdigital Omnichannel API is RESTful and therefore utilizes the abilities of the HTTP protocol in order to derive action and context.

In the tutorial the URL we POST to contains the action or entity we are interested in and the HTTP verb POST indicates we want to send a message.

Authentication is very easy as it uses the HTTP protocols basic auth, with a set of API User credentials.

The Request object

The request object is used to describe the message you want to send and via what channels. As a minimum it is composed of:


The body is the text message body you want to send. The Omnichannel API will automatically ensure this message can be sent on any supported channels.


The to object should be populated with any addressing information that might be used by the channels you want to send on, such as:

  • phoneNumber
  • email
  • fbMessengerId
  • etc...

No from?

You don't need to define who the SMS is from by default as this will simply tell dotdigital you want it to select an appropriate from for the destination country using its Localizer and Stitching feature.

See our full documentation for more details.

The Request object with channel options

The request object can optionally have additional channelOptions defined to allow you finer control over the SMS send, options are:


The from is the phone number, alpha identifier, or short code you are sending from.


The allowUnicode options toggles whether having Unicode characters in the message body will be allowed or not.

See our full documentation for more details.

Making the web service call

We have used the built in CURL functions to make the code simpler when calling web services in PHP.

In the highlighted code you can see how we build the CURL request by setting the various options, adding our basic auth credentials and the request JSON we created earlier. We then execute the CURL request which then does a HTTP POST to the Dotdigital Omnichannel web service.

Batch Sending

The API also supports the sending of messages in a batch which should be used when their is more than one recipient as it will be much more efficient than calling the single send method multiple times.

The web method is very simple as it accepts an array of message requests as used in the single submission method described in this tutorial. The batch send endpoint (URL) is slightly different to the single send endpoint with /batch appended. The web method on being successfully called returns an array of messageId, one for each submitted message request.

Now run the batch_send.php file and you should receive your SMSs shortly, if a successful response was returned with your message ids for each message in the request array.

See our full documentation for more details.

All done

Thanks for taking the time to look through the tutorial, to find out more visit our full documentation.