# Threads and Conversation Context

A thread groups related messages in an inbox. Read it through the API or MCP server; the billing dashboard does not display conversations.

## Inbound matching

mailbot tries these matches in order, scoped to the receiving inbox:

1. An existing message whose `message_id_header` matches `In-Reply-To`.
2. An existing message referenced by the `References` header.
3. A matching normalized subject on a thread active within the last seven days.
4. A new thread if no match is found.

Subject fallback removes reply and forward prefixes. It does not require the same sender, so unrelated messages with identical subjects can be grouped. Preserve reply headers when possible and do not rely on a guaranteed reference-chain search order.

## Reply through the API

Use `POST /v1/inboxes/{inbox_id}/messages/{message_id}/reply` with `body_text` and optional `body_html`. The endpoint sets reply headers using the original message.

The message `id` used in API paths is distinct from its email `message_id_header`. The `thread_id` identifies the conversation. Use IDs returned by the API rather than an email header as a path identifier.

## Retrieve a conversation

```bash
curl "https://getmail.bot/v1/inboxes/$INBOX_ID/threads/$THREAD_ID" \
  -H "Authorization: Bearer $MAILBOT_API_KEY"
```

Keep your application's assignments and processing state explicit. Do not assume that a new message inherits all labels from an earlier message. Data availability is subject to plan retention.

See [Get thread](/docs/api/get-thread) and [Reply to message](/docs/api/reply-message).
