Skip to main content
The AhaSend CLI uses MiniJinja templating (Jinja2-compatible syntax) for creating personalized emails. Templates are rendered by the AhaSend API using MiniJinja. Subject lines also support substitutions. Use default for missing values and test your rendering with sandbox mode; see API templates. Before running the examples, log in with a full API key, use your verified sender domain, and replace YOUR_RESOURCE_ID with a resource UUID from your test account. Create any named template, recipient, attachment, or JSON files first. Shell examples use Bash; examples that read JSON with jq need jq installed. Sends use sandbox mode.

Template Basics

Use double curly braces for variable substitution:

Substitution Types

Global Substitutions

Applied to all recipients - use for company-wide data:
company-data.json

Recipient Substitutions

Per-recipient data from CSV/JSON files:

Basic Examples

Simple Template

Conditional Content

Lists and Loops

Testing Templates

Test templates using sandbox mode:
Then check the AhaSend dashboard to see the rendered message.

Best Practices

  1. Use meaningful variable names: {{customer_first_name}} not {{fn}}
  2. Provide default values: {{name|default("Friend")}}
  3. Test with real data: Use sandbox mode before sending
  4. Keep templates simple: Complex logic belongs in your application
  5. Global vs recipient data: Company info in global, personal info per recipient

Next Steps