> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e6data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Rotate an e6data OAuth client secret or retire a job

> Check which clusters a workspace machine client can read and rotate its secret while jobs keep running. Pause and resume a client, or permanently retire it when a job ends.

How-to guideApplies to: Workspaces with machine client management

Use this guide when a job already uses a workspace OAuth client. The **client secret** lets the job request access tokens. The **access token** lets it call an API until the token expires.

## Before you start

Ask a workspace admin with access to **Administration > Machine Clients** to make the change. Select the client by its **client ID**. Identify every job that uses it and where each job reads its secret. For a new job, start with [Set up a workspace machine client](https://docs.e6data.com/api-reference/list-clusters-with-oauth.md#set-up-a-workspace-machine-client).

## Check which clusters a job can read

Use this check when your workspace admin confirms that API calls by machine clients use resource grants. The **Access** tab can appear before those grants take effect. If your workspace still uses OAuth scopes, follow the [scope-based cluster example](https://docs.e6data.com/api-reference/list-clusters-with-oauth.md) instead.

1. Choose two existing test clusters in the same workspace. Use a test machine client with no other direct or group access to either cluster.
2. On the client's **Access** tab, select **Grant access**. Choose **Cluster**, select the first cluster and grant **Can use**. Leave the second cluster without a grant.
3. [Request a fresh token](https://docs.e6data.com/api-reference/list-clusters-with-oauth.md#1-get-an-access-token) with this client's credentials. Omit the optional `scope` field for this management API check.
4. Run both reads in the same Bash terminal as the token request. It already has `WORKSPACE_URL` and `ACCESS_TOKEN`. Replace the example names with your two test clusters. The commands print only each name and its HTTP status.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
for CLUSTER in example-allowed example-other; do
  curl --proto '=https' --silent --show-error --output /dev/null \
    --write-out "$CLUSTER %{http_code}\n" --header @- \
    "$WORKSPACE_URL/api/v1/queryservices/$CLUSTER" \
    <<< "Authorization: Bearer $ACCESS_TOKEN"
done
```

Expect `200` for the first cluster and `403` for the second. If both return `200`, ask the admin to check the client's group memberships, other grants and which access rules the workspace applies. If a name returns `404`, confirm the cluster name and workspace before repeating the check. These reads leave both clusters unchanged.

## Rotate a secret while jobs keep running

1. Open the client and select **Rotate Secret**. In **Grace Period (seconds)**, enter enough time to update and test every job. For example, enter `3600` for one hour. The default is `0`. Choose a value greater than zero if a job still uses the old secret. The maximum is `86400` seconds (24 hours).
2. Select **Rotate Secret** to confirm. Save the new secret as a new version in your secret manager before closing the dialog. It is shown once. During an overlap, **Previous Secret Expires** shows the deadline for switching jobs.
3. Point each job to the new secret. Check the secret version or reference in the job's configuration without printing its value. Reload credentials if the job reads them only at startup. Keep the client ID and workspace URL the same.
4. Before the deadline, have each job request a **fresh access token** using that version and read a resource it already has access to. For a job that lists clusters, follow [Get an access token](https://docs.e6data.com/api-reference/list-clusters-with-oauth.md#1-get-an-access-token) and [List the clusters](https://docs.e6data.com/api-reference/list-clusters-with-oauth.md#2-list-the-clusters). HTTP `200` on the list request completes that check. A call made with a cached token cannot tell you which secret the job now uses.
5. After the deadline, confirm each job still gets a fresh token on its next run. Once all jobs pass, remove the old version from their secret stores. Finish one rotation before starting another. Only the current secret and its immediate predecessor can work during an overlap.

| When | Which secret can get a new token? |
| - | - |
| During the grace period | Both the old and new secret |
| After the grace period | Only the new secret |
| Immediately after a rotation with zero grace | Only the new secret |

If a job gets `401 invalid_client`, check that it loaded the new secret for the correct client ID and workspace. Then retry the token request. [Troubleshoot a token request](https://docs.e6data.com/api-reference/list-clusters-with-oauth.md#troubleshoot-a-request).

## Pause a client and resume it later

If you want to pause scheduled runs, pause their schedules first. Disabling a client affects every job that uses it. Select **Disable** on the client and confirm. A disabled client cannot obtain new tokens. Already-issued tokens may remain usable until expiry. To check the pause, try a fresh token request with the client's current credentials. Expect `401 invalid_client`.

When the job should run again, select **Enable**. Request a fresh token with the current secret, run the job's usual read to confirm access, and resume any schedules you paused.

## Retire a job permanently

Stop the job and its schedule first. Confirm that every other job using this client has moved to its own credentials. Then open the client, choose **Delete**, and confirm. Deletion is permanent. To run the job again later, you will need a new client.

Verify that a fresh token request with the retired client's credentials returns `401 invalid_client`, then remove those credentials from the job's secret store. Previously issued access tokens can remain valid until their own expiry. Use the `expires_in` returned at issuance to see the token's lifetime.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.