Pushary Docs
Pushary Docs
DashboardPricingGetting Started

Client SDK

InstallationAPI Reference

Server SDK

InstallationAuthenticationSubscribersCampaignsTemplatesSend NotificationsREST API Reference

Templates

Create reusable notification templates

Overview

Templates let you create reusable notification designs that can be used across campaigns. Store common notification formats and quickly create campaigns from them.

List Templates

const { data } = await pushary.templates.list()

for (const template of data) {
  console.log(template.name, template.title)
}

Create Template

const template = await pushary.templates.create({
  name: 'Order Shipped',
  title: 'Your Order is On Its Way! 📦',
  body: 'Order {{orderId}} has shipped. Track your delivery.',
  iconUrl: 'https://example.com/shipping-icon.png',
  actionUrl: 'https://example.com/track/{{orderId}}',
})

Create Options

FieldTypeRequiredDescription
namestringYesTemplate name
titlestringYesNotification title
bodystringYesNotification body
iconUrlstringNoIcon URL
imageUrlstringNoLarge image URL
actionUrlstringNoClick destination

Get Template

const template = await pushary.templates.get('tmpl_123')

console.log(template.title)  // 'Your Order is On Its Way! 📦'

Template Object

interface Template {
  id: string
  siteId: string
  name: string
  title: string
  body: string
  iconUrl?: string
  imageUrl?: string
  actionUrl?: string
  createdAt: string
}

Update Template

const updated = await pushary.templates.update('tmpl_123', {
  body: 'Your order {{orderId}} is out for delivery!',
})

Delete Template

await pushary.templates.delete('tmpl_123')

Template Variables

Use double curly braces for variables:

await pushary.templates.create({
  name: 'Welcome Email',
  title: 'Welcome, {{userName}}!',
  body: 'Thanks for joining {{siteName}}. Get started now!',
})

Variables are replaced when creating campaigns or sending notifications.

Common Templates

Order Updates

await pushary.templates.create({
  name: 'Order Confirmed',
  title: 'Order Confirmed! ✅',
  body: 'Your order #{{orderId}} for {{amount}} is confirmed.',
  actionUrl: 'https://example.com/orders/{{orderId}}',
})

await pushary.templates.create({
  name: 'Order Shipped',
  title: 'On Its Way! 📦',
  body: 'Your order #{{orderId}} has shipped. Arrives {{deliveryDate}}.',
  actionUrl: 'https://example.com/track/{{orderId}}',
})

User Engagement

await pushary.templates.create({
  name: 'New Message',
  title: 'New message from {{senderName}}',
  body: '{{preview}}',
  actionUrl: 'https://example.com/messages/{{messageId}}',
})

await pushary.templates.create({
  name: 'Cart Reminder',
  title: 'You left something behind! 🛒',
  body: 'Complete your purchase of {{itemCount}} items.',
  actionUrl: 'https://example.com/cart',
})

Promotions

await pushary.templates.create({
  name: 'Flash Sale',
  title: '⚡ Flash Sale: {{discount}}% Off!',
  body: '{{itemName}} is on sale for the next {{hours}} hours.',
  actionUrl: 'https://example.com/sale/{{saleId}}',
})

On this page

OverviewList TemplatesCreate TemplateCreate OptionsGet TemplateTemplate ObjectUpdate TemplateDelete TemplateTemplate VariablesCommon TemplatesOrder UpdatesUser EngagementPromotions