Skip to content

API Reference

Relate Mail exposes a RESTful JSON API for managing emails, labels, filters, user profiles, preferences, and SMTP credentials.

Base URL

EnvironmentBase URL
Docker (default)http://localhost:8080/api
Local developmenthttp://localhost:5000/api

All endpoints described in this reference are relative to the base URL. For example, GET /api/emails means http://localhost:8080/api/emails in Docker.

Authentication

The API supports two authentication methods. Every request to a protected endpoint must include one of these.

OIDC / JWT (first-party)

Used by the web and mobile apps when OIDC is configured. Pass the JWT token in the Authorization header:

Authorization: Bearer {jwt_token}

API Key (third-party)

Used by external integrations, desktop apps, mobile apps, and protocol clients (SMTP, POP3, IMAP). Either header format is accepted:

Authorization: Bearer {api_key}
Authorization: ApiKey {api_key}

API keys are created via the SMTP Credentials endpoint. Each key has one or more scopes that control what it can access:

ScopeDescription
smtpSend email via SMTP
pop3Retrieve email via POP3
imapAccess email via IMAP
api:readRead inbox, labels, filters via REST API
api:writeModify emails, labels, filters via REST API
appFull app access (mobile/desktop)
internalService-to-service communication

Common Response Patterns

Paginated Lists

Endpoints that return collections use consistent pagination:

json
{
  "items": [],
  "totalCount": 142,
  "unreadCount": 7,
  "page": 1,
  "pageSize": 20
}

Query parameters:

ParameterTypeDefaultDescription
pageinteger1Page number (1-based)
pageSizeinteger20Items per page

Success Responses

StatusMeaning
200 OKRequest succeeded, response body included
201 CreatedResource created, response body included
204 No ContentAction succeeded, no response body (deletes, updates)

Error Responses

StatusMeaning
400 Bad RequestValidation error. Body contains error details.
401 UnauthorizedMissing or invalid authentication.
403 ForbiddenAuthenticated but insufficient permissions/scopes.
404 Not FoundResource does not exist.
429 Too Many RequestsRate limit exceeded.

Validation errors follow this shape:

json
{
  "type": "https://tools.ietf.org/html/rfc9110#section-15.5.1",
  "title": "One or more validation errors occurred.",
  "status": 400,
  "errors": {
    "fieldName": ["Error message"]
  }
}

Rate Limiting

CategoryLimit
Global100 requests/minute
Authentication endpoints10 requests/minute
Write operations30 requests/minute

When rate-limited, the API returns 429 Too Many Requests. Retry after the duration indicated in the Retry-After header.

Content Type

All request and response bodies use JSON:

Content-Type: application/json

Binary endpoints (attachment downloads, EML/MBOX exports) return appropriate MIME types.

Quick Example

bash
# List inbox emails using an API key
curl -s http://localhost:8080/api/emails \
  -H "Authorization: Bearer YOUR_API_KEY" | jq

Endpoints

SectionPrefixDescription
Emails/api/emails, /api/external/emailsInbox, search, threads, bulk operations
Outbound/api/outboundCompose, drafts, send, reply, forward
Labels/api/labelsCustom labels with color and sorting
Filters/api/filtersAutomatic email filter rules
Profile/api/profileUser profile and additional addresses
Preferences/api/preferencesTheme, density, notification settings
SMTP Credentials/api/smtp-credentialsAPI key management and connection info
Push Subscriptions/api/push-subscriptionsWeb push notification subscriptions
Discovery/api/discoveryServer capabilities and protocol info
Config/api/configRuntime frontend configuration
Internal Notifications/api/internal-notificationsService-to-service new email events
SignalR Hub/hubs/emailReal-time WebSocket events

Released under the MIT License.