# Templates

Source: https://pushary.com/docs/web-push/server-sdk/templates
Last updated: 2026-05-11

> Create reusable notification templates

## Overview [#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 [#list-templates]

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

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

## Create Template [#create-template]

```typescript
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 [#create-options]

| Field       | Type     | Required | Description        |
| ----------- | -------- | -------- | ------------------ |
| `name`      | `string` | Yes      | Template name      |
| `title`     | `string` | Yes      | Notification title |
| `body`      | `string` | Yes      | Notification body  |
| `iconUrl`   | `string` | No       | Icon URL           |
| `imageUrl`  | `string` | No       | Large image URL    |
| `actionUrl` | `string` | No       | Click destination  |

## Get Template [#get-template]

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

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

### Template Object [#template-object]

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

## Update Template [#update-template]

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

## Delete Template [#delete-template]

```typescript
await pushary.templates.delete('tmpl_123')
```

## Template Variables [#template-variables]

Use double curly braces for variables:

```typescript
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 [#common-templates]

### Order Updates [#order-updates]

```typescript
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 [#user-engagement]

```typescript
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 [#promotions]

```typescript
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}}',
})
```