Code Samples
Adding a Discount Code Template
/templates
Python
import requests
# API setup
API_KEY = "YOUR_API_KEY"
ACCOUNT_REF = "EX000000"
URL = "https://api.esendex.co.uk/v2/templates"
headers = {
"X-Api-Key": API_KEY,
"AccountReference": ACCOUNT_REF,
"Content-Type": "application/json"
}
# Template payload
template_data = {
"name": "Winter Sale 2026",
"channel": "SMS"
"templateType": "Text",
"messageType": "MarketingAndResearch",
"channelSettings": {
"sms": {
"characterSet": "GSM"
}
},
"content": "Hi [[firstName]]! Summer Sale starts now: Take [[discountPercent]] off with code [[discountCode]]."
}
try:
response = requests.post(URL, json=template_data, headers=headers)
response.raise_for_status()
result = response.json()
print("✅ Template created successfully!")
print(f"Template ID: {result.get('id', 'N/A')}")
except requests.exceptions.HTTPError as err:
print(f"❌ HTTP Error: {err.response.status_code} - {err.response.text}")
except Exception as e:
print(f"❌ Unexpected Error: {e}")
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.