Campaigns
List, read, create, edit and delete Text2Join and Developer API campaigns with the REST API v1.
A campaign ties a keyword on one of your short codes to what happens when someone texts it: a Text2Join list, a Developer API callback, a survey and so on. Every campaign type can be listed and read; only Text2Join and Developer API campaigns can be created, edited and deleted through the API.
| Method | Path | Does |
|---|---|---|
GET | /campaign | List campaigns |
GET | /campaign/{ID} | Get a campaign |
POST | /campaign | Create a campaign |
POST | /campaign/{ID} | Edit a campaign |
DELETE | /campaign/{ID} | Delete a campaign |
The campaign object
| Field | Example | Meaning |
|---|---|---|
ID | 234553234 | The campaign's unique ID. |
CampaignType | Text2Join | One of Text2Join, Email2Text, Text2Email, AutoResponder, TextSurvey, TextVoting. |
CampaignName | Weekly Coupon Club | Your name for the campaign. |
Shortcode | 27126 | The number people text. |
Keyword | The campaign keyword. | |
AutoResponse | Text2Join only: the automatic reply. | |
ProcessorURL | Developer API only: the URL that receives incoming messages. | |
SubscribersCount | 0 | Number of subscribers (contacts) on the list. |
Responses also include HelpResponse, OptOutResponse, StickySession, ForwardEmail, ForwardMobile, Description, Action and URI; see the parameters under create a campaign.
List campaigns
https://msgapi.wire2air.com/rest/v1/campaign| Parameter | In | Description |
|---|---|---|
| PageNo integeroptional in query | query | The results page to return. |
| PageSize integeroptional in query | query | Results per page. |
curl -G "https://msgapi.wire2air.com/rest/v1/campaign" \
-H "apikey: YOUR_API_KEY" \
--data-urlencode "PageNo=1" \
--data-urlencode "PageSize=10"
import urllib.error
import urllib.parse
import urllib.request
params = urllib.parse.urlencode({
"PageNo": "1",
"PageSize": "10",
})
request = urllib.request.Request(
"https://msgapi.wire2air.com/rest/v1/campaign?" + params,
headers={"apikey": "YOUR_API_KEY"},
method="GET",
)
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({
PageNo: "1",
PageSize: "10",
});
const response = await fetch(`https://msgapi.wire2air.com/rest/v1/campaign?${params}`, {
method: "GET",
headers: { apikey: "YOUR_API_KEY" },
});
console.log(response.status, await response.text());
<?php
$params = http_build_query([
'PageNo' => '1',
'PageSize' => '10',
]);
$ch = curl_init('https://msgapi.wire2air.com/rest/v1/campaign?' . $params);
curl_setopt_array($ch, [
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>
{
["PageNo"] = "1",
["PageSize"] = "10",
};
using var client = new HttpClient();
var query = await new FormUrlEncodedContent(parameters).ReadAsStringAsync();
using var request = new HttpRequestMessage(HttpMethod.Get, "https://msgapi.wire2air.com/rest/v1/campaign?" + query);
request.Headers.Add("apikey", "YOUR_API_KEY");
using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");
{
"PageNo": 1,
"PageSize": 10,
"TotalPages": 12.0,
"TotalRecords": 118,
"RowStart": 1,
"RowEnd": 10,
"ListItems": [
{
"CampaignId": 9999999,
"CampaignType": "Email2Text",
"CampaignName": "demo@wire2air.com",
"Shortcode": "",
"Keyword": "",
"AutoResponse": "",
"ProcessorURL": "",
"HelpResponse": "mZone Text Service. std msg charges apply.",
"OptOutResponse": "You have successfully opted out from Text service and will not receive any messages. std msg charges apply.",
"StickySession": null,
"Action": "",
"ForwardEmail": "",
"ForwardMobile": "",
"Description": "",
"SubscribersCount": 0,
"URI": "v1/campaign/9999999",
"ID": "9999999"
}
]
}
Get a campaign
https://msgapi.wire2air.com/rest/v1/campaign/{ID}Takes no parameters besides the ID in the path. Returns one campaign object, the same as one item of ListItems above.
curl "https://msgapi.wire2air.com/rest/v1/campaign/CAMPAIGN_ID" \
-H "apikey: YOUR_API_KEY"
import urllib.error
import urllib.request
request = urllib.request.Request(
"https://msgapi.wire2air.com/rest/v1/campaign/CAMPAIGN_ID",
headers={"apikey": "YOUR_API_KEY"},
method="GET",
)
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 response = await fetch("https://msgapi.wire2air.com/rest/v1/campaign/CAMPAIGN_ID", {
method: "GET",
headers: { apikey: "YOUR_API_KEY" },
});
console.log(response.status, await response.text());
<?php
$ch = curl_init('https://msgapi.wire2air.com/rest/v1/campaign/CAMPAIGN_ID');
curl_setopt_array($ch, [
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.Net.Http;
using var client = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Get, "https://msgapi.wire2air.com/rest/v1/campaign/CAMPAIGN_ID");
request.Headers.Add("apikey", "YOUR_API_KEY");
using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");
Create a campaign
https://msgapi.wire2air.com/rest/v1/campaignOnly Text2Join and DeveloperAPI campaigns can be created.
| Parameter | In | Description |
|---|---|---|
| CampaignType stringrequired in body | body | Text2Join or DeveloperAPI. |
| Shortcode stringrequired in body | body | The short code Wire2Air assigned to your account. |
| Keyword stringoptional in body | body | The keyword people text. Required for DeveloperAPI campaigns; marked optional for Text2Join. |
| CampaignName stringrequired in body | body | Your name for the campaign. |
| HelpResponse stringoptional in body | body | Automatic reply to the HELP command. URL-encoded; any UTF-8 characters (see encoding). |
| OptOutResponse stringoptional in body | body | Automatic reply to the STOP command. URL-encoded; any UTF-8 characters. |
| ForwardEmail stringoptional in body | body | Text2Join only: email address notified of each new lead. |
| ForwardMobile stringoptional in body | body | Text2Join only: mobile number, in international format, that gets an SMS for each new lead. |
| ProcessorURL stringoptional in body | body | Required for DeveloperAPI campaigns: the URL that receives incoming messages. See webhooks. |
| StickySession integeroptional in body | body | DeveloperAPI only. 1: after someone texts the keyword, their later messages reach your ProcessorURL without the keyword. Inactive sessions stay valid for 72 hours. 0: off. |
curl "https://msgapi.wire2air.com/rest/v1/campaign" \
-H "apikey: YOUR_API_KEY" \
--data-urlencode "CampaignType=Text2Join" \
--data-urlencode "Keyword=coupon" \
--data-urlencode "Shortcode=27126" \
--data-urlencode "CampaignName=Weekly coupon deal" \
--data-urlencode "HelpResponse=Weekly Coupon Deal. Reply STOP to cancel. Msg&Data rates may apply." \
--data-urlencode "OptOutResponse=You have been removed from the Weekly Coupon Deal list. Msg&Data rates may apply."
import urllib.error
import urllib.parse
import urllib.request
params = urllib.parse.urlencode({
"CampaignType": "Text2Join",
"Keyword": "coupon",
"Shortcode": "27126",
"CampaignName": "Weekly coupon deal",
"HelpResponse": "Weekly Coupon Deal. Reply STOP to cancel. Msg&Data rates may apply.",
"OptOutResponse": "You have been removed from the Weekly Coupon Deal list. Msg&Data rates may apply.",
})
request = urllib.request.Request(
"https://msgapi.wire2air.com/rest/v1/campaign",
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({
CampaignType: "Text2Join",
Keyword: "coupon",
Shortcode: "27126",
CampaignName: "Weekly coupon deal",
HelpResponse: "Weekly Coupon Deal. Reply STOP to cancel. Msg&Data rates may apply.",
OptOutResponse: "You have been removed from the Weekly Coupon Deal list. Msg&Data rates may apply.",
});
const response = await fetch("https://msgapi.wire2air.com/rest/v1/campaign", {
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([
'CampaignType' => 'Text2Join',
'Keyword' => 'coupon',
'Shortcode' => '27126',
'CampaignName' => 'Weekly coupon deal',
'HelpResponse' => 'Weekly Coupon Deal. Reply STOP to cancel. Msg&Data rates may apply.',
'OptOutResponse' => 'You have been removed from the Weekly Coupon Deal list. Msg&Data rates may apply.',
]);
$ch = curl_init('https://msgapi.wire2air.com/rest/v1/campaign');
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>
{
["CampaignType"] = "Text2Join",
["Keyword"] = "coupon",
["Shortcode"] = "27126",
["CampaignName"] = "Weekly coupon deal",
["HelpResponse"] = "Weekly Coupon Deal. Reply STOP to cancel. Msg&Data rates may apply.",
["OptOutResponse"] = "You have been removed from the Weekly Coupon Deal list. Msg&Data rates may apply.",
};
using var client = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Post, "https://msgapi.wire2air.com/rest/v1/campaign")
{
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()}");
Edit a campaign
https://msgapi.wire2air.com/rest/v1/campaign/{ID}Edit uses POST (not PUT) to the campaign's URL, with the same parameters as create. Only Text2Join and DeveloperAPI campaigns can be edited.
curl "https://msgapi.wire2air.com/rest/v1/campaign/CAMPAIGN_ID" \
-H "apikey: YOUR_API_KEY" \
--data-urlencode "CampaignType=DeveloperAPI" \
--data-urlencode "Keyword=orders" \
--data-urlencode "Shortcode=27126" \
--data-urlencode "CampaignName=Order updates" \
--data-urlencode "ProcessorURL=https://example.com/wire2air/inbound" \
--data-urlencode "StickySession=1"
import urllib.error
import urllib.parse
import urllib.request
params = urllib.parse.urlencode({
"CampaignType": "DeveloperAPI",
"Keyword": "orders",
"Shortcode": "27126",
"CampaignName": "Order updates",
"ProcessorURL": "https://example.com/wire2air/inbound",
"StickySession": "1",
})
request = urllib.request.Request(
"https://msgapi.wire2air.com/rest/v1/campaign/CAMPAIGN_ID",
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({
CampaignType: "DeveloperAPI",
Keyword: "orders",
Shortcode: "27126",
CampaignName: "Order updates",
ProcessorURL: "https://example.com/wire2air/inbound",
StickySession: "1",
});
const response = await fetch("https://msgapi.wire2air.com/rest/v1/campaign/CAMPAIGN_ID", {
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([
'CampaignType' => 'DeveloperAPI',
'Keyword' => 'orders',
'Shortcode' => '27126',
'CampaignName' => 'Order updates',
'ProcessorURL' => 'https://example.com/wire2air/inbound',
'StickySession' => '1',
]);
$ch = curl_init('https://msgapi.wire2air.com/rest/v1/campaign/CAMPAIGN_ID');
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>
{
["CampaignType"] = "DeveloperAPI",
["Keyword"] = "orders",
["Shortcode"] = "27126",
["CampaignName"] = "Order updates",
["ProcessorURL"] = "https://example.com/wire2air/inbound",
["StickySession"] = "1",
};
using var client = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Post, "https://msgapi.wire2air.com/rest/v1/campaign/CAMPAIGN_ID")
{
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()}");
Delete a campaign
https://msgapi.wire2air.com/rest/v1/campaign/{ID}Only Text2Join and DeveloperAPI campaigns can be deleted.
curl -X DELETE "https://msgapi.wire2air.com/rest/v1/campaign/CAMPAIGN_ID" \
-H "apikey: YOUR_API_KEY"
import urllib.error
import urllib.request
request = urllib.request.Request(
"https://msgapi.wire2air.com/rest/v1/campaign/CAMPAIGN_ID",
headers={"apikey": "YOUR_API_KEY"},
method="DELETE",
)
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 response = await fetch("https://msgapi.wire2air.com/rest/v1/campaign/CAMPAIGN_ID", {
method: "DELETE",
headers: { apikey: "YOUR_API_KEY" },
});
console.log(response.status, await response.text());
<?php
$ch = curl_init('https://msgapi.wire2air.com/rest/v1/campaign/CAMPAIGN_ID');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'DELETE',
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.Net.Http;
using var client = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Delete, "https://msgapi.wire2air.com/rest/v1/campaign/CAMPAIGN_ID");
request.Headers.Add("apikey", "YOUR_API_KEY");
using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");

