--- title: sf api-keys description: Create, list, and revoke the API keys that authenticate CI jobs, scripts, and agents against Spacefast sidebar: order: 10 --- API keys authenticate anything that cannot run a browser login: CI jobs, scripts, servers, agents. A key belongs to a team and carries the permissions of the preset you created it with. Every subcommand needs a login or a `--token` of its own, and acts on your default team unless you name another. Every command here also takes the [global flags](/cli#global-flags). ## sf api-keys create Create an API key and print its one-time secret. ```text sf api-keys create [--name ] [--preset ] [--connection ...] ``` ### Flags | Flag | Default | What it does | | --- | --- | --- | | `--name=` | none | Human-readable API key name. Set one so you can tell keys apart later | | `--[no-]open` | on | Open the browser. `--no-open` prints the link instead | | `--preset=` | `space_publisher` | Access preset compiled into the key's policy. One of `ci_deploy`, `space_publisher`, `space_admin`, `domain_manager`, `team_admin`, `billing_viewer`. | | `--connection=` | all team connections | Connector connection (`cxn_…`) the key may use. Repeat for more. Only `team_admin` includes connector access. | ### Presets | Preset | What a key with it can do | | --- | --- | | `space_publisher` | Publish to Spaces and read the team that owns them. The default. | | `ci_deploy` | The same permissions as `space_publisher`, named for CI. | | `space_admin` | Everything publishing does, plus rename, delete, transfer, export and import Spaces, delete versions, manage domains and webhooks, and set Space access policy. | | `domain_manager` | Manage domains and DNS. Nothing else. | | `billing_viewer` | Read the team and its billing. | | `team_admin` | Everything the team can do. | ### Examples ```bash sf api-keys create --name ci sf api-keys create --name domains-bot --preset domain_manager sf api-keys create --name linear-bot --preset team_admin --connection cxn_abc123 ``` ### Output ```text Created API key ci. ID: key_0123456789abcdef Permissions: publish:write, teams:read Secret: sfa_xxxxxxxxxxxx Store this secret now. It is only shown once. ``` The secret appears once and is never retrievable. Copy it straight into your secret store. With `--json`, `data` carries `apiKey` and the compiled `permissions` array. The secret is replaced with a note saying it was shown once. Run the command without `--json` when you need the value, or pipe the human output where you want it. Use the key by exporting `SPACEFAST_TOKEN`, passing `--token`, or storing it with `sf login --token`. ### Errors | Code | Exit | When | | --- | --- | --- | | `auth_required` | 10 | Not authenticated. "Run `sf login` or pass --token before managing API keys." | | `validation_error` | 2 | No team resolved. "Choose a default team with `sf teams switch ` first." | ## sf api-keys list List API keys for the selected team. ```text sf api-keys list [-T ] [--limit ] ``` Aliases: `sf api-keys ls`. | Flag | Default | What it does | | --- | --- | --- | | `-T, --team=` | default team | Team slug, ID, or name. Env `SPACEFAST_TEAM`. | | `--limit=` | `50` | Maximum keys to return. Between 1 and 100. | ```bash sf api-keys list sf api-keys list --team acme ``` ### Output A table of keys, and with `--json` the list envelope from the API straight through: ```json { "data": [ { "id": "key_0123456789abcdef", "name": "ci", "preset": "space_publisher", "enabled": true, "revokedAt": null, "secretPreview": "sfa_ab12...cdef", "lastUsedAt": null, "createdAt": "2026-06-01T00:00:00.000Z", "updatedAt": "2026-06-01T00:00:00.000Z" } ], "pagination": { "nextCursor": null, "hasMore": false } } ``` `secretPreview` is the only fragment of the secret you ever see again. `lastUsedAt` tells you which keys are dead weight. ## sf api-keys update Rename an API key, or change which connector connections it may use. ```text sf api-keys update [--name ] [--connection ... | --all-connections] ``` | Flag | Default | What it does | | --- | --- | --- | | `--name=` | unchanged | New API key name | | `--connection=` | unchanged | Connector connection (`cxn_…`) the key may use. Repeat for more. Cannot be combined with `--all-connections` | | `--all-connections` | `false` | Remove the connection limit so the key can use every team connection again | ```bash sf api-keys update key_0123456789abcdef --connection cxn_abc123 --connection cxn_def456 sf api-keys update key_0123456789abcdef --all-connections ``` ## sf api-keys revoke Revoke an API key. ```text sf api-keys revoke ID [-y] ``` | Argument | What it does | | --- | --- | | `` | API key ID, for example `key_0123456789abcdef`. Take it from `sf api-keys list`. | ```bash sf api-keys revoke key_0123456789abcdef ``` It confirms first: `Revoke API key ? Every integration using it stops working immediately.` The effect is immediate and there is no undo, so mint the replacement before you revoke the old one. This is a remote destructive action. Agent mode never auto-confirms it, and a non-interactive run needs an explicit `--yes` or fails with `confirmation_required` (exit 2). ### Output ```text Revoked API key key_0123456789abcdef. ``` `--json` returns `{ "data": { "id": "key_0123456789abcdef", "revoked": true } }`. Revoking a key does not sign you out of the CLI. `sf logout` handles the credential the CLI minted for itself.