Send a message
POST /message sends an SMS to one number or, with a comma-separated list, to many. Optional scheduling, reply URL and batch name.
https://msgapi.wire2air.com/rest/v1/messageParameters
Send the parameters form-encoded in the request body.
| Parameter | In | Description |
|---|---|---|
| to stringrequired in body | body | Destination mobile number in international format: country code, then the number, digits only (for example 12121234567 in the US, 447700900012 in the UK). Separate several numbers with commas to send in bulk. |
| from stringrequired in body | body | The short code (or other texting number) Wire2Air assigned to your account. |
| text stringrequired in body | body | The message. Any UTF-8 characters, URL-encoded like every other parameter. Not every carrier and handset displays every character; see encoding and length. |
| DeliveryDateTime stringoptional in body | body | When to deliver the message, in UTC, as MM/DD/YYYY HH:MM:SS. See scheduling. |
| Replypath stringoptional in body | body | Your URL that receives replies from the recipient. See inbound SMS. |
| BatchName stringoptional in body | body | For bulk sends only: a name for the batch, for your own reporting. |
The previous docs wrote these names with a capital first letter (To, From, Text) in the table and in lower case in every example. The examples here use lower case for the three required parameters, as the previous examples did.
Examples
curl "https://msgapi.wire2air.com/rest/v1/message" \
-H "apikey: YOUR_API_KEY" \
--data-urlencode "to=12121234567" \
--data-urlencode "from=27126" \
--data-urlencode "text=Your order has shipped."
import urllib.error
import urllib.parse
import urllib.request
params = urllib.parse.urlencode({
"to": "12121234567",
"from": "27126",
"text": "Your order has shipped.",
})
request = urllib.request.Request(
"https://msgapi.wire2air.com/rest/v1/message",
data=params.encode("utf-8"),
headers={"apikey": "YOUR_API_KEY"},
method="POST",
)
try:
with urllib.request.urlopen(request, timeout=30) as response:
print(response.status, response.read().decode("utf-8"))
except urllib.error.HTTPError as error:
print(error.code, error.read().decode("utf-8"))
const params = new URLSearchParams({
to: "12121234567",
from: "27126",
text: "Your order has shipped.",
});
const response = await fetch("https://msgapi.wire2air.com/rest/v1/message", {
method: "POST",
headers: { apikey: "YOUR_API_KEY" },
body: params, // sent as application/x-www-form-urlencoded
});
console.log(response.status, await response.text());
<?php
$params = http_build_query([
'to' => '12121234567',
'from' => '27126',
'text' => 'Your order has shipped.',
]);
$ch = curl_init('https://msgapi.wire2air.com/rest/v1/message');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $params,
CURLOPT_HTTPHEADER => ['apikey: YOUR_API_KEY'],
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
]);
$body = curl_exec($ch);
if ($body === false) {
echo 'Request failed: ' . curl_error($ch) . PHP_EOL;
} else {
echo curl_getinfo($ch, CURLINFO_HTTP_CODE) . ' ' . $body . PHP_EOL;
}
curl_close($ch);
using System;
using System.Collections.Generic;
using System.Net.Http;
var parameters = new Dictionary<string, string>
{
["to"] = "12121234567",
["from"] = "27126",
["text"] = "Your order has shipped.",
};
using var client = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Post, "https://msgapi.wire2air.com/rest/v1/message")
{
Content = new FormUrlEncodedContent(parameters),
};
request.Headers.Add("apikey", "YOUR_API_KEY");
using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");
Response
{
"Response": "Message Queued successfully",
"URI": "v1/message/outbox/85582790",
"ID": "85582790",
"Type": "Out"
}
{
"Response": "BATCHJOB Saved successfully",
"URI": "v1/batch/3a2139c4-6910-4716-a5f2-895231dba6eb",
"ID": "3a2139c4-6910-4716-a5f2-895231dba6eb",
"Type": "Batch"
}
{
"StatusCode": 703,
"StatusMessage": "Text Message missing."
}
| Status | Meaning |
|---|---|
201 | The message (or batch) has been queued for delivery. |
400 | The request is not valid; StatusMessage says what is missing. |
401 | The API key is missing or incorrect. |
429 | API calls quota exceeded. |
500 | Internal server error; contact support. |
201 means queued, not delivered. To learn whether a message reached the handset, use delivery reports.

