The DMARCTrust API provides RESTful access to your DMARC data. Retrieve reports, monitor domain health, and integrate email authentication insights into your existing tools.
This guide covers everything from generating API keys to making your first request, with examples in multiple languages.
Prerequisites
Getting Started
Step 1: Generate an API Key
- Log in to your DMARCTrust dashboard
- Navigate to Settings (gear icon in the sidebar)
- Scroll to the API Keys section
- Click Create API Key
- Enter a descriptive name (e.g., "Production Server" or "Monitoring Script")
- Click Create
A modal will display your API key. Copy it immediately as it will only be shown once. The key format is:
Store this key securely. Treat it like a password.
Step 2: Make Your First Request
Test your API key by fetching your account information:
A successful response looks like:
Authentication
All API requests require a Bearer token in the Authorization header:
Error Responses
Invalid or missing API key (401):
Subscription required (403):
Rate Limits
| Client Type | Limit |
|---|---|
| Authenticated (with API key) | 30 requests/minute |
| Unauthenticated | 2 requests/minute per IP |
When rate limited, you receive a 429 response with retry information:
Headers included: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset
API Reference
Base URL: https://www.dmarctrust.com/api/v1
Account
Get Account Information
Returns your account details, subscription status, and usage statistics.
Domains
List All Domains
Returns all domains in your account.
Get Single Domain
Returns detailed information about a specific domain, including 30-day statistics.
Add a Domain
Body: {"domain": "newdomain.com"}
Domain Actions
-
POST /domains/:id/activate- Activate a domain to start receiving reports -
POST /domains/:id/deactivate- Deactivate a domain -
POST /domains/:id/refresh_dns- Trigger an immediate DNS check
Domain DNS Records
Get DNS Records
Returns the current DMARC, SPF, and BIMI DNS records for a domain.
Domain Statistics
Get Daily Statistics
Query Parameters:
| Parameter | Default | Description |
|---|---|---|
| start_date | 30 days ago | Start date (YYYY-MM-DD) |
| end_date | today | End date (YYYY-MM-DD) |
Domain Sources
Get Email Sources
Returns email sources (senders) that have sent email on behalf of your domain.
Query Parameters:
| Parameter | Default | Description |
|---|---|---|
| range | 7d | Time range: "48h", "7d", or "30d" |
| date | - | Specific date (YYYY-MM-DD), overrides range |
Reports
List Reports
Returns DMARC aggregate reports received for your domains.
Query Parameters:
| Parameter | Description |
|---|---|
| domain_id | Filter by domain ID (e.g., "ud_19") |
| domain | Filter by domain name (partial match) |
| sender_org | Filter by sender organization (partial match) |
| start_date | Filter reports created after this date |
| end_date | Filter reports created before this date |
| limit | Results per page (default: 25, max: 100) |
| cursor | Pagination cursor for next page |
Get Report Details
Returns full details of a specific report, including individual record entries with source IPs, hostnames, and authentication results.
Pagination
List endpoints use cursor-based pagination. Check the meta object in responses:
To fetch the next page, pass the cursor:
ID Formats
Resources use prefixed IDs for clarity:
| Resource | Prefix | Example |
|---|---|---|
| User | usr_ | usr_123 |
| Domain | ud_ | ud_19 |
| Report | rpt_ | rpt_915 |
When making requests, you can use either the prefixed ID or the raw numeric ID:
Error Handling
All errors follow a consistent format:
Common error codes:
| Code | Status | Description |
|---|---|---|
| invalid_api_key | 401 | API key is missing or invalid |
| subscription_required | 403 | No active subscription |
| not_found | 404 | Resource does not exist |
| invalid_date | 400 | Date parameter is malformed |
| rate_limit_exceeded | 429 | Too many requests |
Code Examples
Python
JavaScript (Node.js)
Ruby
Managing API Keys
Viewing Keys
All your API keys are listed in Settings > API Keys. You can see:
- Key name
- Key prefix (first 12 characters)
- Creation date
- Last used date
Revoking Keys
To revoke an API key:
- Go to Settings > API Keys
- Find the key you want to revoke
- Click the trash icon
- Confirm the revocation
Revoked keys immediately stop working. Any applications using that key will receive 401 Unauthorized responses.
Best Practices
- Use descriptive names - Name keys after their purpose (e.g., "Production Monitoring", "CI/CD Pipeline")
- Rotate regularly - Create new keys and revoke old ones periodically
- One key per application - Use separate keys for different applications to enable granular revocation
- Never commit keys - Use environment variables or secrets management
- Monitor usage - Check "Last Used" dates to identify unused keys for cleanup
Need help? If you encounter issues with the API, contact support through the dashboard with the request_id from error responses. This helps us debug your specific request.