Templates
Create reusable message templates with variables
Templates
Templates allow you to create reusable message formats with dynamic variables. Design once, use across all channels.
What are Templates?
Templates are pre-defined message formats that can include:
- Static content - Text that never changes
- Variables - Dynamic data inserted at send time
- Channel-specific formatting - Customize for each channel
- Conditional logic - Show/hide content based on data
Creating Templates
Via Dashboard
- Go to Templates → Create Template
- Fill in the details:
- Name - Unique identifier (e.g.,
welcome-email) - Channel - Email, SMS, Push, Slack, or Webhook
- Subject - Email subject line (email only)
- Body - Message content with variables
- Name - Unique identifier (e.g.,
- Click Save Template
Via API
curl -X POST https://api.notigrid.com/v1/templates \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "welcome-email",
"channel": "email",
"subject": "Welcome to {{app_name}}!",
"body": "Hi {{user_name}},\n\nThanks for joining {{app_name}}. We are excited to have you on board!\n\nGet started: {{onboarding_url}}\n\nBest,\nThe {{app_name}} Team"
}'Template Variables
Syntax
Variables use double curly braces: {{variable_name}}
Hello {{user_name}}, your order #{{order_id}} has shipped!Nested Variables
Access nested object properties with dot notation:
Customer: {{customer.name}}
Email: {{customer.email}}
Address: {{customer.address.city}}, {{customer.address.state}}Array Access
Access array items by index:
First item: {{items.0.name}}
Second item: {{items.1.name}}Using Templates
Send a notification using a template:
curl -X POST https://api.notigrid.com/v1/notifications \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"template": "welcome-email",
"to": "user@example.com",
"data": {
"app_name": "NotiGrid",
"user_name": "John",
"onboarding_url": "https://app.notigrid.com/onboard"
}
}'Template Helpers
Conditional Logic
Show content only if a condition is true:
{{#if premium_user}}
Thank you for being a premium member!
{{/if}}
{{#unless verified}}
Please verify your email address.
{{/unless}}Loops
Iterate over arrays:
Your order contains:
{{#each items}}
- {{name}} ({{quantity}}x) - ${{price}}
{{/each}}
Total: ${{total}}Formatting
Dates:
Order date: {{formatDate order_date "MMMM DD, YYYY"}}Currency:
Amount: {{formatCurrency amount "USD"}}Numbers:
Items: {{formatNumber item_count}}Channel-Specific Templates
Email Templates
{
"name": "order-confirmation",
"channel": "email",
"subject": "Order #{{order_id}} Confirmed",
"body": "<!DOCTYPE html>\n<html>\n<head>\n <style>\n .header { background: #007bff; color: white; padding: 20px; }\n .content { padding: 20px; }\n </style>\n</head>\n<body>\n <div class=\"header\">\n <h1>Order Confirmed!</h1>\n </div>\n <div class=\"content\">\n <p>Hi {{customer_name}},</p>\n <p>Your order #{{order_id}} has been confirmed.</p>\n <table>\n {{#each items}}\n <tr>\n <td>{{name}}</td>\n <td>{{quantity}}</td>\n <td>${{price}}</td>\n </tr>\n {{/each}}\n </table>\n <p><strong>Total: ${{total}}</strong></p>\n </div>\n</body>\n</html>"
}SMS Templates
Keep SMS under 160 characters:
{
"name": "verification-code",
"channel": "sms",
"body": "Your {{app_name}} verification code is: {{code}}. Expires in {{expires_in}} minutes."
}Slack Templates
Use Slack's Block Kit:
{
"name": "new-signup",
"channel": "slack",
"body": "New user signup!",
"metadata": {
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*New User Signup*\nName: {{user_name}}\nEmail: {{user_email}}\nPlan: {{plan}}"
}
}
]
}
}Template Versioning
Templates support versioning to maintain backwards compatibility:
Creating a Version
- Edit an existing template
- Make your changes
- Click Save as New Version
- Previous version remains accessible
Using Specific Versions
curl -X POST https://api.notigrid.com/v1/notifications \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"template": "welcome-email",
"template_version": 2,
"to": "user@example.com",
"data": {...}
}'Template Testing
Test Mode
Test templates before deploying:
curl -X POST https://api.notigrid.com/v1/templates/welcome-email/test \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"data": {
"user_name": "Test User",
"app_name": "TestApp"
}
}'Returns the rendered template without sending:
{
"rendered": {
"subject": "Welcome to TestApp!",
"body": "Hi Test User,\n\nThanks for joining TestApp..."
}
}Preview in Dashboard
- Go to Templates → [Your Template]
- Click Preview
- Enter sample data
- See rendered output
Best Practices
1. Use Descriptive Names
Good: order-shipped-email, password-reset-sms
Bad: template1, email-v2
2. Provide Default Values
Hello {{user_name "valued customer"}},If user_name is missing, uses "valued customer"
3. Keep SMS Concise
- Target 160 characters
- Use URL shorteners for links
- Avoid special characters (costs extra)
4. Design for Mobile
- Use responsive email templates
- Test on multiple devices
- Keep important content above fold
5. Version Control
- Create new versions for significant changes
- Document version changes
- Test thoroughly before switching
6. Localization
Create separate templates for each language:
welcome-email-en
welcome-email-es
welcome-email-frCommon Patterns
Welcome Email
Subject: Welcome to {{company_name}}!
Hi {{first_name}},
Welcome aboard! We're thrilled to have you as part of {{company_name}}.
Here's what you can do next:
1. Complete your profile: {{profile_url}}
2. Explore our features: {{features_url}}
3. Join our community: {{community_url}}
Need help? Reply to this email or visit {{support_url}}.
Best regards,
The {{company_name}} TeamOrder Confirmation
Subject: Order #{{order_id}} Confirmed
Hi {{customer_name}},
Thank you for your order!
Order #{{order_id}}
Date: {{order_date}}
Items:
{{#each items}}
- {{name}} ({{quantity}}x) - ${{price}}
{{/each}}
Subtotal: ${{subtotal}}
Shipping: ${{shipping}}
Tax: ${{tax}}
Total: ${{total}}
Estimated delivery: {{delivery_date}}
Track your order: {{tracking_url}}Password Reset
Subject: Reset Your Password
Hi {{user_name}},
We received a request to reset your password.
Click here to reset: {{reset_url}}
This link expires in {{expires_in}} hours.
If you didn't request this, please ignore this email.
{{company_name}} Security TeamTroubleshooting
Variable Not Rendering
Issue: {{variable}} appears as literal text
Solutions:
- Check variable name spelling
- Ensure data is passed in request
- Verify variable exists in data object
HTML Not Rendering
Issue: HTML shows as plain text in email
Solutions:
- Set content type to HTML in template settings
- Ensure email client supports HTML
- Provide plain text fallback
Template Not Found
Issue: 404 error when sending
Solutions:
- Verify template name is correct
- Check template exists in your organization
- Ensure you have access permissions
API Reference
List Templates
GET /v1/templatesGet Template
GET /v1/templates/{template_name}Create Template
POST /v1/templatesUpdate Template
PUT /v1/templates/{template_name}Delete Template
DELETE /v1/templates/{template_name}Test Template
POST /v1/templates/{template_name}/testFor complete API documentation, see API Reference.