Threads and messages
Incoming email is grouped into threads automatically: a reply joins the thread of the message it answers. Each thread holds its messages and their attachments.
List threads #
GET
/v1/inboxes/{inbox_id}/threads Returns an inbox's threads, most recent activity first.
Path parameters
-
inbox_idstring required - The inbox, for example
inb_mvdlh9c06724trm1.
Query parameters
-
limitinteger - Results per page, 1–100. Default 20.
-
cursorstring - The
next_cursorfrom the previous page. -
statusstring openorarchived.-
categorystring - Only threads with this category.
curl "$MAILA_API_URL/v1/inboxes/inb_mvdlh9c06724trm1/threads?status=open" \
-H "Authorization: Bearer $MAILA_API_KEY" {
"object": "list",
"data": [
{
"object": "thread",
"id": "thr_mvdlijmoxjmnbx5g",
"inbox_id": "inb_mvdlh9c06724trm1",
"subject": "Question about my invoice",
"participants": ["jane@example.com", "support-agent@mailbox.maila.ai"],
"snippet": "Hi, I was charged twice for October…",
"message_count": 2,
"unread_count": 1,
"last_message_at": 1792335223,
"category": null,
"labels": [],
"status": "open"
}
],
"next_cursor": null
} Get a thread #
GET
/v1/inboxes/{inbox_id}/threads/{thread_id} Returns the thread with all its messages, oldest first, and each message's attachments.
Path parameters
-
inbox_idstring required - The inbox, for example
inb_mvdlh9c06724trm1. -
thread_idstring required - The thread, for example
thr_mvdlijmoxjmnbx5g.
directionisinfor received email andoutfor email you sent.statusisreceived,sent,failed,bouncedorcomplained.spam_verdictandvirus_verdictshow the result of scanning received email:PASS,FAILorGRAY.textholds up to 100 KB;text_truncatedtells you when there is more. Download the full email with Download content.
curl "$MAILA_API_URL/v1/inboxes/inb_mvdlh9c06724trm1/threads/thr_mvdlijmoxjmnbx5g" \
-H "Authorization: Bearer $MAILA_API_KEY" {
"object": "thread",
"id": "thr_mvdlijmoxjmnbx5g",
"subject": "Question about my invoice",
"message_count": 1,
"messages": [
{
"object": "message",
"id": "msg_mvdliiuwzfsa7ngv",
"direction": "in",
"from": { "address": "jane@example.com", "name": "Jane Doe" },
"to": ["support-agent@mailbox.maila.ai"],
"subject": "Question about my invoice",
"text": "Hi, I was charged twice for October…",
"has_html": true,
"status": "received",
"spam_verdict": "PASS",
"virus_verdict": "PASS",
"received_at": 1792335188,
"attachments": [
{
"object": "attachment",
"id": "att_mvdlij8sh1qgdw02",
"filename": "invoice-october.pdf",
"content_type": "application/pdf",
"size": 48213
}
]
}
]
} Update a thread #
PATCH
/v1/inboxes/{inbox_id}/threads/{thread_id} Organizes a thread. Send only the fields you want to change.
Path parameters
-
inbox_idstring required - The inbox, for example
inb_mvdlh9c06724trm1. -
thread_idstring required - The thread, for example
thr_mvdlijmoxjmnbx5g.
Body
-
readboolean truemarks the thread read;falsemarks it unread.-
statusstring openorarchived. A new reply reopens an archived thread.-
labelsstring[] - Replaces the labels. Up to 20.
-
categorystring - Sets the category. An empty string clears it.
curl -X PATCH "$MAILA_API_URL/v1/inboxes/inb_mvdlh9c06724trm1/threads/thr_mvdlijmoxjmnbx5g" \
-H "Authorization: Bearer $MAILA_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "read": true, "labels": ["billing"], "status": "archived" }' Get a message or attachment #
GET
/v1/inboxes/{inbox_id}/threads/{thread_id}/items/{item_id} Returns one message (msg_…) with its attachments, or one attachment (att_…).
Path parameters
-
inbox_idstring required - The inbox, for example
inb_mvdlh9c06724trm1. -
thread_idstring required - The thread, for example
thr_mvdlijmoxjmnbx5g. -
item_idstring required - A message or attachment id.
curl "$MAILA_API_URL/v1/inboxes/inb_mvdlh9c06724trm1/threads/thr_mvdlijmoxjmnbx5g/items/msg_mvdliiuwzfsa7ngv" \
-H "Authorization: Bearer $MAILA_API_KEY" Download content #
GET
/v1/inboxes/{inbox_id}/threads/{thread_id}/items/{item_id}/content Redirects to a download link that works for 5 minutes. For an attachment you get the file. For a message you get the complete original email (.eml), or its HTML body with ?format=html.
Path parameters
-
inbox_idstring required - The inbox, for example
inb_mvdlh9c06724trm1. -
thread_idstring required - The thread, for example
thr_mvdlijmoxjmnbx5g. -
item_idstring required - A message or attachment id.
Query parameters
-
formatstring htmlfor a message's HTML body.
- Use
-Lso curl follows the redirect.
curl -L -o invoice-october.pdf \
"$MAILA_API_URL/v1/inboxes/inb_mvdlh9c06724trm1/threads/thr_mvdlijmoxjmnbx5g/items/att_mvdlij8sh1qgdw02/content" \
-H "Authorization: Bearer $MAILA_API_KEY"