Documentation menu
API reference
Waiting
Block until an email arrives. Built for CI.
Wait for a message
GET/v1/inboxes/{id}/messages/wait
Returns the newest message matching the filters in full, immediately if one already exists, otherwise as soon as one arrives. Subscribes before it first looks, so an email that lands in between is not missed.
Use since to ignore mail from earlier test runs. If nothing arrives in time
the answer is 404 with code wait_timeout.
Path parameters
- idstringrequiredInbox ID.
Query parameters
- qstringSearch. Free text matches subject, sender, recipients and body. Also supports
from:,to:,subject:,is:unread,is:read,is:tagged,tag:name,has:attachment,larger:1m,after:/before:, negation with-or!, and"exact phrases". - fromstringSender contains this text.
- tostringAny recipient contains this text.
- subjectstringSubject contains this text.
- sincestring (date-time)Only messages received at or after this time.
- timeoutnumberSeconds to wait. Defaults to 20, capped at 30.
Returns
- idstringrequired
- inbox_idstringrequired
- received_atstring (date-time)required
- envelope_fromstringrequiredThe SMTP
MAIL FROM. - recipientsarray of stringsrequiredThe SMTP
RCPT TOaddresses, including Bcc. - fromstringrequiredThe
Fromheader. - tostringrequiredThe
Toheader. - subjectstringrequired
- message_idstringrequiredThe
Message-IDheader. - sizeintegerrequiredSize in bytes.
- has_textbooleanrequired
- has_htmlbooleanrequired
- attachment_countintegerrequired
- link_countintegerrequired
- tlsbooleanrequiredWhether the sender used TLS.
- parse_errorstringSet when the message is not valid MIME. Parts may be missing.
- readbooleanrequired
- tagsarray of stringsrequired
- textstring
- htmlstring
- linksarray of stringsrequired
- headersobject
- attachmentsarray of objectsrequired
Child attributes
- indexintegerrequired
- filenamestringrequired
- content_typestringrequired
- sizeintegerrequired
- urlstringrequiredPath to download it (needs your API key).
- thumb_urlstringPath to a thumbnail, for images.
- raw_urlstringrequiredPath to the raw
.eml. - html_urlstringPath to the HTML body, when there is one.
- filesobjectrequiredSigned, expiring URLs a browser can open without an
Authorizationheader.Child attributes
- rawstring (uri)required
- htmlstring (uri)
- attachmentsarray of stringsrequired
- thumbnailsarray of strings
- expires_atstring (date-time)required
- list_unsubscribeobjectParsed
List-Unsubscribeheaders, when present.Child attributes
- headerstring
- header_poststring
- linksarray of strings
- errorsstring
Errors
400The request was malformed or a value was invalid.
401Missing or invalid API key.
404No inbox, or no matching message within the timeout (`wait_timeout`).
429Too many requests. Wait `Retry-After` seconds.
curl "https://app.mailbench.dev/v1/inboxes/box_g3bekcev4z7i4psq/messages/wait" \
-H "Authorization: Bearer $API_KEY"const res = await fetch("https://app.mailbench.dev/v1/inboxes/box_g3bekcev4z7i4psq/messages/wait", {
headers: {
Authorization: `Bearer ${process.env.API_KEY}`,
},
});
const { data } = await res.json();import os, requests
res = requests.get(
"https://app.mailbench.dev/v1/inboxes/box_g3bekcev4z7i4psq/messages/wait",
headers={"Authorization": f"Bearer {os.environ['API_KEY']}"},
)
data = res.json()["data"]{
"success": true,
"data": {
"id": "msg_htumcicppd26jek6",
"inbox_id": "box_g3bekcev4z7i4psq",
"received_at": "2026-10-12T10:00:00Z",
"envelope_from": "noreply@app.test",
"recipients": [
"sam@example.org"
],
"from": "App <noreply@app.test>",
"to": "Sam <sam@example.org>",
"subject": "Welcome aboard",
"message_id": "<8f2c1a@app.test>",
"size": 1432,
"has_text": true,
"has_html": true,
"attachment_count": 0,
"link_count": 2,
"tls": true,
"parse_error": "string",
"read": false,
"tags": [
"billing"
],
"text": "Click https://app.test/verify/abc123 to confirm your address.",
"html": "<p>Click <a href=\"https://app.test/verify/abc123\">here</a>.</p>",
"links": [
"https://app.test/verify/abc123"
],
"headers": {},
"attachments": [
{
"index": 0,
"filename": "invoice.pdf",
"content_type": "application/pdf",
"size": 48211,
"url": "string",
"thumb_url": "string"
}
],
"raw_url": "/v1/messages/msg_htumcicppd26jek6/raw",
"html_url": "/v1/messages/msg_htumcicppd26jek6/html",
"files": {
"raw": "https://example.com/hook",
"html": "<p>Click <a href=\"https://app.test/verify/abc123\">here</a>.</p>",
"attachments": [
"https://example.com/hook"
],
"thumbnails": [
"https://example.com/hook"
],
"expires_at": "2026-10-12T10:00:00Z"
},
"list_unsubscribe": {
"header": "string",
"header_post": "string",
"links": [
"https://app.test/verify/abc123"
],
"errors": "string"
}
}
}