Templates

Send emails using pre-built templates with dynamic variable substitution.

Templates are created and managed through the dashboard. Each template has a name, subject, HTML body, and optional plain text body.

Variables use double-curly-brace syntax: {{variableName}}

When sending with a template, pass the templateId and a variables object. The API will substitute all {{variables}} in the subject, HTML body, and text body.

Explicit values in the request (subject, html, text) override template values, allowing per-send customization.
POST/v1/sendAPI Key

Send an email using a template with variable substitution.

ParameterTypeInDescription
fromrequiredstringbodySender email address
torequiredstring[]bodyArray of recipient email addresses
templateIdrequiredstringbodyUUID of the email template
variablesRecord<string, string>bodyKey-value pairs for template variable substitution
subjectstringbodyOverride template subject

Request

bash
curl -X POST https://your-posthawk-instance.com/v1/send \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your_api_key" \
  -d '{
    "from": "hello@yourdomain.com",
    "to": ["user@example.com"],
    "templateId": "template-uuid-here",
    "variables": {
      "firstName": "John",
      "companyName": "Acme Inc",
      "unsubscribeUrl": "https://example.com/unsub/123"
    }
  }'

Response

json
{
  "success": true,
  "scheduled": false,
  "jobId": "abc-123-def",
  "message": "Email queued for sending",
  "statusUrl": "/v1/send/abc-123-def"
}