Tmail API reference
Create mailboxes and read their mail programmatically. The API is in private beta — every request needs an API key, and keys are issued by the Tmail team rather than through self-serve sign-up.
https://tmailgo.com/api/v1Authentication
There are two layers. First, every request carries your API key in the X-API-Key header. Second, any request that reads a mailbox also proves access to that mailbox — either with its session token (Authorization: Bearer <token>) or its password (X-Mailbox-Password: <password>).
Authorizes use of the API. Keep it secret. Ask us to rotate or revoke it at any time.
A token or password for the specific mailbox. The key alone can never read a mailbox you don't hold the credential for, change an existing mailbox's password, or reach admin features.
Typical flow
POST /api/v1/mailboxes→ get anaddress,passwordandtoken.- Use the address to sign up on the target site.
- Poll
GET /api/v1/messages?address=…(with the token) until the verification mail arrives. - Open it with
GET /api/v1/messages/{id}and read the OTP / link from the body.
Endpoints
/api/v1/domainsAPI keyList the domains a new mailbox can be created on.
Request
curl https://tmailgo.com/api/v1/domains \
-H "X-API-Key: tmpk_live_…"Response
{
"domains": [
{ "id": "…", "domain": "tmail.pk" }
]
}/api/v1/mailboxesAPI keyGenerate a new mailbox. The domain is random unless you send { "domain": "…" }. Returns the address, its password, and a ready-to-use session token.
Request
curl -X POST https://tmailgo.com/api/v1/mailboxes \
-H "X-API-Key: tmpk_live_…" \
-H "Content-Type: application/json" \
-d '{ "domain": "tmail.pk" }' # optionalResponse
{
"address": "a1b2c3@tmail.pk",
"password": "…",
"token": "…" // use as Authorization: Bearer <token>
}/api/v1/tokenAPI keyExchange a mailbox's email + password for a session token you can reuse on reads (so you don't resend the password each time).
Request
curl -X POST https://tmailgo.com/api/v1/token \
-H "X-API-Key: tmpk_live_…" \
-H "Content-Type: application/json" \
-d '{ "address": "a1b2c3@tmail.pk", "password": "…" }'Response
{
"address": "a1b2c3@tmail.pk",
"token": "…"
}/api/v1/messages?address=<addr>API key + mailboxList the messages in a mailbox (newest first, up to 100). Authorize with the session token OR the mailbox password.
Request
# with a token
curl "https://tmailgo.com/api/v1/messages?address=a1b2c3@tmail.pk" \
-H "X-API-Key: tmpk_live_…" \
-H "Authorization: Bearer <token>"
# …or with the mailbox password
curl "https://tmailgo.com/api/v1/messages?address=a1b2c3@tmail.pk" \
-H "X-API-Key: tmpk_live_…" \
-H "X-Mailbox-Password: <password>"Response
{
"address": "a1b2c3@tmail.pk",
"messages": [
{
"id": "…",
"sender": "noreply@example.com",
"subject": "Your code is 123456",
"preview": "Your verification code…",
"is_read": false,
"received_at": "2026-10-29T12:00:00Z"
}
]
}/api/v1/messages/{id}?address=<addr>API key + mailboxFetch one full message — headers, body (HTML + text) and attachments.
Request
curl "https://tmailgo.com/api/v1/messages/<id>?address=a1b2c3@tmail.pk" \
-H "X-API-Key: tmpk_live_…" \
-H "Authorization: Bearer <token>"Response
{
"message": {
"id": "…",
"sender": "noreply@example.com",
"subject": "Your code is 123456",
"html": "<html>…</html>",
"text": "Your verification code is 123456",
"attachments": [ { "filename": "…", "url": "…" } ],
"received_at": "2026-10-29T12:00:00Z"
}
}/api/v1/messages/{id}?address=<addr>API key + mailboxMark a message as read.
Request
curl -X PATCH "https://tmailgo.com/api/v1/messages/<id>?address=a1b2c3@tmail.pk" \
-H "X-API-Key: tmpk_live_…" \
-H "Authorization: Bearer <token>"Response
{ "id": "…", "is_read": true }/api/v1/messages/{id}?address=<addr>API key + mailboxDelete a single message. (There is no endpoint to delete a mailbox.)
Request
curl -X DELETE "https://tmailgo.com/api/v1/messages/<id>?address=a1b2c3@tmail.pk" \
-H "X-API-Key: tmpk_live_…" \
-H "Authorization: Bearer <token>"Response
{ "deleted": true, "id": "…" }Errors
Every error has the shape { "error": "<code>", "message": "<human>" } with the matching HTTP status.
| Status | Code | Meaning |
|---|---|---|
| 400 | invalid_request | A required field (address, message id) is missing or malformed. |
| 400 | invalid_domain | The requested domain isn't in the current /domains list. |
| 401 | api_key_required | No X-API-Key header was sent. |
| 401 | invalid_api_key | The API key is not recognized. |
| 401 | api_key_revoked | The API key has been revoked. |
| 401 | invalid_credentials | Wrong mailbox address or password. |
| 401 | session_required / session_expired | The mailbox needs a valid token or password. |
| 404 | message_not_found | No such message in that mailbox. |
| 429 | rate_limited | Per-minute burst limit hit. Honor the Retry-After header. |
| 429 | daily_limit_exceeded | The key's daily request limit was reached. |
| 503 | service_unavailable | A backend dependency is temporarily unavailable. Retry. |
Rate limits & notes
- Each key has a per-minute burst limit and a per-day limit (set when the key is created).
- On
429, wait for the seconds in theRetry-Afterheader. - When you read with
X-Mailbox-Password, the response includes a freshX-Mailbox-Tokenheader — reuse it to avoid resending the password. - Inboxes are receive-only (the service does not send mail) and show the 100 most recent messages.
- There is no mailbox-delete endpoint, and keys can never change an existing mailbox's password.
Need a key or a higher limit? There is no self-serve sign-up during the private beta: keys are created and limits are set by the Tmail team. Tell us what you are building through the contact page.