Prompt
email API with templates and suppression list
Latest observation
Nov 25, 2026
OpenAI APIWeb search: off
Here’s a solid design for an email API with templates and a suppression list.
Core concepts
1) Templates
Templates let you define reusable email bodies with variables.
Example fields:
idnamesubjecthtml_bodytext_bodyvariablesorschemacreated_atupdated_at
Example placeholders:
{{first_name}}{{order_id}}{{unsubscribe_link}}
2) Suppression list
A suppression list prevents emails from being sent to certain recipients.
Common suppression reasons:
- hard bounce
- complaint
- unsubscribe
- manual suppression
- invalid address
Example fields:
emailreasonsourcecreated_atexpires_atoptionalmetadata
Suggested API endpoints
Templates
POST /templates— create a templateGET /templates— list templatesGET /templates/{id}— get templatePUT /templates/{id}— update templateDELETE /templates/{id}— delete template
Sending email
POST /send- accepts recipient(s), template ID or raw content, and variables
- checks suppression list before sending
Suppression list
POST /suppressions— add email to suppression listGET /suppressions— list suppressionsGET /suppressions/{email}— check suppression statusDELETE /suppressions/{email}— remove suppression
Example send request
{
"to": ["user@example.com"],
"template_id": "tpl_123",
"variables": {
"first_name": "Sam",
"order_id": "A10042"
}
}
Possible response
{
"message_id": "msg_789",
"status": "queued",
"suppressed": []
}
If suppressed:
{
"status": "rejected",
"reason": "suppressed",
"suppressed": [
{
"email": "user@example.com",
"reason": "unsubscribe"
}
]
}
Send flow
- Receive send request
- Validate template or content
- Resolve variables
- Check each recipient against suppression list
- Reject suppressed recipients
- Queue or send remaining recipients
- Store delivery status/events
Data model sketch
templates
id
name
subject
html_body
text_body
created_at
updated_at
suppressions
id
email
reason
source
created_at
metadata
messages
id
template_id
to_email
subject
body_html
body_text
status
created_at
sent_at
Important behavior
- Normalize emails before suppression lookup, e.g. lowercase/trim
- Suppression check should happen before enqueueing
- Support suppression by domain if needed
- Keep audit trail for why an address was suppressed
- Allow webhook/event integration for bounce and complaint handling
Nice additions
- preview rendered template
- test send
- variables validation
- per-account suppression lists
- global suppression list
- unsubscribe link generation
- event webhooks for delivered/open/click/bounce
If you want, I can also provide:
- a REST API spec,
- a database schema, or
- a Node.js/Express implementation.