Skip to main content

Token

Manage the CLI-token surface (/api/v1/auth/cli-tokens). These are the long-lived bearers crewship login --token consumes and that you create in Settings → CLI tokens in the web UI. Tokens are user-scoped, not workspace-scoped — every subcommand clears WorkspaceID on the client.
Defined in cmd/crewship/cmd_token.go. All subcommands require an active login.

Subcommands


crewship token list

GET /api/v1/auth/cli-tokens. Columns: ID (first 12 chars), NAME, CREATED, LAST USED, STATUS.

crewship token create [name]

POST /api/v1/auth/cli-token. Name defaults to "CLI token". Returns the full bearer once — stored only at creation.
Output (default mode — the token value and its warning go to stderr, the metadata to stdout, so a naive > file redirect doesn’t silently persist the bearer):
The bearer is stored only at creation. Capture it now — there is no way to retrieve it later. For CI, prefer --output-file (0600 file) or TOKEN=$(crewship token create --quiet).

crewship token revoke <token-id>

DELETE /api/v1/auth/cli-tokens/{id}. Prompts for confirmation unless -y.
Anything still using the token starts getting 401 immediately. Update clients before revoking.

crewship token rotate <token-id>

Atomic-ish replacement: creates a new token (carrying the old name with a rotation timestamp suffix), prints it, then revokes the old. No dedicated server rotate endpoint exists — this is the same shape the web UI uses.
Safety notes (printed in --help and embedded in the rotation flow):
  • The new token is printed before revoke is attempted. If revoke fails, the new one is already valid — re-run crewship token revoke <old-id> manually to finish.
  • We do not roll back the new token on revoke failure — that would leave you with neither.
  • Anything still using the old token will start getting 401 the moment revoke lands. Update clients first, then rotate — or rotate then immediately update clients.
Errors:
  • token <id> is already revoked — pick a different token or just create a fresh one.
  • token <id> not found (run 'crewship token list') — typo or the token belongs to another user.
  • revoke old token (new token IS active, re-run 'crewship token revoke <old-id>'): <err> — exactly the case described above; the new token is fine, finish manually.

crewship token validate

GET /api/v1/auth/cli-token/validate. Returns user_id, email, and (when present) expires_at.
401 / 403 map to token is invalid or expired.

See also