Skip to main content
Dynamic templates let you store a Handlebars .hbs template on Paubox once and reference it by name when sending. Variable substitution, conditionals, and loops are resolved server-side before delivery — keeping your send requests small and consistent.

Handlebars syntax

Templates use Handlebars syntax. The most common constructs:
SyntaxDescription
{{variable}}Insert the value of a variable
{{#if condition}}...{{/if}}Conditional block (truthy check)
{{#each items}}...{{/each}}Loop over an array; use {{this}} for each item

Example template

Save the following as welcome.hbs:
Hello {{name}},

Thank you for signing up{{#if plan}} for the {{plan}} plan{{/if}}.

{{#if items}}
Your selected items:
{{#each items}}- {{this}}
{{/each}}
{{/if}}

The Paubox Team

Workflow

1. Upload the template

Upload your .hbs file via POST /dynamic_templates. The data[name] value becomes the identifier you use when sending.
curl -X POST https://api.paubox.net/v1/YOUR_USERNAME/dynamic_templates \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "data[name]=welcome" \
  -F "data[body]=@welcome.hbs"

2. Send a templated message

Reference the template by name in POST /templated_messages. Pass variable values as a JSON string in template_values.
curl -X POST https://api.paubox.net/v1/YOUR_USERNAME/templated_messages \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "data": {
      "template_name": "welcome",
      "template_values": "{\"name\":\"Jane\",\"plan\":\"Pro\",\"items\":[\"Email API\",\"HIPAA Compliance\"]}",
      "message": {
        "recipients": ["jane@example.com"],
        "headers": {
          "subject": "Welcome to Paubox",
          "from": "noreply@YOUR_DOMAIN.com"
        }
      }
    }
  }'
template_values must be a JSON-encoded string, not a JSON object. Stringify it before including it in the request body.

Managing templates

OperationAPI reference
List all templatesList dynamic templates
Create a templateCreate a dynamic template
Get a templateGet a dynamic template
Update a templateUpdate a dynamic template
Delete a templateDelete a dynamic template
Send using a templateSend a templated message