Overview
You can use this request to send transactional SMSs.
Transactional SMSs allow you to send once-off SMSs to your contacts. These on-demand SMSs are generated in real-time. Transactional SMSs allow you to send a single message to a single contact at a time. For example, if you need to send a one-time pin to a contacts, you can use transactional SMS to do so.
The Method
API | - | Method |
---|---|---|
REST | POST | https://[Your URL]/api/2.0/production/sms/message |
Your method must be structured as follows:
Parameters
The following parameters are required:
Property | Type | Description | Required | Additional Info |
---|---|---|---|---|
message | string | The sms message to be sent. | yes | Only plain text is accepted. Do not send multimedia. |
mobile_number | string | The mobile number the sms message must be sent to. | yes | Using mobile numbers with country code is advised. |
Responses
A successful call will return HTTP STATUS: 200, and the reason phrase will be: “Your message has been sent.”
A possible processing deference will return HTTP STATUS 201.
You can treat any other HTTP STATUS as a failure.
Code Samples
PHP:
$url = YOUR_INSTALL_URL /api/2.0/production/sms/message'; $post = json_encode(['message' => 'Your sms message','mobile_number' => '27711231234']); $username = 'YOUR_USER_NAME'; $apiKey = 'YOUR_API_KEY'; $cSession = curl_init(); $headers = array( 'Content-Type:application/json', 'Content-Length:'.strlen($post) ); curl_setopt($cSession, CURLOPT_URL, $url); curl_setopt($cSession, CURLOPT_USERPWD, $username . ":" . $apiKey); curl_setopt($cSession, CURLOPT_RETURNTRANSFER, true); curl_setopt($cSession, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($cSession, CURLOPT_POSTFIELDS, $post); curl_setopt($cSession, CURLOPT_HTTPHEADER, $headers); $result = curl_exec($cSession); curl_close($cSession);