SMS Templates
Create reusable SMS templates with personalization variables for efficient messaging campaigns.
Overview
SMS templates allow you to:
- 📝 Reuse common messages without retyping
- 🎯 Personalize messages with recipient-specific data
- ⚡ Send faster by selecting pre-made templates
- 📊 Maintain consistency across campaigns
Template Variables
Use these variables in your templates to automatically insert recipient data:
| Variable | Description | Example |
|---|---|---|
#phone# | Phone number | 37061234567 |
#first-name# | First name | John |
#last-name# | Last name | Doe |
#middle-name# | Middle name | Michael |
#birthdate# | Date of birth | 1990-05-15 |
#gender# | Gender | Male/Female |
#note1# | Custom field 1 | Premium customer |
If a recipient doesn't have data for a variable, that part will be omitted from the message. For example, if #last-name# is missing, only the first name will appear.
Example Template
Dear #first-name# #last-name#,
Thank you for using our services! Your loyalty means everything to us.
Best regards,
Your Company Team
Result for recipient with data:
Dear John Doe,
Thank you for using our services! Your loyalty means everything to us.
Best regards,
Your Company Team
Result for recipient without last name:
Dear John,
Thank you for using our services! Your loyalty means everything to us.
Best regards,
Your Company Team
Get All Templates
Retrieve all templates in your account.
Endpoint:
GET https://www.lightsms.com/external/get/template.php
Required Parameters:
| Parameter | Type | Description |
|---|---|---|
login | string | Your LightSMS login |
signature | string | MD5 hash signature |
timestamp | integer | UTC timestamp |
Optional Parameters:
| Parameter | Type | Description |
|---|---|---|
return | string | Response format: json or xml |
Example Request
curl "https://www.lightsms.com/external/get/template.php?login=YourLogin&signature=generated_signature×tamp=1732809600&return=json"
Response (JSON)
{
"welcome": {
"template": "Welcome #first-name#! Thanks for joining us.",
"up_time": "2024-08-28 15:22:25"
},
"birthday": {
"template": "Happy birthday #first-name#! Enjoy 20% off today.",
"up_time": "2024-08-28 15:39:07"
}
}
Response (XML)
<?xml version="1.0" encoding="utf-8"?>
<response>
<templates>
<template name="welcome" template="Welcome #first-name#! Thanks for joining us." up_time="2024-08-28 15:22:25" />
<template name="birthday" template="Happy birthday #first-name#! Enjoy 20% off today." up_time="2024-08-28 15:39:07" />
</templates>
</response>
Add Template
Create a new template or update an existing one.
Endpoint:
GET https://www.lightsms.com/external/get/add_template.php
Required Parameters:
| Parameter | Type | Description |
|---|---|---|
login | string | Your LightSMS login |
signature | string | MD5 hash signature |
name | string | Template name (identifier) |
text | string | Template text with variables |
timestamp | integer | UTC timestamp |
Optional Parameters:
| Parameter | Type | Description |
|---|---|---|
override | string | 1 to update existing, 0 to fail if exists (default: 0) |
return | string | Response format: json or xml |
Example Request
curl "https://www.lightsms.com/external/get/add_template.php?login=YourLogin&signature=generated_signature&name=welcome&text=Welcome%20%23first-name%23!×tamp=1732809600&return=json"
Response (JSON)
{
"id": "4419373"
}
Response (XML)
<?xml version="1.0" encoding="utf-8"?>
<response>
<id>4419374</id>
</response>
Delete Template
Remove a template from your account.
Endpoint:
GET https://www.lightsms.com/external/get/del_template.php
Required Parameters:
| Parameter | Type | Description |
|---|---|---|
login | string | Your LightSMS login |
signature | string | MD5 hash signature |
name | string | Template name to delete |
timestamp | integer | UTC timestamp |
Optional Parameters:
| Parameter | Type | Description |
|---|---|---|
return | string | Response format: json or xml |
Example Request
curl "https://www.lightsms.com/external/get/del_template.php?login=YourLogin&signature=generated_signature&name=welcome×tamp=1732809600&return=json"
Response (JSON)
{
"result": "deleted"
}
Response (XML)
<?xml version="1.0" encoding="utf-8"?>
<response>
<result>deleted</result>
</response>
PHP Example
<?php
class TemplateManager {
private $login;
private $apiKey;
public function __construct($login, $apiKey) {
$this->login = $login;
$this->apiKey = $apiKey;
}
private function getTimestamp() {
return trim(file_get_contents('https://www.lightsms.com/external/get/timestamp.php'));
}
private function createSignature($params) {
ksort($params);
return md5(implode($params) . $this->apiKey);
}
public function getAll() {
$timestamp = $this->getTimestamp();
$params = [
'login' => $this->login,
'timestamp' => $timestamp,
'return' => 'json'
];
$signature = $this->createSignature($params);
$params['signature'] = $signature;
$url = 'https://www.lightsms.com/external/get/template.php?' . http_build_query($params);
$response = file_get_contents($url);
return json_decode($response, true);
}
public function add($name, $text, $override = false) {
$timestamp = $this->getTimestamp();
$params = [
'login' => $this->login,
'name' => $name,
'text' => $text,
'timestamp' => $timestamp,
'return' => 'json'
];
if ($override) {
$params['override'] = '1';
}
$signature = $this->createSignature($params);
$params['signature'] = $signature;
$url = 'https://www.lightsms.com/external/get/add_template.php?' . http_build_query($params);
$response = file_get_contents($url);
return json_decode($response, true);
}
public function delete($name) {
$timestamp = $this->getTimestamp();
$params = [
'login' => $this->login,
'name' => $name,
'timestamp' => $timestamp,
'return' => 'json'
];
$signature = $this->createSignature($params);
$params['signature'] = $signature;
$url = 'https://www.lightsms.com/external/get/del_template.php?' . http_build_query($params);
$response = file_get_contents($url);
return json_decode($response, true);
}
}
// Usage
$templates = new TemplateManager('YourLogin', 'your_api_key');
// Get all templates
$allTemplates = $templates->getAll();
foreach ($allTemplates as $name => $info) {
echo "Template: {$name}\n";
echo "Text: {$info['template']}\n";
echo "Updated: {$info['up_time']}\n\n";
}
// Add new template
$result = $templates->add(
'welcome',
'Welcome #first-name#! Thanks for joining us.'
);
echo "Template added with ID: {$result['id']}\n";
// Update existing template
$result = $templates->add(
'welcome',
'Welcome #first-name# #last-name#! Thanks for choosing us.',
true // override = true
);
echo "Template updated with ID: {$result['id']}\n";
// Delete template
$result = $templates->delete('old_template');
echo "Delete result: {$result['result']}\n";
?>
Common Template Examples
Welcome Message
Welcome to #note1#, #first-name#!
We're excited to have you with us. Your journey starts now.
Order Confirmation
Hi #first-name#!
Your order #note1# has been confirmed. Track it here: example.com/track
Thanks for shopping with us!
Appointment Reminder
Reminder for #first-name# #last-name#:
Your appointment is tomorrow at #note1#.
Reply YES to confirm or CANCEL to reschedule.
Birthday Greeting
Happy Birthday, #first-name#! 🎉
Celebrate with 25% off your next purchase. Use code: BDAY25
Valid until #note1#
Payment Reminder
Hi #first-name#,
Your payment of #note1# EUR is due on #note2#.
Pay now: example.com/pay
Thank you!
Common Errors
Error Code 21: No name
Problem: Template name is missing or empty
Solution: Provide a valid template name
Error Code 22: Template already exists
Problem: Template name is already in use and override is not set
Solutions:
- Use a different template name
- Set
override=1to update the existing template
Using Templates in Web Interface
- Go to Lists > Templates in LightSMS platform
- Click Add template
- Enter template name and text with variables
- Save template
- When sending SMS, select template from SMS template dropdown