# Threading

Messages are automatically grouped into conversations using email threading headers.

## How threading works

When a message arrives (inbound or outbound), Robotomail resolves its thread using two strategies in order:

1. **Header matching:** If the message has an `In-Reply-To` or `References` header, Robotomail looks up the referenced message ID and joins that thread.
2. **Subject fallback:** If no header match is found, Robotomail normalizes the subject (strips `Re:`, `Fwd:`, whitespace) and matches against existing threads in the same mailbox.

If neither strategy matches, a new thread is created.


## Replying to messages

To reply to a message, pass the original message's `messageId` (the RFC 5322 Message-ID, not the Robotomail UUID) in the `inReplyTo` field when sending. Robotomail automatically sets the `In-Reply-To` and `References` headers and joins the existing thread.


## Thread API

List threads via `GET /v1/mailboxes/:id/threads` and fetch a thread with all its messages via `GET /v1/mailboxes/:id/threads/:threadId`. See the [Threads API reference](https://robotomail.com/docs/api/threads).


---

Previous: [Mailboxes](https://robotomail.com/docs/concepts/mailboxes.md) | Next: [Webhooks](https://robotomail.com/docs/concepts/webhooks.md)
