Skip to content

Authentication

Mail.td uses bearer token authentication. No API key registration is needed to get started.

How It Works

POST /api/accounts → get token + account_id

GET /api/accounts/{account_id}/messages
    Authorization: Bearer <token>

All authenticated requests require the Authorization header:

Authorization: Bearer eyJhbGciOiJIUzI1NiIs...

Token Types

Mail.td supports three token types. All use the same Authorization: Bearer header.

Token typeWho uses itLifetimeHow to get
Email JWTAll users7 daysPOST /api/accounts or POST /api/token
Pro JWTPro users7 daysPOST /api/user/login
Pro API TokenPro usersNever expiresCreated in Pro dashboard or POST /api/user/tokens

Email JWT

Issued when you create an account or sign in. Grants access to one specific account.

bash
# 1. Get PoW challenge (free users only)
curl https://api.mail.td/api/challenge
# → {"id": "...", "salt": "...", "difficulty": 20, "expires_at": ...}

# 2. Create account with solved PoW → get token
curl -X POST https://api.mail.td/api/accounts \
  -H "Content-Type: application/json" \
  -d '{"address":"demo@mail.td","password":"supersecret","pow":{"id":"...","nonce":"..."}}'
# → {"id": "a1b2c3d4-...", "address": "demo@mail.td", "token": "eyJ..."}

# Sign in to existing account → get new token (no PoW needed)
curl -X POST https://api.mail.td/api/token \
  -H "Content-Type: application/json" \
  -d '{"address":"demo@mail.td","password":"supersecret"}'
# → {"id": "a1b2c3d4-...", "address": "demo@mail.td", "token": "eyJ..."}

Pro JWT

Issued when a Pro user logs in with email and password. Grants access to all accounts owned by the Pro user and Pro management features (domains, webhooks, tokens).

bash
curl -X POST https://api.mail.td/api/user/login \
  -H "Content-Type: application/json" \
  -d '{"email":"user@example.com","password":"propassword"}'
# → {"user_id": "...", "email": "...", "plan": "pro", "status": "active"}

OAuth Users

If you signed up with Google or GitHub, you don't have a password and cannot use POST /api/user/login. Instead, create a Pro API Token in the Pro dashboard to access the API.

Pro API Token

Long-lived token for server-to-server integrations. Prefixed with tm_pro_. Does not expire — revoke manually when no longer needed. This is the recommended way to authenticate for all API integrations.

bash
curl https://api.mail.td/api/accounts/{account_id}/messages \
  -H "Authorization: Bearer tm_pro_xxxxxxxxxxxxxxxxxxxx"

Create tokens in the Pro dashboard or via POST /api/user/tokens.

Token Lifetime

TokenExpiresRefresh
Email JWT7 daysCall POST /api/token
Pro JWT7 daysCall POST /api/user/login
Pro API TokenNeverRevoke via DELETE /api/user/tokens/{id}

When a token expires, the API returns:

json
HTTP 401
{ "error": "invalid_or_expired_token" }

Rate Limits

PlanLimitKeyed by
Public endpoints8 req/sIP
Free (authenticated)8 req/sIP
Pro (authenticated)20 req/sIP
Account creation (free)1 per 8sIP
Account creation (Pro)8 req/sIP

Security Best Practices

  • Always use HTTPS (https://api.mail.td)
  • Don't share tokens or embed them in client-side code
  • Rotate Pro API tokens periodically
  • Delete accounts when no longer needed

Mail.td API Documentation