Templates API
API reference for creating, managing, and duplicating reusable email templates in Taifa Mail.
Base URL: https://govconnect.ke/v1
All endpoints require authentication via API Key or JWT cookie.
All template endpoints require the Starter plan or above. Free plan users will receive a 403 Forbidden error.
Create a template
Creates a new reusable email template. Template variables using the {{variable}} syntax in html_body and text_body are automatically extracted and stored with the template.
Request body:
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | A descriptive name for the template. |
subject | string | No | Default subject line. Supports {{variable}} syntax. |
html_body | string | No | HTML email body. Supports {{variable}} syntax. |
text_body | string | No | Plain-text email body. Supports {{variable}} syntax. |
blocks_json | object | No | Structured block data from the drag-and-drop editor. Used by the dashboard UI. |
Response (201 Created):
The variables field is auto-extracted from the html_body and text_body fields. You do not need to specify them manually.
List templates
Returns all templates for the authenticated workspace as a JSON array, ordered by most recently updated.
Response:
Python
Node.js
Get a template
Returns full details for a single template.
Response:
Update a template
Updates a template. Only include the fields you want to change. The variables field is re-extracted automatically from html_body and text_body on every update.
Request body:
| Field | Type | Required | Description |
|---|---|---|---|
name | string | No | New name for the template. |
subject | string | No | New subject line. |
html_body | string | No | New HTML body. |
text_body | string | No | New plain-text body. |
blocks_json | object | No | New block data from the drag-and-drop editor. |
cURL
Python
Node.js
Delete a template
Permanently deletes a template.
Response (204 No Content):
No response body.
Python
Node.js
Deleting a template is permanent. Any automations referencing this template will need to be updated to use a different template.
Duplicate a template
Creates a copy of an existing template. The new template's name is set to the original name with " (copy)" appended.
Response (201 Created):
Python
Node.js
Errors
| Status | Description |
|---|---|
401 Unauthorized | Missing or invalid authentication. |
403 Forbidden | Templates require the Starter plan or above, or the plan template limit was reached. |
404 Not Found | The template ID does not exist or is not visible to your workspace. |
422 Unprocessable Entity | Request body validation failed. |