API reference · v1

Build on Tifamail

Send branded email, generate AI documents on your letterhead and schedule meetings from your own software. Everything the API sends uses your company's templates automatically.

Base URL
https://tifamail.com/api/v1
All requests and responses are JSON (UTF-8). Timestamps are ISO 8601 in UTC. Successful responses wrap the result in data.

Authentication

Company admins create keys under Workspace → API keys. A key is shown once — store it in a secret manager. Send it as a Bearer token on every request. Keys act with the permissions of the admin who created them and can be revoked instantly.

curl https://tifamail.com/api/v1/me \
  -H "Authorization: Bearer $TIFAMAIL_KEY"

Errors & rate limits

Errors return an HTTP status and a body like {"error":{"code":"insufficient_credit","message":"…"}}. Each key may make 600 requests per hour.

401 unauthorizedMissing, malformed or revoked key.
402 insufficient_creditThe AI pre-check estimated more than your credit or the user's monthly limit.
402 workspace_inactiveAnnual maintenance lapsed or workspace suspended.
404 not_foundUnknown resource, or it belongs to another workspace.
422 validation / request_failedInvalid input; the message explains what to fix.
429 rate_limitedToo many requests; retry after the hour window.
GET/me

Get workspace

Company details, AI credit and storage.

Request
curl https://tifamail.com/api/v1/me \
  -H "Authorization: Bearer $TIFAMAIL_KEY"
Response
{"data":{"company":{"name":"Acacia & Partners","domain":"acaciapartners.co.ke","domain_verified":true,"currency":"KES"},"ai_credit":{"kes":482.15,"display":"KES 482.15"},"storage":{"used_bytes":52428800,"quota_bytes":10737418240}}}
GET/mailboxes

List mailboxes

Every address in the workspace.

Request
curl https://tifamail.com/api/v1/mailboxes \
  -H "Authorization: Bearer $TIFAMAIL_KEY"
Response
{"data":[{"id":3,"address":"accounts@acaciapartners.co.ke","display_name":"Accounts","user_id":2}]}
GET/usage?month=2026-09

AI usage

AI requests, tokens and amounts charged for a month (defaults to the current month).

monthstringYYYY-MM
Request
curl "https://tifamail.com/api/v1/usage?month=2026-09" \
  -H "Authorization: Bearer $TIFAMAIL_KEY"
Response
{"data":{"month":"2026-09","items":[{"feature":"document","model":"claude-sonnet-5-5","requests":12,"input_tokens":48210,"output_tokens":39822,"charged_kes":94.6}],"total_kes":94.6}}
GET/messages?mailbox=accounts@…&folder=inbox

List messages

Newest first. Page with before_id.

mailboxstringAddress or mailbox id (required)
folderstringinbox · sent · drafts · archive · spam · trash
limitint1–100, default 25
before_idintReturn messages older than this id
Request
curl "https://tifamail.com/api/v1/messages?mailbox=accounts@acaciapartners.co.ke&limit=10" \
  -H "Authorization: Bearer $TIFAMAIL_KEY"
Response
{"data":[{"id":881,"folder":"inbox","from":[{"name":"Tifa","email":"tifa@savannafoods.co.ke"}],"subject":"Payment sent","snippet":"We have paid INV-2026-0142…","date":"2026-09-30T08:14:02+00:00","read":false,"has_attachments":true}],"next_before_id":872}
GET/messages/{id}

Get a message

Full HTML and text body plus attachment metadata.

Request
curl https://tifamail.com/api/v1/messages/881 \
  -H "Authorization: Bearer $TIFAMAIL_KEY"
Response
{"data":{"id":881,"subject":"Payment sent","html":"<p>…</p>","text":"…","attachments":[{"id":55,"filename":"receipt.pdf","mime":"application/pdf","size":48211}]}}
POST/messages

Send a message

Sends from any workspace address. Your HTML is placed inside the company's branded email template unless template is false.

fromstringWorkspace address (required)
to / cc / bccstring[]Recipients (up to 100 total)
subjectstringSubject line
htmlstringBody HTML (or use text)
templateboolDefault true
attachmentsobject[]{filename, mime, content_base64}, 25 MB total
Request
curl -X POST https://tifamail.com/api/v1/messages \
  -H "Authorization: Bearer $TIFAMAIL_KEY" \
  -H "Content-Type: application/json" \
  -d '{"from":"accounts@acaciapartners.co.ke",
       "to":["tifa@savannafoods.co.ke"],
       "subject":"Invoice INV-2026-0142",
       "html":"<p>Hi Tifa, please find your invoice attached.</p>"}'
