Email Templates API
All endpoints require authentication and templates tool permissions. Templates are stored in the recruitment_email_templates table.
List Templates
Section titled “List Templates”GET /api/email-templatesPermission: templates:view
Query parameters:
| Param | Type | Description |
|---|---|---|
type | string | Filter by template type (e.g. contact) |
category | string | Filter by category (e.g. general) |
Response: { templates }
Get Template
Section titled “Get Template”GET /api/email-templates/:idPermission: templates:view
Path parameters:
| Param | Type | Description |
|---|---|---|
id | string | Template ID |
Response: { template }
Error: 404 if template not found.
Create Template
Section titled “Create Template”POST /api/email-templatesPermission: templates:update
Body:
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Template name |
subject | string | Yes | Email subject line |
body | string | Yes | Email body (supports merge fields) |
type | string | Yes | Template type (default: contact) |
category | string | No | Category (default: general) |
Response: { template } (201)
Update Template
Section titled “Update Template”PUT /api/email-templates/:idPermission: templates:update
Path parameters:
| Param | Type | Description |
|---|---|---|
id | string | Template ID |
Body (all fields optional):
| Field | Type | Description |
|---|---|---|
name | string | Template name |
subject | string | Subject line |
body | string | Email body |
category | string | Category |
is_active | boolean | Active status |
Response: { template }
Error: 404 if template not found.
Delete Template
Section titled “Delete Template”DELETE /api/email-templates/:idPermission: templates:manage
Path parameters:
| Param | Type | Description |
|---|---|---|
id | string | Template ID |
Response: { ok: true }
Preview Template with Contact Merge Fields
Section titled “Preview Template with Contact Merge Fields”POST /api/email-templates/:id/preview-contactResolves merge fields in the template’s subject and body using a contact’s data. Useful for previewing how a template will look before sending.
Permission: templates:view
Path parameters:
| Param | Type | Description |
|---|---|---|
id | string | Template ID |
Body:
| Field | Type | Required | Description |
|---|---|---|---|
contact_id | string | No | Contact ID to use for merge field resolution. If omitted, uses placeholder values. |
Response: { subject, body } — the resolved subject and body with merge fields replaced.
Error: 404 if template not found.