Templates
Create reusable, variable-driven content for any channel
Overview
Templates let you define reusable content once and send it across email, SMS, push, and in-app notifications by referencing a name and passing variables. This is the recommended approach for anything sent more than once — OTP codes, welcome messages, receipts, alerts — since it keeps copy out of your codebase and editable without a deploy.
Referencing a template
Pass a template object with name and, optionally, data for variable interpolation:
await nutifar.notifications.sendEmail({
appId: "app_123",
to: "user@example.com",
template: {
name: "welcome",
data: { name: "Yusuf" },
},
});The same pattern works identically across channels:
await nutifar.notifications.sendSMS({
appId: "app_123",
to: "+15551234567",
template: {
name: "otp-code",
data: { code: "123456" },
},
});Templates are scoped per appId — a template named welcome in one app is a
completely separate template from welcome in another app under the same
tenant. If no template with that name exists for the app, the send will fail
rather than silently falling back to raw content.
Variable interpolation
Whatever you pass in template.data is available to the template body as variables. Keep data limited to the values that actually change between sends — recipient name, dynamic amounts, codes, links. Static copy (subject lines, boilerplate) belongs in the template itself, not in data.
await nutifar.notifications.sendEmail({
appId: "app_123",
to: "user@example.com",
template: {
name: "invoice-receipt",
data: {
invoiceNumber: "INV-1029",
amount: "$49.00",
},
},
});Confirm the exact templating syntax (e.g. Handlebars-style {{ variable }}
vs. another engine) against the template rendering implementation before
publishing — not yet verified.
Creating and managing templates
Templates are created and managed from your tenant dashboard under [Channel] → Templates. There's currently no API for creating or updating templates programmatically — the dashboard is the only way to manage them.
Each template has:
- A unique
name(used to reference it from the SDK) - Channel-specific content (HTML/text body for email, message body for SMS, title/body for push and in-app)
- A usage counter, incremented automatically each time the template is sent
Email templates
Email templates support two authoring modes in the dashboard:
- AI-generated — describe what you want and get a starting draft, which you can then refine before publishing.
- Block-based editor — build the email visually from pre-defined content blocks (text, image, button, divider, etc.), giving more direct control over layout than the AI draft alone.
Both modes produce a template you reference the same way from the SDK — the authoring method has no effect on how you call sendEmail.
Details of the AI generation flow and available block types haven't been confirmed in this conversation — fill in once the dashboard editor is finalized.
SMS, push, and in-app templates
These channels use a simpler, plain-text form in the dashboard — enter the message body (and title, for push/in-app), with variable placeholders for anything passed via template.data. There's no block or AI-assisted editor for these channels, since the content is short-form and doesn't need visual layout.
Programmatic template management (create/update via API) may be added later. For now, treat templates as configuration you set up once in the dashboard, then reference by name from your code.
Sending without a template
Omit template and pass content directly for one-off or dynamically generated sends — see the Email and SMS pages for channel-specific fields.
Errors
Placeholder pending confirmation against actual API error responses.
| Error | Cause |
|---|---|
template_not_found | template.name doesn't exist for this appId |