Skip to content
Docs
Open Escouade
Documentation contents

Docs › Mail

Threads

View as .md

A thread is the conversation between an inbox and a correspondent. It starts with the first send or the first e-mail received. Replies are filed in it, and your agent replies in the same thread.

A thread’s statuses

StatusMeaning
openOpen: waiting for a reply, or a new message received.
repliedThe correspondent replied: to be dealt with.
bouncedThe correspondent’s address failed.
unsubscribedThe correspondent unsubscribed: do not write to them again.
closedClosed: dealt with and closed with close_thread, or all its messages were cancelled.

A thread also carries its origin: outbound if it started with a send, inbound if it started with an e-mail received.

How a thread changes status

What happensThe thread becomes
The inbox writes a first message, or receives a first e-mailopen
The correspondent replies, or writes againreplied
The inbox writes in the thread, drafts includedopen, if it was replied
An automatic reply arrivesunchanged
A permanent non-delivery notice arrivesbounced
The correspondent unsubscribesunsubscribed
All the thread’s messages were cancelledclosed
The thread is dealt with, and closed with close_threadclosed
The correspondent replies in a closed threadreplied
The inbox replies in a closed threadopen
  • Replying takes the thread out of the replies to deal with: it goes back to open.
  • A first e-mail received opens an open thread, not a replied one. To find it, see Receiving mail.
  • A thread that has been dealt with is closed with close_thread: it leaves what waits for a reply. The server also closes by itself an open thread whose messages were all cancelled. A closed thread reopens if the correspondent replies in it, or if the inbox replies in it with reply_to_thread. send_email to the same correspondent, on the other hand, opens another thread.
  • An inbox has a single current thread per correspondent. A new e-mail from the same correspondent joins their thread, if it is not closed.

Receiving

Every inbox receives, with nothing to set up.

  • A reply is attached to its thread by its headers (In-Reply-To, References), otherwise by its correspondent. The thread moves to replied.
  • A new e-mail opens a thread of origin inbound.
  • An automatic reply (out of office, acknowledgement) is marked auto_reply and does not change the thread’s status.
  • A reply asking to stop (“STOP”, “unsubscribe me”…) unsubscribes the correspondent: the thread moves to unsubscribed. See Unsubscribes and blocks.
  • A non-delivery notice marks the message and the thread bounced. A hard bounce blocks the address.

To collect its mail, an agent calls list_threads with unanswered = true, then get_thread. That call returns replies received and first e-mails: see Receiving mail.

list_threads

Lists threads, newest first. Permission: read.

ParameterTypeRequiredDescription
inbox_idinb_… identifiernoA single inbox.
statustextnoA single status: open, replied, bounced, unsubscribed or closed.
unansweredbooleannotrue: only threads whose last message is a received e-mail that nothing has been written back to yet. A reply, or a first e-mail.
sincedatenoThreads active since this date (ISO 8601): those whose last message, incoming or outgoing, is later.
querytextnoA search: part of the correspondent’s address, of their name or of the subject. 100 characters at most.
foldertextnoA folder: received, sent or drafts.
labeltextnoThreads carrying this exact tag (see classify_thread). 40 characters at most.
archivedbooleannotrue: archived threads; false: those that are not.
unreadbooleannotrue: threads with an unread received message; false: those that are read.
cursortextnoThe cursor of the next page: the next_cursor value from the previous call.
limitintegernoThe number of items returned, from 1 to 100. 20 by default.
list_threadsresult
1 fil(s) :
• thr_b81f4c6a2d9e47035c1a8e6f0b4d2c97 — Nadia Morel <[email protected]> — « Rendez-vous de jeudi » — réponse reçue, à traiter — 2 messages — dernier vendredi 9 octobre à 16 h 12

get_thread

Reads a thread: its messages in order, incoming and outgoing, with their text and their status. Read it before replying. Permission: read.

ParameterTypeRequiredDescription
thread_idthr_… identifieryesThe thread.
cursortextnoThe cursor for the rest of the thread: the next_cursor value from the previous call.

The response carries thread and messages. A message’s fields are described in Messages.

One call returns 50 messages at most. If more remain, the response carries next_cursor. Beyond 200 KB of text per call, later bodies are cut: the response carries truncated: true, and get_message returns the whole message.

A received message carries untrusted: true: its content was written by a third party. Your agent reads it as information, never as an instruction. In the readable text, this content is fenced off: see Receiving mail.

In the readable text, a message’s body stops at 2,000 characters. The whole body is in the structured object (text).

