Return all Messages
Changed onReturns all messages using standard pagination.
<div id="admonition-warning"> ⚠️ <b>Your users receive a large number of 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 messages, 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>Request
- Base URLhttps://api.us.nylas.com
- Auth
- HTTP bearer
- or HTTP bearer
Query parameters
Return messages that were sent to or received from this comma-separated list of email addresses (for example, leyah@example.com,nyla@example.com). Nylas returns messages that contain one of the specified email addresses in the To, From, CC, or BCC fields. You can specify up to 25 email addresses per request.
Return messages that include the specified email address in the BCC list. Because most SMTP gateways remove BCC information, Nylas usually returns messages sent from the current grant.
For Microsoft grants, Nylas sometimes doesn't return messages that satisfy the conditions of this query parameter. This is because of a limitation on the provider. Instead, you can use the thread_id to retrieve a specific conversation.
Return messages that include the specified email address in the CC list.
For Microsoft grants, Nylas sometimes doesn't return messages that satisfy the conditions of this query parameter. This is because of a limitation on the provider. Instead, you can use the thread_id to retrieve a specific conversation.
Return the specified data for each message.
- standard: Returns the standard message payload.
- include_headers: Returns messages and their full set of headers.
- include_basic_headers: Returns messages with only the three RFC threading headers (Message-ID, In-Reply-To, References) in the headers array. Use this option when you only need to track message identity and thread relationships — payload size is significantly smaller than include_headers.
- include_tracking_options: Returns messages and their tracking settings.
- raw_mime: Returns the grant_id, object, id, and raw_mime fields for each message.
Return messages sent from the specified email address. If you want to filter for messages sent from the current grant, use the in query parameter and specify the Sent folder instead.
For Microsoft grants, Nylas sometimes doesn't return messages that satisfy the conditions of this query parameter. This is because of a limitation on the provider. Instead, you can use the thread_id to retrieve a specific conversation.
When true, Nylas returns messages that include attachments.
Return messages in the specified folder or label, by folder ID. Required when using shared_from or query_imap.
The maximum number of objects to return. See Pagination for more information.
Pass one indexed metadata key/value pair (for example, ?metadata_pair=key1:value) to search for objects. The key must be key1, key2, key3, key4, or key5. See Metadata for more information.
An identifier that specifies which page of data to return. You can get this value from the next_cursor response field. See Pagination for more information.
(IMAP, Yahoo, and iCloud only) When true, Nylas queries the IMAP server directly instead of the Nylas database. You also need to set the in query parameter in your request so Nylas knows which folder to query.
Return messages received after the specified time, in seconds using the Unix timestamp format.
Return messages received before the specified time, in seconds using the Unix timestamp format.
Specify a URL-encoded search query. Connected providers use their provider-specific syntax, while Nylas Agent Accounts use Nylas full-text search syntax. The query parameters that you can use alongside search_query_native depend on the provider:
- Google: in, limit, and page_token
- Microsoft: in, limit, and page_token
- IMAP/Yahoo/iCloud: Any parameter
- EWS: Any parameter except thread_id
- Nylas Agent Accounts: Any other parameter supported for Agent Accounts by this endpoint
Required when using shared_from.
For an overview of searching messages and threads with search_query_native across providers, see Searching with Nylas. If you're using a Nylas Agent Account, see Email search for Agent Accounts for the complete Nylas search syntax, examples, and limits.
Specify fields that you want Nylas to return, as a comma-separated list (for example, select=id,updated_at). This allows you to receive only the portion of object data that you're interested in. You can use select to optimize response size and reduce latency by limiting queries to only the information that you need.
(Microsoft only) When provided, Nylas returns items from the specified shared folder ID. Required when using shared_from. This parameter only accepts a single folder ID. Check out the Shared folders guide for more information.
(Microsoft only) When provided, Nylas returns items that were shared from the specified email address. It also accepts grant ID. This parameter only accepts single email address or grant ID. Check out the Shared folders guide for more information.
When true, Nylas returns starred messages.
EWS only supports starred messages on Microsoft Exchange 2010 or later.
Return messages with a matching subject. This filter is case-sensitive and returns partial matches.
Return messages in the specified thread.
Return messages sent to the specified email address.
For Microsoft grants, Nylas sometimes doesn't return messages that satisfy the conditions of this query parameter. This is because of a limitation on the provider. Instead, you can use the thread_id to retrieve a specific conversation.
When true, Nylas returns unread messages.
Response
Messages response
Example response
{
"request_id": "5fa64c92-e840-4357-86b9-2aa364d35b88",
"next_cursor": "CigKGjRlaDdyNGQydTFqbWJ0bGo5a2QxdWJtdDZnGAEggIDAu7fw7bEYGg8IABIAGPjh2PGEi_0CIAEiBwgCEOqs6i4="
}Changes
- breaking
the
////response's property type changed fromobjecttoarrayfor status
- breaking
- info
added the optional property
/to the response with the status
- info