Emails API
Access and manage emails received by your Mailhooks domains.
List Emails
Retrieve a paginated list of emails for your account.
https://mailhooks.dev/api/v1/emailsQuery Parameters
Parameter | Type | Description |
|---|---|---|
| integer | Page number (default: 1) |
| integer | Items per page (default: 20, max: 100) |
| string | Filter by sender email |
| string | Filter by recipient email |
| string | Filter by subject (partial match) |
| boolean | Filter by read status (true/false) |
| string | Filter by environment ID |
| string | Filter emails created after this ISO date |
| string | Filter emails created before this ISO date |
| string | Sort field (createdAt, from, subject) |
| string | Sort order (asc, desc). Default: desc |
Example Request
curl -H "x-api-key: mh_your_api_key_here" \
"https://mailhooks.dev/api/v1/emails?page=1&perPage=10"Response
{
"data": [
{
"id": "em_1234567890",
"from": "sender@example.com",
"to": ["recipient@yourdomain.com"],
"cc": [],
"bcc": [],
"subject": "Hello from Mailhooks",
"date": "2024-01-15T10:30:00Z",
"read": false,
"hasAttachments": false,
"attachments": [],
"snippet": "This is the beginning of your email content...",
"spfResult": "pass",
"dkimResult": "pass",
"dmarcResult": "pass",
"authSummary": "SPF: pass, DKIM: pass, DMARC: pass",
"createdAt": "2024-01-15T10:30:00Z"
}
],
"currentPage": 1,
"perPage": 10,
"totalItems": 150,
"totalPages": 15,
"hasNextPage": true
}Response Fields
Field | Type | Description |
|---|---|---|
| string | Unique email identifier |
| string | Sender email address |
| string[] | Array of recipient email addresses |
| string[] | Array of CC recipients |
| string[] | Array of BCC recipients |
| string | Email subject line |
| string | Email date from headers (ISO 8601) |
| boolean | Whether the email has been marked as read |
| boolean | Whether the email has attachments |
| object[] | Array of attachment metadata (id, filename, contentType, size) |
| string | Preview of email content (first ~100 chars) |
| string | SPF authentication result (pass, fail, softfail, neutral, none) |
| string | DKIM authentication result |
| string | DMARC authentication result |
| string | Human-readable summary of auth results |
| string | When the email was received (ISO 8601) |
Get Email Details
Retrieve details for a specific email including full metadata and authentication results.
https://mailhooks.dev/api/v1/emails/:idExample Request
curl -H "x-api-key: mh_your_api_key_here" \
"https://mailhooks.dev/api/v1/emails/em_1234567890"Response
{
"id": "em_1234567890",
"from": "sender@example.com",
"to": ["recipient@yourdomain.com"],
"cc": [],
"bcc": [],
"subject": "Hello from Mailhooks",
"date": "2024-01-15T10:30:00Z",
"read": false,
"hasAttachments": true,
"attachments": [
{
"id": "att_0987654321",
"filename": "document.pdf",
"contentType": "application/pdf",
"size": 125432
}
],
"snippet": "This is the beginning of your email content...",
"spfResult": "pass",
"dkimResult": "pass",
"dmarcResult": "pass",
"authSummary": "SPF: pass, DKIM: pass, DMARC: pass",
"createdAt": "2024-01-15T10:30:00Z"
}Get Email Content
Retrieve the full HTML and text content of an email.
https://mailhooks.dev/api/v1/emails/:id/contentResponse
{
"html": "<html><body><p>Your email HTML content...</p></body></html>",
"text": "Your email plain text content..."
}Mark as Read / Unread
Update the read status of an email. This can be useful for tracking which emails have been processed.
Mark as Read
https://mailhooks.dev/api/v1/emails/:id/readMark as Unread
https://mailhooks.dev/api/v1/emails/:id/unreadExample Request
# Mark email as read
curl -X PATCH \
-H "x-api-key: mh_your_api_key_here" \
"https://mailhooks.dev/api/v1/emails/em_1234567890/read"
# Mark email as unread
curl -X PATCH \
-H "x-api-key: mh_your_api_key_here" \
"https://mailhooks.dev/api/v1/emails/em_1234567890/unread"Response
{
"id": "em_1234567890",
"read": true,
"updatedAt": "2024-01-15T11:00:00Z"
}Delete Email
Permanently delete an email along with any attachments. Deletion removes both the database record and the stored raw email and attachment files.
https://mailhooks.dev/api/v1/emails/:idExample Request
curl -X DELETE \
-H "x-api-key: mh_your_api_key_here" \
"https://mailhooks.dev/api/v1/emails/em_1234567890"Response
Returns 204 No Content on success, or 404 Not Found if the email does not exist or belongs to another tenant.
Download Raw Email
Download the original email in EML format.
https://mailhooks.dev/api/v1/emails/:id/emlDownload Attachment
Download a specific attachment from an email.
https://mailhooks.dev/api/v1/emails/:emailId/attachments/:attachmentIdExample Request
curl -H "x-api-key: mh_your_api_key_here" \
-o attachment.pdf \
"https://mailhooks.dev/api/v1/emails/em_1234567890/attachments/att_0987654321"Email Tracking
Each email received via SMTP is assigned a unique UUID, which is returned in the SMTP response:
250 Message accepted 87b1afa5-bdce-44c2-8a17-819cb2ac8afd
This UUID can be used to track the complete email lifecycle through SMTP reception, spam checks, and hook processing (webhooks, Discord, etc.).
Response Codes
Code | Description |
|---|---|
200 | Successful request |
204 | Successful request with no response body (used by delete) |
400 | Bad request - Invalid parameters |
401 | Unauthorized - Invalid API key |
404 | Not found - Email or attachment not found |
429 | Too many requests - Rate limit exceeded |