The primary reason for using the Wire2Air API is to send SMS text messages.
Endpoint
To send messages using Wire2Air Rest API, send a POST request to the messages URL:POST https://msgapi.wire2air.com/rest/v1/message
Parameters
Name | Required? | Examples | Description |
---|---|---|---|
To | Yes | e.g 12121234567 (for US), 447700900012 (for UK) | DESTINATION MOBILE NUMBER. [(country code) + mobile number] |
From | Yes | Eg:27126 | SHORT CODE NUMBER; PROVIDED BY WIRE2AIR |
Text | Yes | Wire2Air test message | The message text. Just like the other parameters, this should be urlencoded. It may contain any UTF-8 characters (Note: not all cell phone operators support UTF-8 characters). Check the encoding section for details. |
DeliveryDateTime | Optional | Example: 11/6/2010 7:41:06 PM EST (UTC date for 11/6/2010 3:41:06 PM) | Default: Now Date and time for message delivery in UTC MM/DD/YYYY HH:MM:SS format. |
Replypath | Optional | For example http://[yourserver]/smsreceiver.php? | Provide your application url to receive replies from user. |
Request Format
{
“to”: “12121234567”,
“from”: “27126”,
“deliverydatetime”: “8/14/2017 09:00:00 AM”,
“text”: “This is a sample text message”,
“replypath”: “http://yourserverurl/receivesms.asp”
}
“to”: “12121234567”,
“from”: “27126”,
“deliverydatetime”: “8/14/2017 09:00:00 AM”,
“text”: “This is a sample text message”,
“replypath”: “http://yourserverurl/receivesms.asp”
}
Form Encoded
<form action="https://msgapi.wire2air.com/rest/v1/message?authkey=Your-API-Key" enctype="application/x-www-form-urlencoded" method="post">
<input name="to" type="text" value="12123005984" />
<input name="from" type="text" value="27126" />
<input name="text" type="text" value="Test Message" />
<button type="submit">Submit</button>
</form>
curl -H "apikey:Your-API-Key" --data "to=12123005984&from=27126&text=Text message" https://msgapi.wire2air.com/rest/v1/message/
Response
HTTP Status Codes201 | Success – A new message has been queued for delivery |
401 | Unauthorized – Authentication credentials are missing or incorrect |
400 | Bad Request– The request is not valid. An accompanying error message explains what’s missing. |
500 | Internal Server Error – Contact support |
Sample Error Response
{
"StatusCode": 703,
"StatusMessage": "Text Message missing."
}
Successful Response Samples
{
"Response": "Message Queued successfully",
"URI": "v1/message/outbox/85582790",
"ID": "85582790",
"Type": "Out"
}
How to send bulk text messages
To send a message to many recipients simultaneously pass the mobile number as comma separated in the “To” ParameterPOST https://msgapi.wire2air.com/rest/v1/messagewith the following parameters:
Parameters
Name | Required? | Examples | Description |
---|---|---|---|
To | Yes | 12121234567,12121234568,12121234569, 447700900012 | Comma-separated Mobile Numbers. [(country code) + mobile number] |
From | Yes | Eg:27126,18334445555 | SHORT CODE NUMBER or TEXT NUMBER; PROVIDED BY WIRE2AIR |
Text | Yes | Text Message | The message text. Just like the other parameters, this should be URL-encoded. It may contain any UTF-8 characters (Note: not all cell phone operators support UTF-8 characters). Check the encoding section for details. |
BatchName | Optional | Batch08152017 | *Internal Use for Reporting |
DeliveryDateTime | Optional | Example: 11/6/2010 7:41:06 PM EST (UTC date for 11/6/2010 3:41:06 PM) | Default: Now Date and time for message delivery in UTC MM/DD/YYYY HH:MM:SS format. |
Replypath | Optional | For example http://[yourserver]/smsreceiver.php? | Provide your application URL to receive replies from users. |
Successful Response Sample
{
"Response": "BATCHJOB Saved successfully",
"URI": "v1/batch/3a2139c4-6910-4716-a5f2-895231dba6eb",
"ID": "3a2139c4-6910-4716-a5f2-895231dba6eb",
"Type": "Batch"
}