Skip to content
Skip to main content
GET
/v3/grants/{grant_id}/messages

Return all Messages

Returns all messages using standard pagination.

⚠️ Your users receive a large number of messages. If you encounter 429 errors or provider rate limits when listing messages, Nylas recommends you set the limit parameter to 20 and add query parameters to your request to limit the results.
NYLAS API KEYACCESS TOKEN

Parameters

Path parameters

grant_id*string

ID of the grant to access. You can also use the email address associated with the grant, or use /me/ to refer to the grant associated with an access token.

Query parameters

any_emailstring

Return messages that were sent to or received from this comma-separated list of email addresses (for example, [email protected],[email protected]). 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.

bccstring

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.

ccstring

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.

fieldsstring

Return the specified data for each message.

  • standard: Returns the standard message payload.
  • include_headers: Returns messages and their custom 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.
standardinclude_headersinclude_tracking_optionsraw_mime
Default: "standard"
fromstring

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.

has_attachmentboolean

When true, Nylas returns messages that include attachments.

instring

Return messages in the specified folder or label, by folder ID. Required when using shared_from or query_imap.

limitinteger

The maximum number of objects to return. See Pagination for more information.

Default: 50
metadata_pairstring

Pass a metadata key/value pair (for example, ?metadata_pair=key1:value) to search for metadata associated with objects. See Metadata for more information.

page_tokenstring

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.

query_imapboolean

(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.

Default: false
received_afterinteger

Return messages received after the specified time, in seconds using the Unix timestamp format.

received_beforeinteger

Return messages received before the specified time, in seconds using the Unix timestamp format.

search_query_nativestring

Specify a URL-encoded provider-specific query string. Each provider supports a limited set of query parameters that you can use in your request alongside search_query_native:

  • Google: in, limit, and page_token
  • Microsoft: in, limit, and page_token
  • IMAP/Yahoo/iCloud: Any parameter
  • EWS: Any parameter except thread_id

Required when using shared_from.

For more information, see Searching with Nylas.

selectstring

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.

shared_fromstring

(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.

starredboolean

When true, Nylas returns starred messages.

EWS only supports starred messages on Microsoft Exchange 2010 or later.

subjectstring

Return messages with a matching subject. This filter is case-sensitive and returns partial matches.

thread_idstring

Return messages in the specified thread.

tostring

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.

unreadboolean

When true, Nylas returns unread messages.

Responses

request_idstring

The request ID.

dataarray<object>
next_cursorstringnull

A cursor pointing to the next page of results for the request.

GEThttps://api.us.nylas.com/v3/grants/nyla%40example.com/messages?fields=standard&limit=50&query_imap=false

Find your API key in the Nylas Dashboard under API Keys in your application settings.

grant_idrequiredstring

ID of the grant to access. You can also use the email address associated with the grant, or use /me/ to refer to the grant associated with an access token.