Emails API
Complete API reference for sending, listing, searching, scheduling, and retrying emails in Taifa Mail.
Base URL: https://govconnect.ke/v1
All endpoints require authentication via API Key or JWT cookie. API keys are passed as Authorization: Bearer tfm_k_....
Send an email
Send a single email. Returns 202 Accepted; the email is queued for delivery.
Request body:
| Field | Type | Required | Description |
|---|---|---|---|
from_ | object | Yes | Sender address object with email and optional name. |
from_.email | string | Yes | Sender email address. Must be a registered sender on a verified domain. |
from_.name | string | No | Sender display name. |
to | array | Yes | Array of recipient objects. At least one required. |
to[].email | string | Yes | Recipient email address. |
to[].name | string | No | Recipient display name. |
subject | string | Yes | Email subject line. |
html | string | No | HTML body. At least one of html or text is required. |
text | string | No | Plain-text body. |
cc | array | No | Array of CC recipient objects. |
bcc | array | No | Array of BCC recipient objects. |
reply_to | object | No | Reply-to address object with email and optional name. |
headers | object | No | Custom email headers as a string-to-string map. |
tags | string[] | No | Tags for filtering in logs and analytics. |
send_at | string (ISO 8601) | No | Schedule for future delivery. Must be 1 minute to 30 days in the future. Starter plan and above only. |
attachments | array | No | File attachments. See below. |
Attachment fields:
| Field | Type | Required | Description |
|---|---|---|---|
filename | string | Yes | File name. Must not contain path separators. |
content_base64 | string | Yes | File body as base64 (no data: prefix). |
content_type | string | No | MIME type. Defaults to application/octet-stream. |
Per-file and combined attachment size are both capped at 24 MiB.
Response (202 Accepted):
Send batch emails
Send multiple emails in a single request. Requires the Starter plan or above. The request body is a JSON array of email objects, each using the same shape as the single send body.
| Plan | Max emails per batch |
|---|---|
| Free | Not available |
| Starter | 25 |
| Pro | 50 |
| Business | 100 |
Batch sending requires the Starter plan or above. Free plan accounts receive a 403 error.
Response (202 Accepted):
Each email is processed independently. A failed email has "id": null, "status": "error", and a rejection_reason.
List emails
Returns an array of emails, newest first.
Query parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
status | string | -- | Filter by status. |
page | integer | 0 | Zero-based page number. |
limit | integer | 20 | Results per page (1-100). |
Response:
Get email updates
Returns up to 50 emails created or updated after a given timestamp. Useful for polling live status changes.
Query parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
since | string (ISO 8601) | Yes | Return emails updated after this timestamp. |
Response shape matches List emails.
Search emails
Search emails by recipient, sender, subject, status, or tags.
Query parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
q | string | "" | Free-text query. Supports inline tokens (see below). |
status | string | -- | Filter by status. |
tag | string | -- | Filter by an exact tag. |
page | integer | 0 | Zero-based page number. |
limit | integer | 20 | Results per page (1-100). |
The q parameter accepts inline tokens that map to structured filters: to:gmail.com, from:hello@govconnect.ke, status:bounced, domain:govconnect.ke, tag:welcome. Any remaining words are matched as free text across sender, subject, and recipients.
Response: an array of email objects with id, from_address, to_addresses, subject, status, tags, source, created_at, and delivered_at.
List scheduled emails
Returns all emails scheduled for future delivery that have not yet been sent.
Response:
Cancel a scheduled email
Cancels a scheduled email before it sends. Returns 404 if the email is not scheduled.
Response (200 OK):
Send a scheduled email now
Dispatches a scheduled email immediately instead of waiting for scheduled_at.
Response (200 OK):
Validate an email (dry run)
Checks whether an email would send without actually sending it. Validates the sender address, domain verification, plan limits, and account restrictions. The request body uses the same shape as Send an email.
Response (200 OK):
When validation fails, valid and can_send are false and issues lists the problems. Each issue is { "field": "...", "error": "..." }. The field is one of account, from, limits, to, or content.
Use the validate endpoint in your CI/CD pipeline to catch sender or configuration errors before they reach production.
Get email detail
Returns full details for a single email, including the body, headers, and event timeline.
Response:
Retry an email
Resends a previously failed email. Only emails with status bounced, rejected, or failed can be retried; any other status returns 409 Conflict. A new email row is created, linked to the original via retry_of_id.
Response (202 Accepted):
Get email events
Returns the event timeline for a specific email.
Response:
Saved searches
Named filter sets for the email log, stored per user.
List saved searches
Returns { "searches": [...] }.
Replace saved searches
Replaces the entire saved-search list. Body: { "searches": [...] }, capped at 50 entries. Each entry supports id, name, query, range, status, domain, and source fields.