Skip to main content
How-to guideApplies to: Workspaces with machine client access
Use this guide when an app or scheduled job needs to see which clusters exist in one workspace. The example reads the cluster list without changing any clusters.

Set up a workspace machine client

  1. Get the HTTPS workspace URL from your workspace admin. Use the origin only, without a page path or trailing slash. Use that same URL for both requests.
  2. Ask your workspace admin for a machine client, the identity your app uses. Confirm how this workspace checks management API requests. During an update, new access controls may appear before their grants take effect.
  3. Save the client ID and store the client secret in your secret manager. The secret is shown once at creation.
Use Bash, curl 7.76 or later, and jq. Run both examples in the same terminal with shell tracing off.

How the two requests work

Your app sends its client ID and secret to the workspace token endpoint. It then sends the returned access token to the cluster API on the same workspace.

1. Get an access token

Choose one setting in Bash. If your workspace checks OAuth scopes, request the read scope:
If your admin confirmed that workspace permissions are active for management API requests, omit the optional scope:
Set your workspace URL and client ID, then run the request in the same terminal. Curl prompts for the client secret without displaying it.
A successful POST /oauth2/token returns HTTP 200 and four fields. The command prints only the last three so the access token stays out of your terminal output. Example scope-based response with the token removed:
expires_in is the lifetime in seconds. Your workspace may return a different value. If curl reports a token request error, run jq -r '.error // empty' <<< "$TOKEN_REPLY" to read the error code. When workspace permissions are active, the returned scope can be empty. Use step 2 to check the actual API call.

2. List the clusters

Send the token in the Authorization header of GET /api/v1/queryservices. This request takes no body. The command reads the header from standard input so the token stays out of curl’s command-line arguments.
HTTP 200 means the call worked. Read total for the cluster count and items for the cluster records. A list with no results looks like this:
When you finish the example, run unset ACCESS_TOKEN TOKEN_REPLY. For request fields and responses, see Get an app access token or List clusters. To check the state of one cluster, use Get a cluster with the same token. To verify a grant to one cluster, follow Check which clusters a job can read.

Keep a scheduled job signed in

Have the job read its credentials from your secret manager. Use your HTTP client’s Basic authentication option for the token request. The password prompt in the example is for a person running curl. Keep the token in memory and reuse it. Request a new one shortly before its expires_in lifetime ends. If the cluster list returns 401 because the token expired, get a new token and retry that read once. This grant does not issue a refresh token. Keep secrets and tokens out of job logs. When the client secret needs replacing, rotate it while jobs keep running.

Troubleshoot a request

A cluster read confirms management API access. To run SQL with a machine client, the query engine also requires query_engine.query:execute in the token and access to the target cluster. See SQL over REST.
Last modified on December 2, 2026