Response
{"data":{"id":902,"status":"sent","message_id":"8f2c…@acaciapartners.co.ke"}}
GET/messages/{id}/attachments/{attachment_id}

Download attachment

Returns the file as base64.

Request
curl https://tifamail.com/api/v1/messages/881/attachments/55 \
  -H "Authorization: Bearer $TIFAMAIL_KEY"
Response
{"data":{"id":55,"filename":"receipt.pdf","mime":"application/pdf","size":48211,"content_base64":"JVBERi0xLjcK…"}}
POST/ai/email

Write an email with AI

Drafts subject and body in your company voice. A cheaper model estimates the cost first; the request is declined with 402 if credit is insufficient. Billed at provider cost + 50%.

fromstringSender address (required — used for the sign-off)
promptstringWhat the email should say
tonestringprofessional · friendly · formal · persuasive · concise · apologetic
Request
curl -X POST https://tifamail.com/api/v1/ai/email \
  -H "Authorization: Bearer $TIFAMAIL_KEY" \
  -d '{"from":"tifa.ben@acaciapartners.co.ke","prompt":"Remind Savanna Foods their invoice is 14 days overdue","tone":"friendly"}'
Response
{"data":{"subject":"A friendly reminder about INV-2026-0142","html":"<p>Dear Tifa,</p>…","charged_kes":1.42}}
POST/documents

Generate a document

Creates any business document on your letterhead. POST to /documents/{id} with a new prompt to revise it into a new version.

promptstringDescribe the document (required)
Request
curl -X POST https://tifamail.com/api/v1/documents \
  -H "Authorization: Bearer $TIFAMAIL_KEY" \
  -d '{"prompt":"Quotation for 40 ergonomic chairs at KES 12,500 each, delivery within Nairobi, valid 30 days"}'
Response
{"data":{"id":41,"version":1,"title":"Quotation","html":"<h1 class=\"doc-title\">Quotation</h1>…","charged_kes":6.18,"view_url":"https://tifamail.com/document?id=41"}}
GET/documents

List documents

Most recently updated first.

Request
curl https://tifamail.com/api/v1/documents \
  -H "Authorization: Bearer $TIFAMAIL_KEY"
Response
{"data":[{"id":41,"title":"Quotation","version":2,"updated_at":"2026-09-30T09:00:00+00:00"}]}
GET/documents/{id}

Get a document

Returns the body HTML and a complete, print-ready letterhead HTML page (A4) you can render to PDF.

Request
curl https://tifamail.com/api/v1/documents/41 \
  -H "Authorization: Bearer $TIFAMAIL_KEY"
Response
{"data":{"id":41,"title":"Quotation","version":2,"html":"…","letterhead_html":"<!DOCTYPE html>…"}}
POST/meetings

Send meeting invitations

Each invitee receives a branded invitation with Confirm / Maybe / Decline buttons and an .ics calendar file.

fromstringOrganiser address (required)
titlestringMeeting title
starts_atstringISO 8601, e.g. 2026-10-14T10:00
timezonestringIANA zone, default Africa/Nairobi
durationintMinutes (default 30)
link / location / agendastringOptional
inviteesstring[]Guest emails (max 100)
Request
curl -X POST https://tifamail.com/api/v1/meetings \
  -H "Authorization: Bearer $TIFAMAIL_KEY" \
  -d '{"from":"tifa.ben@acaciapartners.co.ke","title":"Quarterly review",
       "starts_at":"2026-10-14T10:00","timezone":"Africa/Nairobi","duration":60,
       "link":"https://meet.google.com/abc-defg-hij","invitees":["tifa@savannafoods.co.ke"]}'
Response
{"data":{"id":17,"sent":1,"errors":[]}}
GET/meetings/{id}

RSVP status

Live responses from every guest.

Request
curl https://tifamail.com/api/v1/meetings/17 \
  -H "Authorization: Bearer $TIFAMAIL_KEY"
Response
{"data":{"id":17,"title":"Quarterly review","status":"scheduled","invitees":[{"email":"tifa@savannafoods.co.ke","status":"accepted","responded_at":"2026-09-30T10:02:11+00:00"}]}}

Inbound mail webhook platform operators

Your MX relay (Postfix pipe, Cloudflare Email Worker, or any service that can POST raw MIME) delivers incoming mail here. The platform matches recipients to hosted mailboxes, encrypts and files the message, and de-duplicates by Message-ID.

curl -X POST "https://tifamail.com/hook/inbound?secret=$INBOUND_SECRET&to=tifa@acme.co.ke" \
  -H "Content-Type: message/rfc822" \
  --data-binary @message.eml

Also accepts multipart form posts with the MIME in email, message, raw or body-mime.