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

# Service accounts

> Manage service accounts and their access tokens.

Service accounts provide machine-to-machine authentication for CI/CD pipelines and automated workflows. Once created, their tokens can be passed via the `NSCALE_SERVICE_TOKEN` environment variable.

**Aliases:** `service-accounts`, `sa`, `serviceaccounts`

Commands that act on one service account take its ID or name either as a positional argument or with `--id`. If you omit it, the CLI opens an interactive picker, so always pass it in scripts.

## Subcommands

* [list](#list) — List service accounts
* [get](#get) — Get service account details
* [create](#create) — Create a new service account
* [update](#update) — Update an existing service account
* [rotate](#rotate) — Rotate a service account token
* [delete](#delete) — Delete a service account

***

## list

List service accounts in an organization.

```bash theme={null}
nscale service-accounts list --org <org-id> [flags]
```

**Aliases:** `list`, `ls`

### Flags

<table>
  <thead><tr><th>Flag</th><th>Description</th></tr></thead>

  <tbody>
    <tr><td>`--org string`</td><td>Organization ID or name</td></tr>

    <tr>
      <td>
        `--limit int`
      </td>

      <td>Show at most N results (client-side; every result is still fetched). Cuts before `-q`. `0` for all</td>
    </tr>

    <tr>
      <td>
        `--json`
      </td>

      <td>Emit the full JSON payload (mutually exclusive with `-q`)</td>
    </tr>

    <tr>
      <td>
        `-q, --query stringArray`
      </td>

      <td>jq filter for value extraction (see [Query output with `-q`](https://docs.nscale.com/docs/cli/query-output))</td>
    </tr>
  </tbody>
</table>

### Example

```bash theme={null}
nscale service-accounts list -q '.[].metadata.id' -q '.[].metadata.name' -q '.[].status.expiry'
```

***

## get

Get details for a specific service account.

```bash theme={null}
nscale service-accounts get <sa-id>
```

### Flags

<table>
  <thead><tr><th>Flag</th><th>Description</th></tr></thead>

  <tbody>
    <tr><td>`--id string`</td><td>Service account ID or name</td></tr>
    <tr><td>`--org string`</td><td>Organization ID or name</td></tr>

    <tr>
      <td>
        `--json`
      </td>

      <td>Emit the full JSON payload (mutually exclusive with `-q`)</td>
    </tr>

    <tr>
      <td>
        `-q, --query stringArray`
      </td>

      <td>jq filter for value extraction (see [Query output with `-q`](https://docs.nscale.com/docs/cli/query-output))</td>
    </tr>
  </tbody>
</table>

### Example

```bash theme={null}
nscale service-accounts get <sa-id> -q '.status.expiry'
```

***

## create

Create a new service account. Supports interactive mode or JSON input. The response carries the access token; the CLI also prints a `Hint:` line on stderr with the token's expiry. Save the token straight away.

```bash theme={null}
nscale service-accounts create --org <org-id> [flags]
```

### Flags

<table>
  <thead><tr><th>Flag</th><th>Description</th></tr></thead>

  <tbody>
    <tr><td>`--org string`</td><td>Organization ID or name</td></tr>
    <tr><td>`-f, --file string`</td><td>Path to a JSON file</td></tr>
    <tr><td>`--stdin`</td><td>Read JSON from standard input</td></tr>
    <tr><td>`--dry-run`</td><td>Preview actions and payload without persisting</td></tr>
    <tr><td>`-y, --yes`</td><td>Automatically confirm creation</td></tr>

    <tr>
      <td>
        `--json`
      </td>

      <td>Emit the full JSON payload (mutually exclusive with `-q`)</td>
    </tr>

    <tr>
      <td>
        `-q, --query stringArray`
      </td>

      <td>jq filter for value extraction (see [Query output with `-q`](https://docs.nscale.com/docs/cli/query-output))</td>
    </tr>
  </tbody>
</table>

### Examples

```bash theme={null}
nscale service-accounts create --org <org-id> --file serviceaccount.json
nscale service-accounts create --org <org-id> --stdin < serviceaccount.json
cat serviceaccount.json | nscale service-accounts create --org <org-id> --stdin
# Print only the access token
nscale service-accounts create --file serviceaccount.json --yes -q '.status.accessToken'
# Interactive mode
nscale service-accounts create
```

***

## update

Update an existing service account.

```bash theme={null}
nscale service-accounts update <sa-id> --org <org-id> [flags]
```

### Flags

<table>
  <thead><tr><th>Flag</th><th>Description</th></tr></thead>

  <tbody>
    <tr><td>`--id string`</td><td>Service account ID or name</td></tr>
    <tr><td>`--org string`</td><td>Organization ID or name</td></tr>
    <tr><td>`-f, --file string`</td><td>Path to a JSON file</td></tr>
    <tr><td>`--stdin`</td><td>Read JSON from standard input</td></tr>
    <tr><td>`--dry-run`</td><td>Preview actions and payload without persisting</td></tr>
    <tr><td>`-y, --yes`</td><td>Automatically confirm update</td></tr>

    <tr>
      <td>
        `--json`
      </td>

      <td>Emit the full JSON payload (mutually exclusive with `-q`)</td>
    </tr>

    <tr>
      <td>
        `-q, --query stringArray`
      </td>

      <td>jq filter for value extraction (see [Query output with `-q`](https://docs.nscale.com/docs/cli/query-output))</td>
    </tr>
  </tbody>
</table>

### Examples

```bash theme={null}
nscale service-accounts update <sa-id> --org <org-id> --file serviceaccount.json
nscale service-accounts update <sa-id> --org <org-id> --stdin < serviceaccount.json
cat serviceaccount.json | nscale service-accounts update <sa-id> --org <org-id> --stdin
# Interactive mode
nscale service-accounts update
```

***

## rotate

Rotate the access token for a service account. The old token is invalidated and a new one is returned.

```bash theme={null}
nscale service-accounts rotate <sa-id> [flags]
```

### Flags

<table>
  <thead><tr><th>Flag</th><th>Description</th></tr></thead>

  <tbody>
    <tr><td>`--id string`</td><td>Service account ID or name</td></tr>
    <tr><td>`--org string`</td><td>Organization ID or name</td></tr>
    <tr><td>`--dry-run`</td><td>Preview actions and payload without persisting</td></tr>
    <tr><td>`-y, --yes`</td><td>Automatically confirm token rotation</td></tr>

    <tr>
      <td>
        `--json`
      </td>

      <td>Emit the full JSON payload (mutually exclusive with `-q`)</td>
    </tr>

    <tr>
      <td>
        `-q, --query stringArray`
      </td>

      <td>jq filter for value extraction (see [Query output with `-q`](https://docs.nscale.com/docs/cli/query-output))</td>
    </tr>
  </tbody>
</table>

### Example

```bash theme={null}
nscale service-accounts rotate <sa-id> --yes
# Print only the new access token
nscale service-accounts rotate <sa-id> --yes -q '.status.accessToken'
```

***

## delete

Delete an existing service account.

```bash theme={null}
nscale service-accounts delete <sa-id> [flags]
```

**Aliases:** `delete`, `rm`, `remove`

### Flags

| Flag | Description |
| - | - |
| `--id string` | Service account ID or name |
| `--org string` | Organization ID or name |
| `--dry-run` | Preview actions and payload without persisting |
| `-y, --yes` | Automatically confirm deletion |

***

## Related

> [card] [Service Tokens (Console)](https://docs.nscale.com/docs/manage/service-tokens.md)
>
> Generate and manage service tokens via the Console UI.
