Skip to main content

API Reference

Complete REST API for managing aliases, emails, domains, webhooks, and more.

Authentication

All API requests require authentication via an API key passed as a Bearer token in the Authorization header.

Authorization: Bearer YOUR_API_KEY

Generate API keys from Settings → API Keys in the dashboard. Pro plans include 1 key, Enterprise plans include up to 10.

All responses follow the shape { data: T } on success or { error: string } on failure.

Addresses

Create, list, update, and delete email aliases.

MethodEndpointDescription
GET/api/addressesList all addresses (filter by domainId)
POST/api/addressesCreate a new address
GET/api/addresses/:idGet address details
PATCH/api/addresses/:idUpdate note, expiration, enabled, or category
DELETE/api/addresses/:idDelete an address
POST/api/addresses/generateGenerate a random address using naming preferences
GET/api/addresses/:id/statsGet address statistics and top senders

Example: Create address

curl -X POST https://mailservr.app/api/addresses \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "notifications", "domainId": 1, "note": "GitHub alerts"}'

// Response (201):
{
  "data": {
    "id": 42,
    "name": "notifications",
    "enabled": true,
    "note": "GitHub alerts",
    "expiresAt": null,
    "domain": { "id": 1, "name": "priv.sh", "receiveOnly": false }
  }
}

Example: Generate random address

curl -X POST https://mailservr.app/api/addresses/generate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"domainId": 1}'

// Response (201):
{
  "data": {
    "id": 43,
    "name": "sarah.mitchell42",
    "enabled": true,
    "domain": { "id": 1, "name": "priv.sh", "receiveOnly": false }
  }
}

Address Categories

Organize addresses into color-coded categories.

MethodEndpointDescription
GET/api/address-categoriesList all categories
POST/api/address-categoriesCreate a category
PATCH/api/address-categories/:idUpdate category name or color
DELETE/api/address-categories/:idDelete a category

Example: Create category

curl -X POST https://mailservr.app/api/address-categories \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Work", "color": "#3B82F6"}'

// Response (201):
{
  "data": {
    "id": 5,
    "name": "Work",
    "color": "#3B82F6",
    "sortOrder": 0
  }
}

Emails

Read, compose, reply, and manage email threads.

MethodEndpointDescription
GET/api/emailsList threads (paginated, searchable, filterable)
POST/api/emails/composeCompose and send a new email
GET/api/emails/:threadIdGet thread with all messages
PATCH/api/emails/:threadIdUpdate read, starred, archived, or trash state
DELETE/api/emails/:threadIdMove to trash or permanently delete
POST/api/emails/:threadId/replyReply, reply-all, or forward
PATCH/api/emails/batchBatch update read/starred state (up to 100)
GET/api/emails/html/:emailIdGet rendered HTML of an email
GET/api/emails/raw/:emailIdGet raw email data
DELETE/api/emails/empty-trashPermanently delete all trashed emails

Example: List threads

curl "https://mailservr.app/api/emails?folder=inbox&limit=10&search=deploy" \
  -H "Authorization: Bearer YOUR_API_KEY"

// Response:
{
  "data": {
    "items": [
      {
        "id": 87,
        "subject": "Deployment successful",
        "snippet": "Your app was deployed to...",
        "isRead": false,
        "isStarred": false,
        "lastMessageAt": "2026-02-13T10:30:00Z"
      }
    ],
    "pagination": { "page": 1, "limit": 10, "total": 1, "totalPages": 1 }
  }
}

Example: Compose email

curl -X POST https://mailservr.app/api/emails/compose \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "addressId": 42,
    "to": "[email protected]",
    "subject": "Hello from mailservr",
    "textBody": "This is a test email."
  }'

// Response (201):
{
  "data": {
    "id": 88,
    "subject": "Hello from mailservr",
    "emails": [{ "id": 150, "from": "[email protected]", "status": "SENT" }]
  }
}

Query parameters for GET /api/emails

ParameterTypeDescription
pagenumberPage number (default: 1)
limitnumberItems per page (default: 20, max: 100)
folderstring"inbox", "trash", or "archived"
addressIdnumberFilter by address
searchstringSearch subjects and senders
isStarredbooleanFilter starred threads
isReadbooleanFilter read/unread
dateFromstringISO date lower bound
dateTostringISO date upper bound
sortBystring"date" or "subject"
sortOrderstring"asc" or "desc"

Domains

List available domains. Domain creation is admin-restricted.

MethodEndpointDescription
GET/api/domainsList domains (filter by isPrivate)
GET/api/domains/:idGet domain details and address count

Example: List domains

curl https://mailservr.app/api/domains \
  -H "Authorization: Bearer YOUR_API_KEY"

// Response:
{
  "data": [
    {
      "id": 1,
      "name": "priv.sh",
      "status": "ACTIVE",
      "isPrivate": false,
      "receiveOnly": false,
      "_count": { "addresses": 12 }
    }
  ]
}

Blocked Senders

Block specific senders from delivering to your addresses.

