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.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/addresses | List all addresses (filter by domainId) |
| POST | /api/addresses | Create a new address |
| GET | /api/addresses/:id | Get address details |
| PATCH | /api/addresses/:id | Update note, expiration, enabled, or category |
| DELETE | /api/addresses/:id | Delete an address |
| POST | /api/addresses/generate | Generate a random address using naming preferences |
| GET | /api/addresses/:id/stats | Get 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.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/address-categories | List all categories |
| POST | /api/address-categories | Create a category |
| PATCH | /api/address-categories/:id | Update category name or color |
| DELETE | /api/address-categories/:id | Delete 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.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/emails | List threads (paginated, searchable, filterable) |
| POST | /api/emails/compose | Compose and send a new email |
| GET | /api/emails/:threadId | Get thread with all messages |
| PATCH | /api/emails/:threadId | Update read, starred, archived, or trash state |
| DELETE | /api/emails/:threadId | Move to trash or permanently delete |
| POST | /api/emails/:threadId/reply | Reply, reply-all, or forward |
| PATCH | /api/emails/batch | Batch update read/starred state (up to 100) |
| GET | /api/emails/html/:emailId | Get rendered HTML of an email |
| GET | /api/emails/raw/:emailId | Get raw email data |
| DELETE | /api/emails/empty-trash | Permanently 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
| Parameter | Type | Description |
|---|---|---|
| page | number | Page number (default: 1) |
| limit | number | Items per page (default: 20, max: 100) |
| folder | string | "inbox", "trash", or "archived" |
| addressId | number | Filter by address |
| search | string | Search subjects and senders |
| isStarred | boolean | Filter starred threads |
| isRead | boolean | Filter read/unread |
| dateFrom | string | ISO date lower bound |
| dateTo | string | ISO date upper bound |
| sortBy | string | "date" or "subject" |
| sortOrder | string | "asc" or "desc" |
Domains
List available domains. Domain creation is admin-restricted.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/domains | List domains (filter by isPrivate) |
| GET | /api/domains/:id | Get 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.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/blocked-senders | List blocked senders (filter by addressId) |
| POST | /api/blocked-senders | Block a sender for an address |
| DELETE | /api/blocked-senders/:id | Unblock 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.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/api-keys | List API keys (key prefix only) |
| POST | /api/api-keys | Create a new API key |
| DELETE | /api/api-keys/:id | Revoke 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.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/webhooks | List webhook endpoints with recent deliveries |
| POST | /api/webhooks | Create a webhook endpoint |
| PATCH | /api/webhooks/:id | Update events or toggle enabled |
| DELETE | /api/webhooks/:id | Delete a webhook endpoint |
| GET | /api/webhooks/:id/deliveries | View 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.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/push/vapid | Get the VAPID public key |
| POST | /api/push/subscribe | Register a push subscription |
| GET | /api/push/subscribe | List active subscriptions |
| DELETE | /api/push/subscribe | Remove 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.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/attachments/:id | Get 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.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/preferences | Get current preferences |
| PATCH | /api/preferences | Update 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
| Format | Example |
|---|---|
| RANDOM | x7k9m2p4 |
| FIRST_NAME | sarah |
| FIRST_LAST | sarahmitchell |
| FIRST_DOT_LAST | sarah.mitchell |
| FIRST_INITIAL_LAST | smitchell |
| RANDOM_WORD | autumn-river |
| RANDOM_LETTERS | qwxztp |
Password Manager Aliases
SimpleLogin and Addy.io-compatible endpoints for password manager integration. See the password manager setup guide for configuration instructions.
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/alias/random/new | Generate alias (SimpleLogin protocol) |
| POST | /api/v1/aliases | Generate 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]" } }