# service-accounts

> Service accounts (owners and admins): callers for CI and scripts that are no member and hold no seat. Each holds keys (nxsa_…) that you issue, rotate and revoke; a token is shown once.

Service accounts (owners and admins): callers for CI and scripts that are no member and hold no seat. Each holds keys (nxsa_…) that you issue, rotate and revoke; a token is shown once.

## nexus service-accounts list

```sh
nexus service-accounts list
```

The organization's service accounts and their keys (owners and admins).

## nexus service-accounts create

```sh
nexus service-accounts create --name <name> --team <slug> [--owner <user-id>] --expires <YYYY-MM-DD|30d> [--dry-run]
```

Create a service account: a caller for CI and scripts that is no member and holds no seat (owners and admins).

| Option | Meaning |
| --- | --- |
| `--name <name>` | The service account's name (1 to 64 characters) |
| `--team <slug>` | The team that owns it, by slug or id: its keys stop when the team is deleted |
| `--owner <user-id>` | The member who answers for it, by user id (default: you): its keys stop when they leave the organization |
| `--expires <YYYY-MM-DD|30d>` | When it stops working: a day (YYYY-MM-DD, UTC, the whole day) or a duration (30d, 12h or a number of days); at most 365 days from now |
| `--dry-run` | Show what would change, change nothing |

```sh
nexus service-accounts create --name ci --team web --expires 90d --dry-run
nexus service-accounts create --name ci --team web --expires 2027-01-31
```

## nexus service-accounts revoke

```sh
nexus service-accounts revoke <id> [--dry-run]
```

Revoke a service account and stop every live key it holds (owners and admins).

| Option | Meaning |
| --- | --- |
| `--dry-run` | Show what would change, change nothing |

```sh
nexus service-accounts revoke sva_… --dry-run
```

## nexus service-accounts keys create

```sh
nexus service-accounts keys create <account id> --label <label> [--expires <YYYY-MM-DD|30d>]
```

Issue a key for a service account: its token (nxsa_…) is shown once.

| Option | Meaning |
| --- | --- |
| `--label <label>` | A name for the key (1 to 80 characters), to tell keys apart |
| `--expires <YYYY-MM-DD|30d>` | When the key stops working: a day or a duration, as for the account, and not past the account's own (default: 90 days from now) |

```sh
nexus service-accounts keys create sva_… --label github-actions
```

## nexus service-accounts keys rotate

```sh
nexus service-accounts keys rotate <account id> <key id> [--label <label>] [--expires <YYYY-MM-DD|30d>]
```

Issue a new key in place of one and stop the old one at once: it keeps the label and lifetime unless you set them; the new token is shown once.

| Option | Meaning |
| --- | --- |
| `--label <label>` | A name for the new key (1 to 80 characters); the old key's name by default |
| `--expires <YYYY-MM-DD|30d>` | When the new key stops working: a day or a duration, as for the account, and not past the account's own (default: as long as the old key lived) |

```sh
nexus service-accounts keys rotate sva_… sak_…
```

## nexus service-accounts keys revoke

```sh
nexus service-accounts keys revoke <account id> <key id>
```

Revoke one key at once.