MethodEndpointDescription
GET/api/blocked-sendersList blocked senders (filter by addressId)
POST/api/blocked-sendersBlock a sender for an address
DELETE/api/blocked-senders/:idUnblock a sender

Example: Block a sender

curl -X POST https://mailservr.app/api/blocked-senders \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"addressId": 42, "senderEmail": "[email protected]"}'

// Response (201):
{
  "data": {
    "id": 7,
    "addressId": 42,
    "senderEmail": "[email protected]",
    "createdAt": "2026-02-13T10:30:00Z"
  }
}

API Keys

Manage API keys for programmatic access.

MethodEndpointDescription
GET/api/api-keysList API keys (key prefix only)
POST/api/api-keysCreate a new API key
DELETE/api/api-keys/:idRevoke an API key

Example: Create API key

curl -X POST https://mailservr.app/api/api-keys \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "CI/CD Pipeline", "expiresAt": "2027-01-01T00:00:00Z"}'

// Response (201):
{
  "data": {
    "id": 3,
    "name": "CI/CD Pipeline",
    "keyPrefix": "ms_abc1",
    "expiresAt": "2027-01-01T00:00:00Z",
    "key": "ms_abc123def456..."
  }
}

The full key value is only returned once at creation time. Store it securely.

Webhooks

Manage outbound webhook endpoints. Available on the Enterprise plan. See the webhook documentation for event payloads and signature verification.

MethodEndpointDescription
GET/api/webhooksList webhook endpoints with recent deliveries
POST/api/webhooksCreate a webhook endpoint
PATCH/api/webhooks/:idUpdate events or toggle enabled
DELETE/api/webhooks/:idDelete a webhook endpoint
GET/api/webhooks/:id/deliveriesView delivery history

Example: Create webhook

curl -X POST https://mailservr.app/api/webhooks \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/webhook",
    "events": ["EMAIL_RECEIVED", "THREAD_CREATED"]
  }'

// Response (201):
{
  "data": {
    "id": 2,
    "url": "https://example.com/webhook",
    "events": ["EMAIL_RECEIVED", "THREAD_CREATED"],
    "enabled": true,
    "secret": "whsec_abc123..."
  }
}

The secret is only returned once at creation time. Use it to verify webhook signatures.

Push Notifications

Subscribe to browser push notifications for new emails.

MethodEndpointDescription
GET/api/push/vapidGet the VAPID public key
POST/api/push/subscribeRegister a push subscription
GET/api/push/subscribeList active subscriptions
DELETE/api/push/subscribeRemove a push subscription

Example: Subscribe

curl -X POST https://mailservr.app/api/push/subscribe \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "endpoint": "https://fcm.googleapis.com/fcm/send/...",
    "keys": {
      "p256dh": "BNcRd...",
      "auth": "tBHI..."
    }
  }'

// Response:
{ "data": { "id": 12 } }

Attachments

Download email attachments via presigned URLs.

MethodEndpointDescription
GET/api/attachments/:idGet a presigned download URL

Example

curl https://mailservr.app/api/attachments/15 \
  -H "Authorization: Bearer YOUR_API_KEY"

// Response:
{
  "data": {
    "url": "https://storage.example.com/...",
    "filename": "report.pdf",
    "contentType": "application/pdf"
  }
}

Preferences

Manage user preferences for default domain and alias generation format.

MethodEndpointDescription
GET/api/preferencesGet current preferences
PATCH/api/preferencesUpdate preferences

Example: Update preferences

curl -X PATCH https://mailservr.app/api/preferences \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"defaultDomainId": 1, "emailFormat": "FIRST_DOT_LAST", "includeNumbers": true}'

// Response:
{
  "data": {
    "defaultDomainId": 1,
    "emailFormat": "FIRST_DOT_LAST",
    "includeNumbers": true,
    "defaultDomain": { "id": 1, "name": "priv.sh" }
  }
}

Email format options

FormatExample
RANDOMx7k9m2p4
FIRST_NAMEsarah
FIRST_LASTsarahmitchell
FIRST_DOT_LASTsarah.mitchell
FIRST_INITIAL_LASTsmitchell
RANDOM_WORDautumn-river
RANDOM_LETTERSqwxztp

Password Manager Aliases

SimpleLogin and Addy.io-compatible endpoints for password manager integration. See the password manager setup guide for configuration instructions.

MethodEndpointDescription
POST/api/alias/random/newGenerate alias (SimpleLogin protocol)
POST/api/v1/aliasesGenerate alias (Addy.io protocol)

Example: SimpleLogin

curl -X POST "https://mailservr.app/api/alias/random/new?hostname=github.com" \
  -H "Authentication: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"note": "Generated for github.com"}'

// Response (201):
{ "alias": "[email protected]" }

Example: Addy.io

curl -X POST https://mailservr.app/api/v1/aliases \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"domain": "priv.sh", "description": "Generated for github.com"}'

// Response (201):
{ "data": { "email": "[email protected]" } }

Related