Sending

Templates

Templates store reusable email designs server-side. Reference them by ID when sending and update all future sends by editing one template.

Create a Template

curl -X POST https://api.postmta.com/v1/templates -H "Authorization: Bearer pmta_live_xxxx" -H "Content-Type: application/json" -d '{"name":"welcome_email","description":"Sent to new users after signup","subject":"Welcome to Example Co!","html":"

Hi there

Welcome to Example Co.

","text":"Hi there, Welcome to Example Co."}'

Substitution Variables

Use {variable_name} syntax in subject, HTML, and text bodies.

VariableExampleNotes
{first_name}AliceSimple text substitution
{company.name}Acme CorpNested object access
{#if vip}...{/if}ConditionalConditional blocks

Send Using a Template

curl -X POST https://api.postmta.com/v1/messages/send -H "Authorization: Bearer pmta_live_xxxx" -d '{"from":{"address":"hello@shop.example.com"},"to":[{"address":"alice@example.com"}],"template_id":"tpl_welcome_email","template_data":{"first_name":"Alice","company_name":"Acme Corp","vip":false}}'

Template Versions

Every template edit creates a new version. Activate a specific version:

curl -X PUT https://api.postmta.com/v1/templates/tpl_welcome_email/activate -H "Authorization: Bearer pmta_live_xxxx" -d '{"version":2}'

Preview a Template

curl -X POST https://api.postmta.com/v1/templates/tpl_welcome_email/preview -H "Authorization: Bearer pmta_live_xxxx" -d '{"first_name":"Alice","company_name":"Acme Corp"}'

Returns the fully rendered HTML and text with all substitutions applied.