Documentation / API Reference

API Overview

2 min read

The MailingAPI REST API lets you send transactional emails, manage domains, configure webhooks, and access analytics programmatically.

Base URL

All API requests use this base URL:

https://api.mailingapi.com/v1

Authentication

Authenticate using Bearer tokens in the Authorization header:

curl https://api.mailingapi.com/v1/messages \
  -H "Authorization: Bearer your_api_key_here"

API keys are scoped to a single domain. Get your key from Settings → API Keys.

See Authentication for details.

Request format

Content-Type

Send JSON with Content-Type: application/json:

curl -X POST https://api.mailingapi.com/v1/messages/send \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"from": "hello@yourdomain.com", "to": "user@example.com", ...}'

Request body

All POST/PUT/PATCH requests accept JSON bodies:

{
  "from": "hello@yourdomain.com",
  "to": "user@example.com",
  "subject": "Hello",
  "html": "<p>Hello world</p>"
}

Response format

All responses return JSON with consistent structure.

Success response

{
  "id": "msg_abc123",
  "status": "queued",
  "message": "Email queued for delivery"
}

List response

{
  "data": [
    {"id": "msg_abc123", ...},
    {"id": "msg_def456", ...}
  ],
  "meta": {
    "total": 150,
    "page": 1,
    "per_page": 25,
    "total_pages": 6
  }
}

Error response

{
  "error": {
    "type": "validation_error",
    "message": "Invalid email address",
    "code": "invalid_to_address",
    "details": {
      "field": "to",
      "value": "not-an-email"
    }
  }
}

HTTP methods

Method Usage
GET Retrieve resources
POST Create resources
PATCH Partial update
PUT Full replacement
DELETE Remove resources

Status codes

Code Meaning
200 Success
201 Created
204 No content (successful delete)
400 Bad request (invalid input)
401 Unauthorized (invalid/missing API key)
403 Forbidden (insufficient permissions)
404 Not found
422 Unprocessable entity (validation failed)
429 Too many requests (rate limited)
500 Internal server error

Pagination

List endpoints support pagination:

curl "https://api.mailingapi.com/v1/messages?page=2&per_page=50" \
  -H "Authorization: Bearer $API_KEY"

Parameters:

  • page — Page number (default: 1)
  • per_page — Items per page (default: 25, max: 100)

Response includes pagination metadata:

{
  "data": [...],
  "meta": {
    "total": 150,
    "page": 2,
    "per_page": 50,
    "total_pages": 3
  }
}

Filtering

Many endpoints support filtering:

curl "https://api.mailingapi.com/v1/messages?status=delivered&from=2024-01-01" \
  -H "Authorization: Bearer $API_KEY"

Common filters:

  • from / to — Date range (ISO 8601)
  • status — Resource status
  • tag — Filter by tag

Rate limiting

API requests are rate limited per API key:

Endpoint Limit
Send email 100/minute
Batch send 10/minute
Other endpoints 1000/minute

Rate limit headers are included in responses:

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1705315860

When rate limited, you receive 429 Too Many Requests:

{
  "error": {
    "type": "rate_limit_exceeded",
    "message": "Too many requests",
    "retry_after": 5
  }
}

Idempotency

For POST requests, use idempotency keys to prevent duplicates:

curl -X POST https://api.mailingapi.com/v1/messages/send \
  -H "Authorization: Bearer $API_KEY" \
  -H "Idempotency-Key: unique-request-id-123" \
  -d '{...}'
  • Keys are valid for 24 hours
  • Repeated requests with same key return original response
  • Use UUIDs or unique identifiers

Versioning

The API is versioned via URL path:

https://api.mailingapi.com/v1/...

We maintain backwards compatibility within major versions. Breaking changes require a new version.

SDKs

Official SDKs available:

See the full SDK documentation for installation guides and examples.

API resources

Resource Description
Messages Send and track emails
Domains Manage sending domains
Webhooks Configure event notifications
Templates Email templates
Validation Email address validation
Analytics Statistics and reporting