SMS API
GetUnsubscribedNumbers
This method returns a list of all recipient numbers who have opted out of your messaging campaign.
Endpoint
GET:https://messaging.esendex.us/Messaging.svc/GetUnsubscribedNumbers?LicenseKey={LICENSEKEY}
Syntax
GetUnsubscribedNumbers(LicenseKey)
Request Parameters
Parameter Name | Description | Data Type | Required | Sample Value |
---|---|---|---|---|
LicenseKey | Your license key. | GUID | True | 00000000-0000-0000-0000-000000000000 |
Response
Returns: Array of UnsubscribedNumber
objects
Code Samples
You can use any programming language you want with our API, as long as it can make a REST or SOAP call. Here are examples for some of the most common platforms.
C#
// https://messaging.esendex.us/Messaging.svc?wsdl was added as a Service Reference and given the name WSDL
using WSDL;
var client = new MessagingClient(MessagingClient.EndpointConfiguration.mms2wsHttpBindingSecure);
var numbers = await client.GetUnsubscribedNumbersAsync(YOUR_LICENSE_KEY);
foreach (var n in numbers)
{
Console.WriteLine(
"Phone Number: " + n.PhoneNumber + Environment.NewLine +
"UTC Entry Date: " + n.EntryDate + Environment.NewLine
);
}
Java
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Properties;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
public final class GetUnsubscribedNumbers {
public static void main(String[] args) {
try {
URL url = new URL("https://messaging.esendex.us/Messaging.svc/GetUnsubscribedNumbers?"
+ "LicenseKey=00000000-0000-0000-0000-000000000000");
try {
InputStream in = url.openStream();
StreamSource source = new StreamSource(in);
printResult(source);
} catch (java.io.IOException e) {
}
} catch (MalformedURLException e) {
}
}
private static void printResult(Source source) {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
StreamResult sr = new StreamResult(bos);
Transformer trans = TransformerFactory.newInstance().newTransformer();
Properties oprops = new Properties();
oprops.put(OutputKeys.OMIT_XML_DECLARATION, "yes");
trans.setOutputProperties(oprops);
trans.transform(source, sr);
System.out.println("**** Response ******");
System.out.println(bos.toString());
bos.close();
System.out.println();
} catch (Exception e) {
}
}
}
JavaScript
const params = new URLSearchParams({
'LicenseKey': '00000000-0000-0000-0000-000000000000'
});
const url = 'https://messaging.esendex.us/Messaging.svc/GetUnsubscribedNumbers?' + params.toString();
const response = await fetch(url, {
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
});
const numbers = await response.json();
console.log(numbers);
JSON Response
[
{
"EntryDate": "\/Date(928164000000-0400)\/",
"PhoneNumber": "String content"
}
]
PHP with cURL
<?php
$url = 'https://messaging.esendex.us/Messaging.svc/GetUnsubscribedNumbers?LicenseKey=00000000-0000-0000-0000-000000000000';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Accept: application/json'));
$response = curl_exec($ch);
curl_close($ch);
$array = json_decode($response, true);
print_r($array);
?>
Python
import httpx
headers = {"Accept": "application/json"}
url = "https://messaging.esendex.us/Messaging.svc/GetUnsubscribedNumbers"
request = {"LicenseKey": "00000000-0000-0000-0000-000000000000"}
with httpx.Client(headers=headers) as client:
response = client.get(url=url, params=request)
response.raise_for_status()
print(response.json())
Ruby
require 'json'
require 'net/http'
headers = { Accept: 'application/json', 'Content-Type': 'application/json' }
uri = URI('https://messaging.esendex.us/Messaging.svc/GetUnsubscribedNumbers')
params = {
'LicenseKey': '00000000-0000-0000-0000-000000000000'
}
uri.query = URI.encode_www_form(params)
response = Net::HTTP.get(uri, headers)
raise response.message if response.is_a?(Net::HTTPClientError) || response.is_a?(Net::HTTPServerError)
puts JSON.parse(response)
XML Response
<ArrayOfUnsubscribedNumber xmlns="http://sms2.cdyne.com">
<UnsubscribedNumber>
<EntryDate>1999-05-31T11:20:00</EntryDate>
<PhoneNumber>String content</PhoneNumber>
</UnsubscribedNumber>
<UnsubscribedNumber>
<EntryDate>1999-05-31T11:20:00</EntryDate>
<PhoneNumber>String content</PhoneNumber>
</UnsubscribedNumber>
</ArrayOfUnsubscribedNumber>
Let’s start sending, together.