> For the complete documentation index, see [llms.txt](https://docs.mailtrap.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mailtrap.io/developers/inbound/threads/list-threads.md).

# List threads

Returns the inbox's conversation threads, ordered by most recent activity first.

Only threads and messages within your plan's retention window are included; the per-thread aggregates (message count, size, senders, recipients, attachments) are computed over those accessible messages.

Use `search` to narrow the list to threads whose subject, or any message's `from`, `to`, `cc`, or `bcc` address, contains the given text.

Results use cursor pagination, up to 100 threads per page. When more results are available the response includes a `last_id`; pass it back as the `last_id` query parameter (together with the same `search`, if any) to get the next page. When `last_id` is `null` you have reached the end.

```json
{"openapi":"3.1.0","info":{"title":"Inbound","version":"2.0.0"},"tags":[{"name":"threads","description":"A thread groups the inbound and sent messages that belong to the\nsame conversation. Use these endpoints to page through an inbox's\nthreads, fetch a single thread with its messages embedded, or delete a\nthread.\n"}],"servers":[{"description":"Mailtrap API","url":"https://mailtrap.io"}],"security":[{"HeaderAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"HeaderAuth":{"type":"apiKey","description":"API token in Api-Token header","in":"header","name":"Api-Token"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Bearer token authentication"}},"parameters":{"inbox_id":{"name":"inbox_id","in":"path","required":true,"description":"Inbound inbox ID","schema":{"type":"integer"}}},"schemas":{"ThreadsListResponse":{"type":"object","required":["data","total_count","last_id"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ThreadSummary"}},"total_count":{"type":"integer","description":"Total number of threads matching the query."},"last_id":{"type":["string","null"],"description":"Cursor for the next page. `null` when there are no more results.\n"}}},"ThreadSummary":{"type":"object","description":"Summary of a thread. All aggregates are computed over the messages you\ncan still access (those within the plan's retention window). The\n`subject` and the `*_at` timestamps describe the whole thread,\nincluding messages outside the retention window.\n","required":["id","subject","message_count","size","first_message_at","last_received_at","last_sent_at","last_activity_at","last_message_id","senders","recipients","attachments"],"properties":{"id":{"type":"string"},"subject":{"type":["string","null"],"description":"Subject of the thread's root message."},"message_count":{"type":"integer","description":"Number of accessible messages in the thread. Messages sent together\n(reply-all fan-out) count once.\n"},"size":{"type":"integer","description":"Combined size of the accessible messages, in bytes."},"first_message_at":{"type":"string","format":"date-time"},"last_received_at":{"type":["string","null"],"format":"date-time","description":"When the most recent inbound message arrived, if any."},"last_sent_at":{"type":["string","null"],"format":"date-time","description":"When the most recent message was sent, if any."},"last_activity_at":{"type":"string","format":"date-time","description":"Timestamp of the most recent message in either direction."},"last_message_id":{"type":["string","null"],"description":"ID of the most recent accessible message in the thread."},"senders":{"type":"array","description":"Distinct `from` addresses across the accessible messages.","items":{"type":"string"}},"recipients":{"type":"array","description":"Distinct `to`/`cc`/`bcc` addresses across the accessible messages.","items":{"type":"string"}},"attachments":{"type":"array","description":"Attachments across the accessible messages, with download URLs.","items":{"$ref":"#/components/schemas/AttachmentWithDownloadUrl"}}}},"AttachmentWithDownloadUrl":{"allOf":[{"$ref":"#/components/schemas/Attachment"},{"type":"object","properties":{"download_url":{"type":["string","null"],"format":"uri","description":"URL to download the attachment. Expires after one hour."},"download_url_expires_at":{"type":["string","null"],"format":"date-time"}}}]},"Attachment":{"type":"object","properties":{"attachment_id":{"type":"string"},"size":{"type":["integer","null"]},"filename":{"type":["string","null"]},"content_type":{"type":["string","null"]},"content_disposition":{"type":["string","null"],"enum":["attachment","inline",null]},"content_id":{"type":["string","null"],"description":"`Content-ID` header value, used to reference inline attachments\nfrom the HTML body.\n"}}},"UnprocessableEntity":{"type":"object","properties":{"errors":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}}}}},"ErrorResponse":{"type":"object","properties":{"error":{"type":"string"}}},"ForbiddenError":{"type":"object","properties":{"errors":{"type":"string"}}}},"responses":{"Unauthorized":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"Forbidden":{"description":"Forbidden. The token lacks the permission required for this operation\n(`Access forbidden`), has no access to the account\n(`Account access forbidden`), or Email API/SMTP is not enabled for the\norganization (empty response body).\n","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ForbiddenError"}}}},"NotFound":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/api/inbound/inboxes/{inbox_id}/threads":{"get":{"operationId":"listInboundThreads","summary":"List threads","description":"Returns the inbox's conversation threads, ordered by most recent\nactivity first.\n\nOnly threads and messages within your plan's retention window are\nincluded; the per-thread aggregates (message count, size, senders,\nrecipients, attachments) are computed over those accessible messages.\n\nUse `search` to narrow the list to threads whose subject, or any\nmessage's `from`, `to`, `cc`, or `bcc` address, contains the given\ntext.\n\nResults use cursor pagination, up to 100 threads per page. When more\nresults are available the response includes a `last_id`; pass it\nback as the `last_id` query parameter (together with the same\n`search`, if any) to get the next page. When `last_id` is `null` you\nhave reached the end.\n","tags":["threads"],"parameters":[{"$ref":"#/components/parameters/inbox_id"},{"name":"last_id","in":"query","required":false,"description":"Opaque cursor from the previous response's `last_id`. Omit on the\nfirst request. A malformed cursor returns `400`.\n","schema":{"type":"string"}},{"name":"search","in":"query","required":false,"description":"Case-insensitive substring match against the thread subject and\nthe `from`, `to`, `cc`, and `bcc` addresses of its messages.\nWildcard characters (`*`, `?`) are matched literally. Leading and\ntrailing whitespace is ignored; a blank value returns the\nunfiltered list. `total_count` reflects the filtered result.\n","schema":{"type":"string","maxLength":256}}],"responses":{"200":{"description":"List of threads","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ThreadsListResponse"}}}},"400":{"description":"Invalid `last_id` cursor or `search` value","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnprocessableEntity"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.mailtrap.io/developers/inbound/threads/list-threads.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
