Validate DLT Template API
Introduction to Validate DLT Template API
Welcome to SMSGatewayCenter's Validate DLT Template API! This essential API allows you to verify that your SMS message matches the registered DLT (Distributed Ledger Technology) template before sending messages. Perfect for ensuring India TRAI DLT compliance, preventing message rejections, validating variable replacements in templates, and building pre-send validation in mobile applications. Our RESTful endpoint uses POST method with application/x-www-form-urlencoded content type for secure integration.
About DLT Template Validation
The Validate DLT Template API enables you to:
- Pre-validate messages - Check template match before sending SMS
- Ensure DLT compliance - Verify India TRAI DLT requirements
- Prevent rejections - Catch template mismatches before API submission
- Validate variables - Check dynamic variable replacements in templates
- Sender ID verification - Confirm sender ID matches registered template
- Template ID check - Verify DLT template ID validity
- Real-time validation - Instant feedback on template compliance
This API is crucial for India SMS campaigns to ensure all messages comply with DLT regulations before sending.
What is DLT Template Validation?
DLT (Distributed Ledger Technology) is a regulatory framework by TRAI (Telecom Regulatory Authority of India) that requires all commercial SMS messages to be pre-registered with approved templates. This API validates that your message content exactly matches your registered DLT template, including proper variable syntax {#var#}, ensuring your SMS will not be rejected by operators.
Validate Template
Validate that your SMS message matches the registered DLT template. Returns success if message matches template, or error with reason if validation fails.
API Endpoint
https://unify.smsgateway.center/SMSApi/validateTemplateHTTP Method
POST
Content Type
application/x-www-form-urlencoded
application/x-www-form-urlencoded content type. Use --data-urlencode in cURL or appropriate encoding in your HTTP client.
| Key | Value | Description |
|---|---|---|
| Login Credentials (Required) | ||
| Authenticate your API request using userid-password or apiKey—choose one method. | ||
| userid | Your Registered Username | Your registered username; use if apiKey isn't provided. Signup for User ID |
| password | Your Password | URL-encoded password (for special characters); use if apiKey isn't provided. Signup for API Key |
| Header (optional) Parameters | ||
| apiKey | Your unique apiKey | apiKey needs to be sent as HTTP header when you are not using userid-password method. You can avail this from your user control panel and use instead of userid-password HTTP Request parameter. Please do not disclose this to anyone. |
| Parameter | Type | Required | Description |
|---|---|---|---|
senderid | String | Yes | Sender ID registered with DLT (e.g., "SMSGAT") |
msg | String | Yes | SMS message text to validate against DLT template. Include variables as {#var#} |
dltTemplateId | String | Yes | DLT Template ID registered with operator (e.g., "xxxx16194317445xxxx") |
output | String | Optional | Response format. Use json for JSON response (recommended) |
curl --location 'https://unify.smsgateway.center/SMSApi/validateTemplate' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'userid=YourUsername' \
--data-urlencode 'password=YourPassword' \
--data-urlencode 'output=json' \
--data-urlencode 'senderid=SMSGAT' \
--data-urlencode 'msg=Your Instant Demo account is live. This is a Demo Test message. {#var#} Demo Message SMSGatewayCenter' \
--data-urlencode 'dltTemplateId=xxxx16194317445xxxx'<?php
$curl = curl_init();
$postData = array(
'userid' => 'YourUsername',
'password' => 'YourPassword',
'output' => 'json',
'senderid' => 'SMSGAT',
'msg' => 'Your Instant Demo account is live. This is a Demo Test message. {#var#} Demo Message SMSGatewayCenter',
'dltTemplateId' => 'xxxx16194317445xxxx'
);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://unify.smsgateway.center/SMSApi/validateTemplate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => http_build_query($postData),
CURLOPT_HTTPHEADER => array(
"Content-Type: application/x-www-form-urlencoded",
"cache-control: no-cache"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
{
"status": "success",
"template": "Your Instant Demo account is live This is a Demo Test message {#var#} Demo Message SMSGatewayCenter",
"dltTemplateId": "xxxx16194317445xxxx",
"senderId": "SMSGAT",
"statusCode": "200",
"reason": "success",
"text": "Your Instant Demo account is live. This is a Demo Test message. {#var#} Demo Message SMSGatewayCenter"
}
Explanation: The message matches the DLT template successfully. Note that punctuation differences are normalized (periods may be converted to spaces in the template field).
{
"status": "error",
"statusCode": "188",
"reason": "message template mismatch"
}
Explanation: The message does not match the registered DLT template. Check for differences in text, spacing, or variable syntax.
Response Fields
| Field | Type | Description |
|---|---|---|
| Success Response Fields | ||
status | String | Response status: "success" or "error" |
template | String | Normalized template text (punctuation may be converted to spaces) |
dltTemplateId | String | DLT Template ID that was validated |
senderId | String | Sender ID that was validated |
statusCode | String | Status code: "200" for success |
reason | String | Result message: "success" or error description |
text | String | Original message text as submitted |
| Error Response Fields | ||
status | String | "error" |
statusCode | String | "188" - Template mismatch error code |
reason | String | Error description (e.g., "message template mismatch") |
Understanding DLT Variables
DLT templates support dynamic variables that can be replaced with actual values when sending messages. Variables must be properly formatted for validation to succeed.
Correct Variable Format: {#var#}
Examples of valid variables:
{#var#}- Generic variable placeholder
| Use Case | Template Example |
|---|---|
| OTP Message | Your OTP is {#var#}. Valid for 10 minutes. Do not share. - YourCompany |
| Order Confirmation | Your order {#var#} is confirmed. Amount: Rs {#var#}. Thank you - YourStore |
| Appointment Reminder | Reminder: Your appointment with Dr. {#var#} on {#var#} at {#var#}. - YourClinic |
| Payment Due | Dear {#var#}, your payment of Rs {#var#} is due on {#var#}. Pay now - YourCompany |
Integration Examples
Example 1: Pre-Send Validation in Mobile App
// React Native / JavaScript example
async function validateBeforeSend(senderId, message, dltTemplateId) {
const params = new URLSearchParams({
userid: 'YourUsername',
password: 'YourPassword',
output: 'json',
senderid: senderId,
msg: message,
dltTemplateId: dltTemplateId
});
try {
const response = await fetch('https://unify.smsgateway.center/SMSApi/validateTemplate', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: params.toString()
});
const data = await response.json();
if (data.status === 'success' && data.statusCode === '200') {
console.log('✓ Template validated successfully');
console.log(`Sender: ${data.senderId}`);
console.log(`Template: ${data.template}`);
// Proceed to send SMS
return true;
} else {
console.error(`✗ Validation failed: ${data.reason}`);
alert(`Template mismatch. Please check your message format.`);
// Do not send SMS
return false;
}
} catch (error) {
console.error('Validation error:', error);
return false;
}
}
// Usage
const isValid = await validateBeforeSend(
'SMSGAT',
'Your Instant Demo account is live. This is a Demo Test message. {#var#} Demo Message SMSGatewayCenter',
'xxxx16194317445xxxx'
);
if (isValid) {
// Send SMS using send API
sendSMS(...);
}Example 2: Batch Validation
import requests
from urllib.parse import urlencode
def validate_template(userid, password, sender_id, message, dlt_template_id):
url = 'https://unify.smsgateway.center/SMSApi/validateTemplate'
data = {
'userid': userid,
'password': password,
'output': 'json',
'senderid': sender_id,
'msg': message,
'dltTemplateId': dlt_template_id
}
headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}
response = requests.post(url, data=data, headers=headers)
result = response.json()
return result['status'] == 'success' and result['statusCode'] == '200'
# Batch validate multiple messages
messages_to_validate = [
{
'sender': 'SMSGAT',
'message': 'Your OTP is {#var#}. Valid for 10 minutes.',
'template_id': '1234567890123456'
},
{
'sender': 'SMSGAT',
'message': 'Your order {#var#} is confirmed. Amount: Rs {#var#}',
'template_id': '9876543210987654'
}
]
valid_messages = []
invalid_messages = []
for msg in messages_to_validate:
is_valid = validate_template(
'YourUsername',
'YourPassword',
msg['sender'],
msg['message'],
msg['template_id']
)
if is_valid:
valid_messages.append(msg)
print(f"✓ Valid: {msg['message'][:50]}...")
else:
invalid_messages.append(msg)
print(f"✗ Invalid: {msg['message'][:50]}...")
print(f"\n{len(valid_messages)} valid, {len(invalid_messages)} invalid")Example 3: Validate with Variable Replacement Preview
<?php
function validateAndPreviewMessage($senderId, $template, $dltTemplateId, $variables) {
// Replace variables in template for preview
$previewMessage = $template;
$varIndex = 1;
foreach ($variables as $value) {
$previewMessage = preg_replace('/{#var#}/', $value, $previewMessage, 1);
}
// Validate template first
$url = "https://unify.smsgateway.center/SMSApi/validateTemplate";
$postData = array(
'userid' => 'YourUsername',
'password' => 'YourPassword',
'output' => 'json',
'senderid' => $senderId,
'msg' => $template,
'dltTemplateId' => $dltTemplateId
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
if ($result['status'] === 'success') {
echo "✓ Template is valid!\n";
echo "Template: " . $result['template'] . "\n";
echo "Preview: " . $previewMessage . "\n";
return true;
} else {
echo "✗ Validation failed: " . $result['reason'] . "\n";
return false;
}
}
// Usage
$template = "Your OTP is {#var#}. Valid for {#var#} minutes. Do not share.";
$variables = ['123456', '10'];
$dltTemplateId = '1234567890123456';
validateAndPreviewMessage('SMSGAT', $template, $dltTemplateId, $variables);
// Output Preview: Your OTP is 123456. Valid for 10 minutes. Do not share.
Error Codes
| Status Code | Status | Reason | Description |
|---|---|---|---|
200 | success | success | Template validation successful - message matches DLT template |
188 | error | message template mismatch | Message does not match the registered DLT template |
Common Validation Failures
| Issue | Wrong | Correct |
|---|---|---|
| Variable Syntax | {{var}} or $var$ | {#var#} |
| Extra Spaces | "Hello World" (2 spaces) | "Hello World" (1 space) |
| Case Sensitivity | "your otp is" | "Your OTP is" (match registered template) |
| Missing Text | "Your OTP is {#var#}" | "Your OTP is {#var#}. Do not share." (complete template) |
| Extra Text | "Your OTP is {#var#}. Please verify soon." | "Your OTP is {#var#}. Do not share." (match exactly) |
| Wrong Sender ID | Using sender "OLDID" with template for "NEWID" | Use sender ID registered with the template |
Best Practices
Recommendations
- Validate Before Sending: Always validate templates before calling the send SMS API
- Use x-www-form-urlencoded: Ensure proper content-type header is set
- URL Encoding: Use proper URL encoding for special characters in message text
- Match Exactly: Ensure message text matches registered DLT template character-by-character
- Variable Syntax: Use correct
{#var#}format for dynamic variables - Sender ID Match: Verify sender ID is registered with the DLT template
- Cache Valid Templates: Cache validated templates to reduce API calls
- Error Handling: Show clear error messages when validation fails
- Template Library: Maintain a library of validated templates in your app
- Test Mode: Test validation with sample templates before production use
Why Template Validation Matters
Benefits of Pre-Validation
- Prevent SMS rejections
- Save SMS credits from failed sends
- Ensure DLT compliance
- Better user experience
- Avoid operator penalties
Risks Without Validation
- Messages rejected by operators
- Wasted SMS credits
- Non-compliance penalties
- Poor delivery rates
- Customer complaints
Common Use Cases
Pre-Send Validation
Validate messages before sending to prevent rejections and ensure DLT compliance.
Template Testing
Test DLT templates during development to ensure correct registration.
Bulk Campaign Validation
Validate templates before launching bulk SMS campaigns to avoid mass rejections.
Compliance Check
Ensure all outgoing messages meet India TRAI DLT regulatory requirements.
Testimonials
Why do Great Businesses Trust SMS Gateway Center?

