Issue with Nylas v3 $search on input with search_query_native

When I use the $search param with a connected outlook grant, nylas throws an error stating that the $ is invalid. I don’t think my syntax is incorrect?

Here’s an example query:

curl --request GET \
  --url "https://api.us.nylas.com/v3/grants/<NYLAS_GRANT_ID>/messages?limit=5&search_query_native=%24search%3Dto%3Aphilippe%example.com" \
  --header 'Accept: application/json, application/gzip' \
  --header 'Authorization: Bearer <NYLAS_API_KEY>' \
  --header 'Content-Type: application/json'

I get this 400 error response:

{
  "request_id": "7241143411-09b2d291-7010-44b9-b889-f65b5603c32b",
  "error": {
    "type": "general_error",
    "message": "Bad Request",
    "provider_error": {
      "error": {
        "code": "BadRequest",
        "message": "Syntax error: character '$' is not valid at position 0 in '$search=to:philippe@example.com'."
      }
    }
  }
}

Note: It does not throw this error when I have $filter at the start

The issue is that $search is not a supported Microsoft Graph query parameter for the search_query_native parameter in Nylas API v3. The reason that using $search in the search_query_native is because this is not well supported in Microsoft and is often either ignored or returns partial result.

For Microsoft Graph accounts, you can use $filter queries in the search_query_native parameter. The documentation shows an example using $filter for Microsoft Graph:

curl --request GET \
  --url "https://api.us.nylas.com/v3/grants/<NYLAS_GRANT_ID>/messages?search_query_native=%24filter%3Dfrom%2FemailAddress%2Faddress%20eq%20%27someuser%40example.com%27" \
  --header 'Accept: application/json, application/gzip' \
  --header 'Authorization: Bearer <NYLAS_API_KEY>' \
  --header 'Content-Type: application/json'

The search_query_native parameter allows you to use provider-specific query strings for Google, Microsoft Graph, EWS, and IMAP accounts, but the query string must be URL-encoded and follow the specific syntax supported by each provider.

For Microsoft Graph, you should use $filter instead of $search. To search for messages from a specific email address, your query would be:

$filter=from/emailAddress/address eq 'philippe@example.com'

URL-encoded, this becomes:

%24filter%3Dfrom%2FemailAddress%2Faddress%20eq%20%27philippe%40example.com%27

The issue is, if I need to search across the email body or recipients (not from, but to, bcc, and cc), it doesn’t seem like that is possible via this $filter param. Am I just not using this properly or is there no way to search/filter across email body on outlook emails?

@sam Just flagging this again

Body Content Search Limitation:

Unfortunately, you cannot search email body content using Microsoft Graph through Nylas. This isn’t a limitation of Nylas, but rather a deliberate design decision due to reliability issues with Microsoft Graph’s search capabilities. Microsoft’s $search functionality has documented problems including:

  • Returning partial or inconsistent results
  • Sometimes ignoring search queries entirely
  • Unreliable behavior with compound queries

Recipient Search Limitations:

For recipient searching, your options with Microsoft Graph are limited to:

What Works:

Individual recipient fields using

  • $filter:
  • $filter=from/emailAddress/address eq ‘philippe@example.com’

What Doesn’t Work Reliably:

  • Searching across all recipient fields (to/cc/bcc) simultaneously
  • Body content search
  • Complex recipient queries

Recommended Workarounds:

  1. Use Nylas standard query parameters instead of search_query_native:
# Search across all recipient fields
curl --request GET \
  --url "https://api.us.nylas.com/v3/grants/<GRANT_ID>/messages?any_email=philippe@example.com" \
  --header 'Authorization: Bearer <API_KEY>'

# Search specific recipient fields
curl --request GET \
  --url "https://api.us.nylas.com/v3/grants/<GRANT_ID>/messages?to=philippe@example.com" \
  --header 'Authorization: Bearer <API_KEY>'
  1. Subject-only content search (the only reliable content search):
curl --request GET \
  --url "https://api.us.nylas.com/v3/grants/<GRANT_ID>/messages?subject=search%20term" \
  --header 'Authorization: Bearer <API_KEY>'
  1. Client-side filtering: Retrieve messages using recipient filters and then search body content on your end.