Skip to main content
Developer API · v1

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.

Base URLhttps://tmailgo.com/api/v1

Authentication

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>).

Layer 1 — API key

Authorizes use of the API. Keep it secret. Ask us to rotate or revoke it at any time.

Layer 2 — mailbox

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

  1. POST /api/v1/mailboxes → get an address, password and token.
  2. Use the address to sign up on the target site.
  3. Poll GET /api/v1/messages?address=… (with the token) until the verification mail arrives.
  4. Open it with GET /api/v1/messages/{id} and read the OTP / link from the body.

Endpoints

GET/api/v1/domainsAPI key

List 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" }
  ]
}
POST/api/v1/mailboxesAPI key

Generate 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" }'   # optional

Response

{
  "address": "a1b2c3@tmail.pk",
  "password": "…",
  "token": "…"          // use as Authorization: Bearer <token>
}
POST/api/v1/tokenAPI key

Exchange 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": "…"
}
GET/api/v1/messages?address=<addr>API key + mailbox

List 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"
    }
  ]
}
GET/api/v1/messages/{id}?address=<addr>API key + mailbox

Fetch 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"
  }
}
PATCH/api/v1/messages/{id}?address=<addr>API key + mailbox

Mark 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 }
DELETE/api/v1/messages/{id}?address=<addr>API key + mailbox

Delete 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.

StatusCodeMeaning
400invalid_requestA required field (address, message id) is missing or malformed.
400invalid_domainThe requested domain isn't in the current /domains list.
401api_key_requiredNo X-API-Key header was sent.
401invalid_api_keyThe API key is not recognized.
401api_key_revokedThe API key has been revoked.
401invalid_credentialsWrong mailbox address or password.
401session_required / session_expiredThe mailbox needs a valid token or password.
404message_not_foundNo such message in that mailbox.
429rate_limitedPer-minute burst limit hit. Honor the Retry-After header.
429daily_limit_exceededThe key's daily request limit was reached.
503service_unavailableA 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 the Retry-After header.
  • When you read with X-Mailbox-Password, the response includes a fresh X-Mailbox-Token header — 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.