Messages
List, inspect, and respond to received messages
Inbound messages are the emails delivered to an inbox. Use these endpoints to page through recent messages, fetch the full body and attachments, reply to or forward a message, or delete one you no longer need.
Returns inbound messages received by the inbox, ordered by received_at descending.
List responses use cursor pagination. When more results are available the response includes a last_id; pass it back as the last_id query parameter to get the next page. When last_id is null you have reached the end.
API token in Api-Token header
Inbound inbox ID
1ID of the last message from the previous page. Pass the last_id
value returned by the previous response to fetch the next page.
Omit on the first request.
1700000000000123List of messages
Total number of messages within the retention window.
1Cursor for the next page. null when there are no more results.
Unauthorized
Forbidden
Not found
curl -X GET 'https://mailtrap.io/api/inbound/inboxes/{inbox_id}/messages' \
-H 'Authorization: Bearer YOUR_API_KEY'
{
"data": [
{
"id": "1700000000000123",
"inbox_id": 1,
"from": "sender@example.com",
"to": [
"support-tickets-1a2b3c4d@inbound-mailtrap.io"
],
"cc": [],
"bcc": [],
"reply_to": null,
"subject": "Hello",
"rfc_message_id": "<abc@sender.example>",
"in_reply_to": null,
"references": [],
"headers": {
"mime-version": "1.0"
},
"size": 4096,
"html_size": 512,
"text_size": 128,
"received_at": "2026-05-08T10:30:00.000Z",
"thread_id": "1700000000000124",
"attachments": [
{
"attachment_id": "att-1",
"size": 1024,
"filename": "logo.png",
"content_type": "image/png",
"content_disposition": "inline",
"content_id": "logo@example.com"
}
]
}
],
"total_count": 1,
"last_id": null
}Returns a single inbound message together with URLs for the raw .eml file and for each attachment, plus the decoded HTML and plain-text bodies. URLs expire after one hour.
API token in Api-Token header
Inbound inbox ID
1Inbound message ID
1700000000000123Message details
Mailtrap object ID for the message (not the Message-ID header value).
17000000000001231sender@example.com["support-tickets-1a2b3c4d@inbound-mailtrap.io"]HelloValue of the original Message-ID header.
<abc@sender.example>Selected headers from the original message, lowercased.
{"mime-version":"1.0","return-path":"<sender@example.com>"}Total size of the raw message in bytes.
4096Size of the HTML body in bytes. Zero if the message has no HTML part.
512Size of the plain-text body in bytes. Zero if the message has no text part.
1282026-05-08T10:30:00.000ZID of the thread this message belongs to. Use it with the Threads endpoints to fetch the full conversation.
1700000000000124URL to download the raw .eml file. Expires after one hour.
https://s3.amazonaws.com/inbound-mail/raw.eml?X-Amz-Signature=...2026-05-08T11:30:00.000ZDecoded HTML body. null when the message has no HTML part.
<html><body>Hello</body></html>Decoded plain-text body. null when the message has no text part.
HelloUnauthorized
Forbidden
Not found
curl -X GET https://mailtrap.io/api/inbound/inboxes/{inbox_id}/messages/{id} \
-H 'Authorization: Bearer YOUR_API_KEY'
{
"id": "1700000000000123",
"inbox_id": 1,
"from": "sender@example.com",
"to": [
"support-tickets-1a2b3c4d@inbound-mailtrap.io"
],
"cc": [],
"bcc": [],
"reply_to": null,
"subject": "Hello",
"rfc_message_id": "<abc@sender.example>",
"in_reply_to": null,
"references": [],
"headers": {
"mime-version": "1.0",
"return-path": "<sender@example.com>"
},
"size": 4096,
"html_size": 512,
"text_size": 128,
"received_at": "2026-05-08T10:30:00.000Z",
"thread_id": "1700000000000124",
"attachments": [
{
"attachment_id": "att-1",
"size": 1024,
"filename": "logo.png",
"content_type": "image/png",
"content_disposition": "inline",
"content_id": "logo@example.com",
"download_url": "https://s3.amazonaws.com/inbound-mail/att-1?X-Amz-Signature=...",
"download_url_expires_at": "2026-05-08T11:30:00.000Z"
}
],
"raw_message_url": "https://s3.amazonaws.com/inbound-mail/raw.eml?X-Amz-Signature=...",
"raw_message_expires_at": "2026-05-08T11:30:00.000Z",
"html_body": "<html><body>Hello</body></html>",
"text_body": "Hello"
}Permanently delete an inbound message and its stored body and attachments.
API token in Api-Token header
Inbound inbox ID
1Inbound message ID
1700000000000123Message deleted
No content
Unauthorized
Forbidden
Not found
curl -X DELETE https://mailtrap.io/api/inbound/inboxes/{inbox_id}/messages/{id} \
-H 'Authorization: Bearer YOUR_API_KEY'
No content
Send a reply to an inbound message. The reply is threaded to the original and its subject is prefixed with Re: (unless it already starts with one).
By default the reply is addressed to the original sender (its Reply-To, or From when absent). Pass to to override the recipients — an explicit empty array sends to cc/bcc only — or add cc/bcc.
The sender depends on the inbox type:
Mailtrap-hosted inbox — always sends from the inbox's own generated address. Supplying
fromis rejected with400.Custom-domain inbox — you supply
from, whose address must belong to the inbox's domain.
API token in Api-Token header
Inbound inbox ID
1Inbound message ID
1700000000000123Options for the sent message. All fields are optional. reply and
reply_all must carry a body (text and/or html); forward may omit
it, since the original message is quoted automatically. forward also
requires at least one recipient in to. Addresses use the Email
Sending API { email, name } shape.
Plain-text body.
Thanks for reaching out. We are looking into it.HTML body.
<p>Thanks for reaching out. We are looking into it.</p>Email API category for the sent message.
Support replyMessage queued for delivery. Returns the UUID(s) the Email API assigned to the sent message, one per recipient.
UUIDs assigned by the Email API to the sent message, one per
recipient. These are the sent message's UUIDs — not the inbound
message ID acted on, nor an RFC Message-ID header value.
["1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d"]The message could not be sent. Returned for an invalid sender (for
example a from on a Mailtrap-hosted inbox, or one outside the inbox's
domain) and for validation errors rejected by the Email API.
Unauthorized
The caller lacks permission on the inbox, or the inbox's monthly sending limit has been reached.
Not found
The message exceeds the maximum allowed size.
Too many requests. Retry after a short delay.
curl -X POST https://mailtrap.io/api/inbound/inboxes/{inbox_id}/messages/{id}/reply \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{ "text": "Thanks for reaching out. We are looking into it." }'
{
"message_ids": [
"1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d"
]
}Send a reply to an inbound message and copy the original's other recipients. Behaves exactly like the Reply to a message operation, except cc defaults to the original's To + Cc — minus the inbox's own addresses and the sender (already in To).
Pass to, cc, or bcc to override the computed recipients. As with a plain reply, the subject is prefixed with Re:.
API token in Api-Token header
Inbound inbox ID
1Inbound message ID
1700000000000123Options for the sent message. All fields are optional. reply and
reply_all must carry a body (text and/or html); forward may omit
it, since the original message is quoted automatically. forward also
requires at least one recipient in to. Addresses use the Email
Sending API { email, name } shape.
Plain-text body.
Thanks for reaching out. We are looking into it.HTML body.
<p>Thanks for reaching out. We are looking into it.</p>Email API category for the sent message.
Support replyMessage queued for delivery. Returns the UUID(s) the Email API assigned to the sent message, one per recipient.
UUIDs assigned by the Email API to the sent message, one per
recipient. These are the sent message's UUIDs — not the inbound
message ID acted on, nor an RFC Message-ID header value.
["1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d"]The message could not be sent. Returned for an invalid sender (for
example a from on a Mailtrap-hosted inbox, or one outside the inbox's
domain) and for validation errors rejected by the Email API.
Unauthorized
The caller lacks permission on the inbox, or the inbox's monthly sending limit has been reached.
Not found
The message exceeds the maximum allowed size.
Too many requests. Retry after a short delay.
curl -X POST https://mailtrap.io/api/inbound/inboxes/{inbox_id}/messages/{id}/reply_all \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{ "text": "Thanks all. Adding my colleague to the thread." }'
{
"message_ids": [
"1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d"
]
}Forward an inbound message to new recipients. The subject is prefixed with Fwd: (unless it already starts with one). The original message is always carried along: its rendered body is quoted below your optional note and its attachments are re-attached (any attachments you supply are added on top).
A forward has no implicit recipient — you must address it with to (and optionally cc/bcc). The from rules match those of the Reply operation: rejected for Mailtrap-hosted inboxes, required-and-domain-bound for custom-domain inboxes.
API token in Api-Token header
Inbound inbox ID
1Inbound message ID
1700000000000123Options for the sent message. All fields are optional. reply and
reply_all must carry a body (text and/or html); forward may omit
it, since the original message is quoted automatically. forward also
requires at least one recipient in to. Addresses use the Email
Sending API { email, name } shape.
Plain-text body.
Thanks for reaching out. We are looking into it.HTML body.
<p>Thanks for reaching out. We are looking into it.</p>Email API category for the sent message.
Support replyMessage queued for delivery. Returns the UUID(s) the Email API assigned to the sent message, one per recipient.
UUIDs assigned by the Email API to the sent message, one per
recipient. These are the sent message's UUIDs — not the inbound
message ID acted on, nor an RFC Message-ID header value.
["1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d"]The message could not be sent. Returned for an invalid sender (for
example a from on a Mailtrap-hosted inbox, or one outside the inbox's
domain) and for validation errors rejected by the Email API.
Unauthorized
The caller lacks permission on the inbox, or the inbox's monthly sending limit has been reached.
Not found
The message exceeds the maximum allowed size.
Too many requests. Retry after a short delay.
curl -X POST https://mailtrap.io/api/inbound/inboxes/{inbox_id}/messages/{id}/forward \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{ "to": [{ "email": "colleague@example.com" }], "text": "Please take a look at the message below." }'
{
"message_ids": [
"1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d"
]
}Last updated
Was this helpful?

