Unsupported Query Error When Searching Clients by Name via API

Overview

This article explains the cause of an Unsupported query error that occurs when attempting to search for a client by name using the Management API /api/v2/clients endpoint. The following error is returned:

{
"statusCode": 400,
"error": "Bad Request",
"message": "Unsupported query.",
"errorCode": "query_syntax_error"
}

Applies To

  • Management API
  • Clients Endpoint

Cause

The error occurs because the query parameter (q) for the /api/v2/clients endpoint does not support searching by the name field. While Lucene query syntax is valid for other endpoints, the available search fields are determined on a per-endpoint basis. For the /api/v2/clients endpoint, the only permitted query fields are client_grant.organization_id and client_grant.allow_any_organization, as mentioned in the endpoint description.

Solution

As a workaround, retrieve the full list of clients and filter the results within the application.

  1. Retrieve all clients using the /api/v2/clients endpoint. Include only the necessary fields to reduce the response size: https://<auth0_domain>/api/v2/clients?fields=name,client_id
  2. Parse the JSON response and filter the results by the client's name to retrieve its corresponding client_id.
  3. Use the client_id to get the complete client details by calling the get client by ID endpoint.

Recommended content

No recommended content found...