Simple SMS API¶
Our SMS API is able to parse requests coming in as either JSON, Form-encoded or even as a querystring.
However, some caution must be taken when building a form/querystring request, especially when it comes to lists, as each list needs an index.
Building a Request¶
1 2 3 |
|
1 2 3 4 5 6 7 |
|
This is a request with the following fields:
- The message itself
Hello World
- The recipient
4512345678
- The sender
ExampleSMS
As recipients are an array of objects, the format becomes {array_name}.{index}.{object_field}
. Or in this specific case recipients.{index}.msisdn
.
To demonstrate how to build requests, we have included two examples using curl below. The data in the examples are the same as above, but broken up into more lines where it makes sense, rather than the plain HTTP requests above.
1 2 3 4 5 |
|
1 2 3 4 5 |
|
Input Fields¶
Field | Type | Required | Note |
---|---|---|---|
message |
string | yes | The message of the SMS |
recipients.0.msisdn |
int | yes | The receiving phone number |
sender |
string | no | The sender text |
encoding |
string | no | The desired encoding of the message |
user_ref |
string | no | Your reference for the SMS |
callback_url |
string | no | The URL we deliver notifications back to |
These fields are the same as in Basic Use in the REST docs, which is because the HTTP GET/POST API is merely a specialized parser for the same API.
For the complete list of fields that can be used, consult the Advanced Use.
Multiple Recipients¶
When sending to multiple recipients the array index increases by one for each element in the array.
1 2 3 |
|
1 2 3 4 5 6 7 |
|
1 2 3 4 5 6 |
|
1 2 3 4 5 6 |
|
Recommendations¶
Use a trusted encoding library.
Adding strings will probably work in most cases, but a proper URL encoding function would make sure your message is not rejected due to some trivial problem - for example a message with an ampersand (&
) in it.