REST API Reference
Programmatically access emails, analysis results, and integrate MailLinter into your development workflow via the REST API.
Base URL
http://localhost:8547/apiAll API endpoints are relative to this base URL. External API access requires an API key (see Authentication below).
Authentication
API requests from external sources require authentication using an API key. Include your API key in the Authorization header:
Authorization: Bearer ml_your_api_key_hereThe web UI accesses the API internally without requiring authentication. API keys are only needed for external programmatic access (CI/CD pipelines, scripts, etc.).
API Endpoints
{
"emails": [
{
"id": "abc123",
"from": "sender@example.com",
"to": ["recipient@example.com"],
"subject": "Test Email",
"date": "2024-01-15T10:30:00Z",
"hasAttachments": false
}
],
"total": 1
}Code Examples
# Set your API key
API_KEY="ml_your_api_key_here"
# List all emails
curl -H "Authorization: Bearer $API_KEY" \
http://localhost:8547/api/emails
# Get specific email
curl -H "Authorization: Bearer $API_KEY" \
http://localhost:8547/api/emails/abc123
# Get all analysis results (spam, accessibility, compatibility, AI)
curl -H "Authorization: Bearer $API_KEY" \
http://localhost:8547/api/emails/abc123/analysis
# Get only accessibility report
curl -H "Authorization: Bearer $API_KEY" \
http://localhost:8547/api/emails/abc123/accessibility
# Send an email via API
curl -X POST -H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
http://localhost:8547/api/send-email \
-d '{
"from": "sender@example.com",
"to": "recipient@example.com",
"subject": "Test Email",
"html": "<h1>Hello World</h1>",
"text": "Hello World"
}'Common Use Cases
Automated Testing
Query the API after sending test emails to validate spam scores and accessibility.
Assert spam score < 5.0 in your test suiteBatch Processing
Process multiple emails programmatically for bulk template validation.
Iterate through all emails and check compatibilityCI/CD Integration
Integrate API calls into your pipeline to catch email issues before deployment.
Fail build if critical accessibility issues foundCustom Dashboards
Build custom reporting tools using the API data.
Aggregate spam scores across all templatesWhat's Next?
API Tips
Performance
- Use pagination for large email lists
- Cache analysis results when possible
- Delete old emails to keep responses fast
Best Practices
- Poll for new emails rather than constant requests
- Handle network errors gracefully
- Use environment variables for the base URL