Unsupported Query Error When Searching Clients by Name via API
Last Updated:
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.
- Retrieve all clients using the
/api/v2/clientsendpoint. Include only the necessary fields to reduce the response size:https://<auth0_domain>/api/v2/clients?fields=name,client_id - Parse the JSON response and filter the results by the client's name to retrieve its corresponding
client_id. - Use the
client_idto get the complete client details by calling the get client by ID endpoint.