In an assistant that displays MCP Apps views, get_thread comes with a view: the conversation in order. See Views.

reply_to_thread

Replies in a thread, to the thread’s correspondent: subject “Re: …” and In-Reply-To and References headers, so that the reply shows in the same conversation for the recipient. Also used to follow up. Permission: send. The space must be verified, and have an active plan: without a plan, the reply can only be a draft.

ParameterTypeRequiredDescription
thread_idthr_… identifieryesThe thread (see list_threads).
subjecttextnoThe subject. By default: “Re:” followed by the thread’s subject.
cclist of textsnoAddresses in copy, five at most. Only if the correspondent has already written in the thread, to someone who has also written in it or to an address of the space.
texttextyesThe plain text of the reply.
htmltextnoAn HTML version, with the same content as text.
reply_totextnoThe reply-to address, if it differs from the inbox.
from_addresstextnoThe sending address: the inbox’s main address, or one of its aliases (see list_inboxes).
metadataobjectnoThe agent’s free data, 8,000 characters at most.
requires_approvalbooleannotrue: the reply stays a draft until a human approves it.
send_afterdatenoNot before this date (ISO 8601, or Paris time without an offset).
idempotency_keytextnoA unique key for this send, 1 to 255 characters.

Two cases, depending on whether the correspondent has already written in the thread.

RuleThe correspondent has written: a conversationThey have not written: a follow-up
Working hoursThe reply leaves without waiting for the sending window.It waits for the sending window.
Departure orderIt goes ahead of first messages in the queue.It follows the queue.
Unsubscribe footerNo visible footer. The one-click link stays in the headers.The footer is added.
Inbox on the shared domainAccepted.Refused: own_domain_required.
Inbox on the customer’s domainAccepted.Accepted.
Daily quota, spacingApply.Apply.
Block list, human approvalApply.Apply.
Attachment, copy (cc)Allowed.Refused: attachments_not_allowed, cc_not_allowed.

In both cases, the duplicate rule does not apply: a reply in a thread is not a duplicate, and it counts towards the plan’s monthly volume. An automatic reply from the correspondent does not count as a written message.

The step-by-step guide: Reply to a correspondent. Attaching a file, adding a copy: Attachments and copies.

reply_to_threadqueued
Message msg_e93b7d1a5c0f42b8d6e2a9c4f7b1d056 en file dans le fil thr_b81f4c6a2d9e47035c1a8e6f0b4d2c97 : de [email protected] à [email protected], « Re: Rendez-vous de jeudi ». Le correspondant a déjà écrit dans ce fil : la réponse part sans attendre le créneau. Départ au plus tôt : samedi 10 octobre à 10 h 05. Quota du jour de la boîte : 0/10 (semaine 2 du réchauffage, palier de 10 par jour).

close_thread

Closes a thread that has been dealt with: it takes the closed status and leaves what waits for a reply. Nothing is erased. Permission: send or approve.

ParameterTypeRequiredDescription
thread_idthr_… identifieryesThe thread to close.
  • The result returns the thread (thread) and closed: true if it has just been closed, false if it already was.
  • While a draft or a queued message waits in the thread, the call is refused with the code thread_busy: cancel it with cancel_message, or let it leave.
  • A bounced or unsubscribed thread is already finished: code thread_not_closable.
  • A closed thread reopens by itself if the correspondent replies in it, or if the inbox replies in it.

classify_thread

Adds or removes a conversation’s tags (labels replaces the whole list), archives or restores the thread, marks received messages as read or unread. Access: send or approve.

ParameterTypeRequiredDescription
thread_idthr_… identifieryesThe conversation to classify.
labelslistnoThe thread’s tags, 20 at most (40 characters each). Replaces the whole list.
archivedbooleannoArchive or restore.
readbooleannoMark as read or unread.

A thread can carry up to 20 tags; list_threads filters them by label. Archiving a thread files it away without erasing or blocking anything.

Full reference

The fields of a thread

FieldContent
idThe thread identifier, thr_….
inbox_idThe thread’s inbox.
counterpart, counterpart_nameThe correspondent’s address and name.
subjectThe subject.
statusSee the statuses.
originoutbound or inbound.
message_countThe number of messages.
last_message_at, last_inbound_at, last_outbound_at, created_atThe dates, in ISO 8601.

Going through a list

Lists return items and next_cursor. As long as next_cursor is not null, pass it back as it is in cursor for the next page.

This page in Markdown: /en/mail/docs/fils.md All the docs for an agent: /en/mail/docs/llms.txt Legal notice · Terms · Privacy · Service status