# Thread Management

mailbot groups messages within an inbox using `In-Reply-To`, then `References`, then a normalized subject match within seven days. If nothing matches, it creates a new thread.

## Read a thread

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

Use the returned `thread_id` to follow a conversation. Message API paths take the message's resource `id`, not its email `Message-ID` header.

## Reply

```bash
curl -X POST "https://getmail.bot/v1/inboxes/$INBOX_ID/messages/$MESSAGE_ID/reply" \
  -H "Authorization: Bearer $MAILBOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"body_text":"Thanks for the update."}'
```

The reply endpoint preserves the header relationship. Subject-only fallback can group unrelated senders using the same subject, so preserve reply headers whenever possible. Read [Threads and Conversation Context](/docs/concepts/threads-conversation-context) for matching details and limitations.
