Complete guide to template creation, testing, and API integration
Sign up at www.lorotemplates.com/login and confirm your email address.
After email confirmation, you'll receive your API key via email. This key authenticates all your API requests.
Login to access your dashboard where you can create, edit, and test templates.
Scriban is a powerful templating engine that allows you to generate dynamic content by combining templates with JSON data.
Hello {{ name }}!
Your order details:
{{~ for item in items ~}}
- {{ item.name }}: ${{ item.price }}
{{~ end ~}}
Total: ${{ total }}
{{ variable_name }}
{{ user.first_name }}
{{ items[0].price }}
{{~ if user.premium ~}}
Premium user benefits
{{~ else ~}}
Standard features
{{~ end ~}}
{{~ for item in items ~}}
{{ item.name }}
{{~ end ~}}
{{ date.now | date.to_string "%Y-%m-%d" }}
{{ name | string.upcase }}
{{ items | array.size }}
{
"name": "John Doe",
"email": "john@example.com",
"items": [
{
"name": "Widget A",
"price": 29.99,
"quantity": 2
},
{
"name": "Widget B",
"price": 19.99,
"quantity": 1
}
],
"total": 79.97,
"date": "2024-01-15"
}
https://api.lorotemplates.com
All API requests require your API key in the request header:
X-API-Key: your-api-key-here
Every API request must include your API key in the X-API-Key
header.
Content-Type: application/json
X-API-Key: your-api-key-here
Render a template with JSON data
{
"template_id": "uuid-of-template", // Optional: use saved template
"template": "Hello {{ name }}!", // Optional: inline template
"data": {
"name": "John Doe"
}
}
{
"success": true,
"result": "Hello John Doe!",
"render_time_ms": 45
}
Get all your templates
[
{
"id": "template-uuid",
"name": "Welcome Email",
"description": "Customer welcome email template",
"category": "Emails",
"is_active": true,
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
]
Get a specific template by ID
{
"id": "template-uuid",
"name": "Welcome Email",
"description": "Customer welcome email template",
"content": "Hello {{ customer.name }}!",
"category": "Emails",
"schema": "{ \"type\": \"object\" }",
"sample_data": "{ \"customer\": { \"name\": \"John\" } }",
"is_active": true,
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
const API_BASE = 'https://api.lorotemplates.com';
const API_KEY = process.env.LORO_API_KEY;
async function renderTemplate(templateData) {
const response = await fetch(`${API_BASE}/api/templates/render`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': API_KEY
},
body: JSON.stringify({
template: 'Hello {{ name }}!',
data: { name: 'John Doe' }
})
});
const result = await response.json();
console.log(result.result); // "Hello John Doe!"
}
import requests
import os
API_BASE = 'https://api.lorotemplates.com'
API_KEY = os.getenv('LORO_API_KEY')
def render_template(template, data):
response = requests.post(
f'{API_BASE}/api/templates/render',
headers={
'Content-Type': 'application/json',
'X-API-Key': API_KEY
},
json={
'template': template,
'data': data
}
)
result = response.json()
return result['result']
# Usage
output = render_template(
'Hello {{ name }}!',
{'name': 'John Doe'}
)
print(output) # "Hello John Doe!"
$template,
'data' => $data
]);
$context = stream_context_create([
'http' => [
'method' => 'POST',
'header' => "Content-Type: application/json\r\n" .
"X-API-Key: $apiKey\r\n",
'content' => $postData
]
]);
$response = file_get_contents("$apiBase/api/templates/render", false, $context);
$result = json_decode($response, true);
return $result['result'];
}
// Usage
$output = renderTemplate('Hello {{ name }}!', ['name' => 'John Doe']);
echo $output; // "Hello John Doe!"
?>
curl -X POST https://api.lorotemplates.com/api/templates/render \
-H "Content-Type: application/json" \
-H "X-API-Key: your-api-key-here" \
-d '{
"template": "Hello {{ name }}!",
"data": {
"name": "John Doe"
}
}'
Cause: Missing or invalid API key
Solution: Ensure your API key is included in the X-API-Key
header
Cause: Syntax error in your template or invalid JSON data
Solution: Use the template tester to debug your template and data
Cause: You've exceeded your monthly API call limit
Solution: Upgrade your plan or wait until next month
Cause: Invalid template ID
Solution: Verify the template ID exists in your dashboard
Need additional support?
Email us at admin@lorotemplates.com and we'll help you resolve any issues.
Made with care by the Loro Templates team