Source: https://keypaste.com/developers/token/
Last updated: 2026-12-01

# keypaste token

Creates, lists and revokes scoped tokens, which only feed `keypaste run --token` or `--bundle`: a token injects an environment’s stage into a command and never prints a value.

## Synopsis

Terminal window

```
keypaste token create <name> --scope <scopes> [--ttl <n(m|h|d)>] [--allow-prod] [--json]keypaste token ls [--json]keypaste token revoke <name|id>keypaste token bundle <name> -o <file> [--force] [--token <token|-|env>]
```

Every verb also takes `--vault <path>` and `--keyfile <path>`. `create` and `revoke` change the vault, so lock it in the app or stop `keypaste approve` first.

## Options

| Option | Verbs | Effect |
| --- | --- | --- |
| `--scope <scopes>` | `create` | Required. What it may inject: `read:<project>/<stage>/<KEY or *>`, several separated by commas. |
| `--ttl <n(m|h|d)>` | `create` | How long it works, `30d` by default. |
| `--allow-prod` | `create` | Lets it reach a protected stage, which then asks you live every time. |
| `--json` | `create`, `ls` | Machine-readable output. |
| `-o`, `--output <file>` | `bundle` | Required. Where to write the bundle. |
| `--force` | `bundle` | Replace a file that is there. |
| `--token <token|-|env>` | `bundle` | The token, which the process holding the vault checks. `-` reads it from standard input, `env` from `KEYPASTE_TOKEN`. |

## Behaviour

- `create` prints the token once and never stores it.
- `ls` lists each token’s name, prefix, scope and expiry, never a secret. The app’s Settings › Scoped tokens lists and revokes them too.
- `keypaste run --token` asks the desktop app or `keypaste approve` holding the vault, so the job must reach that process.
- `bundle` seals the token’s sets into a file that `keypaste run --bundle` opens with the token alone, with no vault. It never holds a protected stage. A bundle can’t be revoked, and its expiry is checked against the job’s own clock, so rotate its values once it is retired or may have leaked.

## Examples

Terminal window

```
keypaste token create ci-staging --scope 'read:acme-api/staging/*'KEYPASTE_TOKEN=… keypaste run --token env -p staging acme-api -- npm testkeypaste token bundle ci-staging -o staging.bundle --token envkeypaste run --bundle staging.bundle --token env -- npm testkeypaste token revoke ci-staging
```
