Skip to main content

API Reference

Base URL

https://api.optail.io/v1

For self-hosted instances, replace with your API server URL.

Authentication

All API requests require a Bearer token in the Authorization header:

Authorization: Bearer ms_live_your_api_key_here

API keys are created in the dashboard under Settings > API Keys. Each key has scoped permissions:

PermissionAccess
SENDSend emails
TEMPLATES_READRead templates
TEMPLATES_WRITECreate, update, delete templates
PROVIDERS_READRead provider accounts
PROVIDERS_WRITEConnect, update, delete providers
METRICS_READRead delivery metrics
SETTINGS_WRITEManage organization settings

Rate Limits

EndpointLimit
POST /v1/send100 requests/second per organization
All other endpoints1,000 requests/second per organization
Unauthenticated20 requests/minute per IP

Rate limit headers are included in every response:

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 87
Retry-After: 1 (only on 429 responses)

Error Format

All errors follow a consistent JSON structure:

{
"error": {
"code": "VALIDATION_ERROR",
"message": "Request validation failed",
"details": {
"issues": [
{
"path": "to",
"message": "Invalid email"
}
]
}
}
}

Error Codes

HTTP StatusCodeDescription
400VALIDATION_ERRORRequest body or query params failed validation
401AUTHENTICATION_ERRORMissing or invalid API key
404NOT_FOUNDResource does not exist
409CONFLICTResource already exists (e.g., duplicate suppression)
422VALIDATION_ERRORSemantic validation failed (e.g., no active provider)
429RATE_LIMIT_EXCEEDEDToo many requests; check Retry-After header
500INTERNAL_ERRORUnexpected server error

Pagination

List endpoints support pagination via query parameters:

ParameterTypeDefaultDescription
pageinteger1Page number (1-indexed)
limitinteger20Items per page (max 100)

Paginated responses include a pagination object:

{
"data": [...],
"pagination": {
"page": 1,
"limit": 20,
"total": 142,
"totalPages": 8
}
}