---
title: "Return all threads"
method: GET
path: "/v3/grants/{grant_id}/threads"
tags: ["Threads"]
---

# Return all threads

`GET /v3/grants/{grant_id}/threads`

Returns all threads.

For Microsoft, IMAP, iCloud, Yahoo, and EWS, threads are ordered reverse chronologically by the latest message received.

For Google, thread ordering is not guaranteed to be reverse chronological due to a Gmail API limitation.
However, setting the `in` query parameter improves the likelihood of reverse chronological ordering significantly (approximately 40%).
While reverse chronological ordering remains unguaranteed even with the `in` parameter, we recommend using it to increase the chance of this ordering pattern.

<div id="admonition-warning">
⚠️ <b>Your users might receive a large number of threaded messages</b>. If you encounter
<a href="/docs/api/errors/400-response/"><code>429</code> errors</a> or provider
<a href="/docs/dev-guide/platform/rate-limits/">rate limits</a> when listing all threads, Nylas
recommends you set the <code>limit</code> parameter to 20 and add
<a href="#query-parameters">query parameters</a> to your request to
limit the results.</div>

## Query parameters

- `any_email` string
- `bcc` string
- `cc` string
- `from` string
- `has_attachment` boolean
- `in` string
- `earliest_message_date` integer
- `latest_message_after` integer
- `latest_message_before` integer
- `limit` integer
- `page_token` string
- `search_query_native` string
- `select` string
- `shared_folder_id` string
- `shared_from` string
- `starred` boolean
- `subject` string
- `to` string
- `unread` boolean

## Response `200`

Threads response

