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 KeySend an email using a template with variable substitution.
| Parameter | Type | In | Description |
|---|---|---|---|
fromrequired | string | body | Sender email address |
torequired | string[] | body | Array of recipient email addresses |
templateIdrequired | string | body | UUID of the email template |
variables | Record<string, string> | body | Key-value pairs for template variable substitution |
subject | string | body | Override 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"
}