import { createClient } from "@mailsai/sdk";
const client = createClient(); // reads MAILS_API_KEY
const result = await client.received.list({ limit: 10 });
console.log(result);from mailsai import create_client
client = create_client() # reads MAILS_API_KEY
result = client.list_received(limit=10)
print(result)curl 'https://api.mails.ai/v1/messages/received?limit=10' \
-H "Authorization: Bearer $MAILS_API_KEY"mails receiving list
mails receiving list --agent-id hello \
--json | jq '.data[0].id'{
"name": "mails_list_received",
"arguments": { "limit": 10 }
}{
"data": [
{
"id": "rcv_01JZX8K3M9Q4P7VN2YB6RTDC0E",
"agent_id": "agt_01JZX8K3M9Q4P7VN2YB6RTDC0E",
"thread_id": "thrd_01JZX8K3M9Q4P7VN2YB6RTDC0E",
"from": {
"address": "jordan@example.com",
"name": "<name>"
},
"envelope_from": "<envelope_from>",
"to": "jordan@example.com",
"delivered_to": "<delivered_to>",
"subject": "<subject>",
"is_thread_reply": false,
"in_reply_to_message_id": "msg_01JZX8K3M9Q4P7VN2YB6RTDC0E",
"thread_root_message_id": "msg_01JZX8K3M9Q4P7VN2YB6RTDC0E",
"body_text": "<body_text>",
"body_html": "<body_html>",
"body_text_excerpt": "<body_text_excerpt>",
"extracted_text": "<extracted_text>",
"extracted_html": "<extracted_html>",
"codes": [{ "value": null }],
"links": [{ "url": null, "kind": null }],
"spf_pass": false,
"dkim_pass": false,
"dkim": "pass",
"dkim_domain": "<dkim_domain>",
"dmarc": "pass",
"auth_failed": false,
"has_attachment": false,
"attachments": [
{
"id": null,
"filename": null,
"content_type": null,
"size": null,
"content_id": null,
"inline": null
}
],
"attachments_omitted": [
{
"filename": null,
"content_type": null,
"size": null,
"reason": null
}
],
"attachments_omitted_count": 0,
"raw_omitted": "too_large",
"over_limit": "quota_exceeded",
"parse_status": "parsed",
"injection_score": 0,
"quarantined": false,
"received_at": "2026-10-04T12:00:00.000Z",
"raw_url": "<raw_url>",
"created_at": "2026-10-04T12:00:00.000Z"
}
],
"has_more": false,
"next_cursor": "<next_cursor>"
}200 A page of received messages (excerpts only; fetch
one for full body).
400 Invalid request — malformed JSON or a field failed
validation. Also feature_not_enabled when this
server has a feature switched off (custom domains
before they are available).
401 Missing or invalid API key.
403 The API key lacks the required scope
(insufficient_scope), or the token belongs to an
app connected by sign-in and this operation is
closed to connected apps
(connected_app_not_allowed).
409 Conflict — duplicate resource, an in-progress
idempotent request, a draft or scheduled message
that started sending while it was being changed, or
a thread deleted for good while one of its messages
is being sent (duplicate_resource); or an agent
name more than one agent has (agent_name_conflict:
use the agent's id); or a status change on an
archived agent, since archiving cannot be undone
(agent_archived).
500 Internal server error.List received messages
import { createClient } from "@mailsai/sdk";
const client = createClient(); // reads MAILS_API_KEY
const result = await client.received.list({ limit: 10 });
console.log(result);from mailsai import create_client
client = create_client() # reads MAILS_API_KEY
result = client.list_received(limit=10)
print(result)curl 'https://api.mails.ai/v1/messages/received?limit=10' \
-H "Authorization: Bearer $MAILS_API_KEY"mails receiving list
mails receiving list --agent-id hello \
--json | jq '.data[0].id'{
"name": "mails_list_received",
"arguments": { "limit": 10 }
}{
"data": [
{
"id": "rcv_01JZX8K3M9Q4P7VN2YB6RTDC0E",
"agent_id": "agt_01JZX8K3M9Q4P7VN2YB6RTDC0E",
"thread_id": "thrd_01JZX8K3M9Q4P7VN2YB6RTDC0E",
"from": {
"address": "jordan@example.com",
"name": "<name>"
},
"envelope_from": "<envelope_from>",
"to": "jordan@example.com",
"delivered_to": "<delivered_to>",
"subject": "<subject>",
"is_thread_reply": false,
"in_reply_to_message_id": "msg_01JZX8K3M9Q4P7VN2YB6RTDC0E",
"thread_root_message_id": "msg_01JZX8K3M9Q4P7VN2YB6RTDC0E",
"body_text": "<body_text>",
"body_html": "<body_html>",
"body_text_excerpt": "<body_text_excerpt>",
"extracted_text": "<extracted_text>",
"extracted_html": "<extracted_html>",
"codes": [{ "value": null }],
"links": [{ "url": null, "kind": null }],
"spf_pass": false,
"dkim_pass": false,
"dkim": "pass",
"dkim_domain": "<dkim_domain>",
"dmarc": "pass",
"auth_failed": false,
"has_attachment": false,
"attachments": [
{
"id": null,
"filename": null,
"content_type": null,
"size": null,
"content_id": null,
"inline": null
}
],
"attachments_omitted": [
{
"filename": null,
"content_type": null,
"size": null,
"reason": null
}
],
"attachments_omitted_count": 0,
"raw_omitted": "too_large",
"over_limit": "quota_exceeded",
"parse_status": "parsed",
"injection_score": 0,
"quarantined": false,
"received_at": "2026-10-04T12:00:00.000Z",
"raw_url": "<raw_url>",
"created_at": "2026-10-04T12:00:00.000Z"
}
],
"has_more": false,
"next_cursor": "<next_cursor>"
}200 A page of received messages (excerpts only; fetch
one for full body).
400 Invalid request — malformed JSON or a field failed
validation. Also feature_not_enabled when this
server has a feature switched off (custom domains
before they are available).
401 Missing or invalid API key.
403 The API key lacks the required scope
(insufficient_scope), or the token belongs to an
app connected by sign-in and this operation is
closed to connected apps
(connected_app_not_allowed).
409 Conflict — duplicate resource, an in-progress
idempotent request, a draft or scheduled message
that started sending while it was being changed, or
a thread deleted for good while one of its messages
is being sent (duplicate_resource); or an agent
name more than one agent has (agent_name_conflict:
use the agent's id); or a status change on an
archived agent, since archiving cannot be undone
(agent_archived).
500 Internal server error.Query Parameters
Page size (1–100).
Opaque cursor from a previous page's next_cursor.
Filter by agent id or name. A key tied to one agent always reads that agent's mail, and naming another agent is a 403.
Filter by thread id.
Case-insensitive substring of the subject, body or sender address. For word search across all mail, use GET /v1/search.
Only mail from this sender: an address (noreply@github.com, in any case) or a domain (github.com, which takes its subdomains such as mail.github.com and never github.com.evil.example). It is the From header's address, proven only when the message's dmarc is pass. Anything else answers 400 invalid_param_value.
Only mail sent to this address, in any case: the message's delivered_to. Give each test run or sign-up its own plus address (qa.acme+run-1842@in.mails.ai) and pass it here, so runs that overlap never read each other's mail. In a query string, write its + as %2B: one left as it is arrives as a space, which is read back as +. Mail received before 2026-10-16 has no delivered_to and never matches. Anything that is not an address answers 400 invalid_param_value.
Only mail received at or after this time: an ISO 8601 time such as 2026-10-05T07:00:00Z, or a date (midnight UTC). Any other value answers 400 invalid_param_value.
Response
The items on this page, at most limit of them.
True when more items follow this page: pass next_cursor as cursor to get them.
Pass as cursor to fetch the next page. Absent on the last page.
Was this page helpful?