- object
  - `request_id` string — The request ID.
  - `data` object — The response object.
    - `threads` Thread[]
      - `grant_id` string — The ID of grant for the connected user.
      - `id` string — A globally unique object identifier for Microsoft accounts. An email address for Google accounts.
      - `object` string — The type of object (in this case, `thread`).
      - `latest_draft_or_message` Message
        - `attachments` Attachment[] — An array of Attachment objects. For Google, linked Google Drive files are not included. For Microsoft, linked OneDrive files are not included.
          - `id` string, required — The ID of the attachment.
          - `content_type` string — The [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types) of the attachment, used by the email client to determine how to display the attachment. If you don't provide a type, Nylas infers it from the file name. The value of this field is exactly the same as the email attachment's `Content-Type` header. The provider might set additional parameters, such as `name` and `charset`. Nylas returns an empty `content_type` field if an attachment file name contains non-ASCII characters (for example, accented characters like `ü`). This is because Google can't detect its content type.
          - `filename` string — The file name of the attachment.
          - `grant_id` string — The ID of grant for the connected user.
          - `content_id` string — (Inline attachments only) The alphanumeric `cid` from the `<img>` tag in the message's HTML. For example, you might see something like `<img src=\"cid:ce9b9547-9eeb-43b2-ac4e-58768bdf04e4\">` in the message body. Sometimes, the `content_id` value is contained in angle brackets (for example, `<ce9b9547-9eeb-43b2-ac4e-58768bdf04e4>`).
          - `content_disposition` string — (Not supported for Microsoft and EWS) The content disposition of the attachment. Usually, this is `inline` or `attachment` followed by the file name (for example, `inline; filename="some-image.jpeg"`).
          - `is_inline` boolean — If `true`, indicates that the attachment is an inline file.
          - `size` integer — The size of the attachment, in bytes.
        - `bcc` MessageParticipant[] — An array of name/email address pairs that the message was BCC'd to. For received messages, this is nearly always empty.
          - `name` string
          - `email` string, email, required
        - `body` string — The body of the message as either plain-text or HTML content. If the message has both plain-text and HTML, Nylas returns the HTML version.
        - `cc` MessageParticipant[] — An array of name/email address pairs that the message was CC'd to.
          - `name` string
          - `email` string, email, required
        - `date` integer — Unix timestamp in seconds that represents when _the mail server_ received the message. This might be different from the unified `Date` header in a raw Message object.
        - `folders` string[] — The IDs of the folders that the message appears in. Microsoft messages can be in a single folder only. Google allows a single message to appear in multiple folders.
        - `from` MessageParticipantResponse[] — A list of name/email address pairs that the message was sent from. This is usually one pair only, but can be many.
          - `name` string
          - `email` string, email
        - `grant_id` string — The ID of grant for the connected user.
        - `headers` MessageHeader[] — An array of key-value pairs that contain the message headers. Nylas returns this field when you set the `fields` query parameter to either `include_headers` or `include_basic_headers`. - `fields=include_headers`: Returns the full set of headers on the message. - `fields=include_basic_headers`: Returns only the three RFC threading headers (`Message-ID`, `In-Reply-To`, `References`). Use this option when you only need to track message identity and thread relationships — payload size is significantly smaller than `include_headers`. A single message can sometimes have multiple headers with the same key name. Nylas adds all of the headers to the `headers` array without merging or de-duplicating the data. When the headers contain encoded data, Nylas adds it to the `headers` array without decoding it. If you need the decoded data, you need to build decoding logic into your project. Some headers might contain raw MIME information (for example, `=?Windows-1252?Q?Re:_Candidature_de_Mme_Leyah_Miller?=`).
          - `name` string, required
          - `value` string, required
        - `id` string — A globally unique object identifier for Microsoft accounts. An email address for Google accounts.
        - `in_reply_to` string — (EWS only) The ID of the message that this message replies to. This ID is the same as the `In-Reply-To` header.
        - `metadata` Metadata — The metadata associated with the object. For more information, see [Metadata](/docs/reference/api/#metadata).
        - `object` string — The object type of the response (in this case, `message`).
        - `raw_mime` string — A Base64url-encoded string containing the message data (including the body content). To get the raw MIME content for a message, set the `fields` query parameter to `raw_mime` in your request. When you request raw MIME data, Nylas returns the `grant_id`, `object`, `id`, and `raw_mime` fields only.
        - `reply_to` MessageParticipant[] — An array of name/email address pairs that should receive replies to the message.
          - `name` string
          - `email` string, email, required
        - `snippet` string — A short snippet (the first 100 characters, with HTML tags removed) of the message body. This is useful for displaying a preview of the message.
        - `starred` boolean — If `true`, shows that the message has been starred by the user. For EWS, this is only supported on Microsoft Exchange 2010 or later.
        - `subject` string — The subject of the message.
        - `thread_id` string — A reference to the parent Thread object. Every message is associated with a thread, whether that thread contains one message or many. If the message is new, Nylas assigns a `thread_id` to it.
        - `to` MessageParticipant[] — An array of name/email address pairs that the message was sent to.
          - `name` string
          - `email` string, email, required
        - `tracking_options` object — Tracking options for the message.
          - `opens` boolean — When `true`, shows that message open tracking is enabled.
          - `thread_replies` boolean — When `true`, shows that thread replied tracking is enabled.
          - `links` boolean — When `true`, shows that link clicked tracking is enabled.
          - `label` string — A label describing the message tracking purpose.
        - `unread` boolean — If `true`, shows that the message has not been read by the user.
      - `has_attachments` boolean — When `true`, indicates that the message has attachments.
      - `has_drafts` boolean — When `true`, indicates that the message is a draft.
      - `earliest_message_date` integer — The date when the earliest or first message in the thread was sent or received, in seconds using the Unix timestamp format.
      - `latest_message_received_date` integer — The date when the most recent incoming message in the thread was received, in seconds using the Unix timestamp format.
      - `latest_message_sent_date` integer — The date when the most recent outgoing message in the thread was sent, in seconds using the Unix timestamp format.
      - `participants` object[] — A sub-object that contains the names and email addresses of all participants in the thread.
        - `email` string
        - `name` string
      - `snippet` string — A short snippet (the first 100 characters, with HTML tags removed) of the body of the last received message. This is useful for displaying a preview of a message.
      - `starred` boolean — When `true`, indicates that the thread is starred. For EWS, this is only supported for Microsoft Exchange 2010 or later.
      - `subject` string — The subject line of the thread.
      - `unread` boolean — When `false`, indicates that all messages in the thread have been read.
      - `message_ids` string[] — An array of IDs for all messages in the thread.
      - `draft_ids` string[] — An array of IDs for all drafts in the thread.
      - `folders` string[] — An array of folder IDs for all folders that the messages in the thread appear in. Microsoft messages can only be in one folder at a time. Google messages can be in multiple folders.
  - `next_cursor` string, nullable — A cursor pointing to the next page of results for the request.

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `429` — Rate Limit
- `504` — Provider Failure

---

[API](https://skmtc.dev/nylas/apis/nylas-api.md) · [All operations](https://skmtc.dev/nylas/apis/nylas-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/nylas/nylas-api/revisions/51c2c1b4ecff/schema)
