Code Samples
Looping Channels for Complete Opt-outs
/optouts
NodeJS
async function main() {
const axios = require('axios');
// Setting up API connection
const url = "https://api.esendex.co.uk/v2/optouts";
const headers = {
"X-Api-Key": "YOUR_KEY_HERE",
"Content-Type": "application/json"
};
const accountReference = "EXUKxxxxxx";
const targetNumber = "+447123456789";
const channels = ["SMS", "RCS"];
for (const channel of channels) {
const body = {
accountReference: accountReference,
channel: channel,
value: targetNumber
};
try {
const response = await axios.post(
url,
body,
{ headers }
);
console.log(`Success (${channel}):`, response.data);
} catch (error) {
if (error.response) {
console.error(`Error (${channel}): ${error.response.status}`);
console.error("Error details:", error.response.data);
} else {
console.error(`Error (${channel}):`, error.message);
}
}
}
}
main();
Why do developers choose our multichannel API suite?
Built for outcomes
Our RCS API (REST) eliminates API complexity with its modern architecture: one format, one base URL, and one API key.
Multichannel agility
Frictionless transition from SMS to RCS with one simple parameter change.
Fast API integration
Reduce time-to-value and skip complex setup. Our modern architecture means you can set up your API in as little as 3 hours.
Enterprise security
Rest easy with fully accredited ISO 27001 certification and built-in, reliable GDPR compliance pathways. The only messaging supplier with both ISO 27001 and NEN 7510 in the world.
Let’s start sending, together.
Discover the full power of our mobile messaging platform.