> ## 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:** `serviceaccounts`, `sa`

## 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 serviceaccounts list --org <org-id> [flags]
```

### Flags

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

  <tbody>
    <tr><td><code>--org string</code></td><td>Organization ID</td></tr>

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

    <tr>
      <td><code>-q, --query stringArray</code></td>
      <td>jq filter for value extraction (see <a href="/docs/cli/query-output">Query output with <code>-q</code></a>)</td>
    </tr>
  </tbody>
</table>

***

## get

Get details for a specific service account.

```bash theme={null}
nscale serviceaccounts get --id <sa-id> --org <org-id>
```

### Flags

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

  <tbody>
    <tr><td><code>--id string</code></td><td>Service account ID</td></tr>
    <tr><td><code>--org string</code></td><td>Organization ID</td></tr>

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

    <tr>
      <td><code>-q, --query stringArray</code></td>
      <td>jq filter for value extraction (see <a href="/docs/cli/query-output">Query output with <code>-q</code></a>)</td>
    </tr>
  </tbody>
</table>

***

## create

Create a new service account. Supports interactive mode or JSON input.

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

### Flags

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

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

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

    <tr>
      <td><code>-q, --query stringArray</code></td>
      <td>jq filter for value extraction (see <a href="/docs/cli/query-output">Query output with <code>-q</code></a>)</td>
    </tr>
  </tbody>
</table>

### Examples

```bash theme={null}
nscale serviceaccounts create --org <org-id> --file serviceaccount.json
nscale serviceaccounts create --org <org-id> --stdin < serviceaccount.json
cat serviceaccount.json | nscale serviceaccounts create --org <org-id> --stdin
# Interactive mode
nscale serviceaccounts create
```

***

## update

Update an existing service account.

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

### Flags

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

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

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

    <tr>
      <td><code>-q, --query stringArray</code></td>
      <td>jq filter for value extraction (see <a href="/docs/cli/query-output">Query output with <code>-q</code></a>)</td>
    </tr>
  </tbody>
</table>

### Examples

```bash theme={null}
nscale serviceaccounts update --org <org-id> --id <sa-id> --file serviceaccount.json
nscale serviceaccounts update --org <org-id> --id <sa-id> --stdin < serviceaccount.json
cat serviceaccount.json | nscale serviceaccounts update --org <org-id> --id <sa-id> --stdin
```

***

## rotate

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

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

### Flags

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

  <tbody>
    <tr><td><code>--id string</code></td><td>Service account ID</td></tr>
    <tr><td><code>--org string</code></td><td>Organization ID</td></tr>
    <tr><td><code>--dry-run</code></td><td>Preview the request payload without persisting</td></tr>
    <tr><td><code>-y, --yes</code></td><td>Automatically confirm token rotation</td></tr>

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

    <tr>
      <td><code>-q, --query stringArray</code></td>
      <td>jq filter for value extraction (see <a href="/docs/cli/query-output">Query output with <code>-q</code></a>)</td>
    </tr>
  </tbody>
</table>

### Example

```bash theme={null}
nscale serviceaccounts rotate --org <org-id> --id <sa-id> --yes
```

***

## delete

Delete an existing service account.

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

### Flags

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

***

## Related

<CardGroup cols={2}>
  <Card title="Service Tokens (Console)" icon="browser" href="/docs/manage/service-tokens">
    Generate and manage service tokens via the Console UI.
  </Card>
</CardGroup>
