Skip to content

feat(cli): add tokens command (public auth token API parity)#15812

Merged
brookemosby merged 5 commits intomainfrom
brooke/cli-parity-tokens
Apr 2, 2026
Merged

feat(cli): add tokens command (public auth token API parity)#15812
brookemosby merged 5 commits intomainfrom
brooke/cli-parity-tokens

Conversation

@brookemosby
Copy link
Copy Markdown
Contributor

Summary

  • New vercel tokens command aligned with public APIs:
    • tokens lsGET /v6/user/tokens (optional --limit, --format json)
    • tokens add <name>POST /v3/user/tokens (optional --project for scoped tokens)
    • tokens rm <id>DELETE /v3/user/tokens/:tokenId
  • All requests use useCurrentTeam: false so listing works under a team scope (v6 rejects team context otherwise).
  • Root + subcommand telemetry; unit tests for ls/add/rm; commands map test updated.

Test plan

  • pnpm --dir packages/cli run vitest-run test/unit/commands/tokens/
  • pnpm --dir packages/cli run vitest-run test/unit/commands/index.test.ts

Made with Cursor

Add vercel tokens with ls (GET /v6/user/tokens), add (POST /v3/user/tokens),
and rm (DELETE /v3/user/tokens/:id). Requests use useCurrentTeam: false so
team scope does not break user token listing. Includes telemetry and tests.

Made-with: Cursor
@brookemosby brookemosby requested review from a team as code owners April 1, 2026 20:57
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 1, 2026

Low Risk — New CLI command feature with tests, docs, and telemetry — no auth/billing/schema changes.

  • packages/cli/src/commands/tokens/: new tokens command with ls, add, rm subcommands
  • packages/cli/src/util/telemetry/: telemetry tracking for tokens command and subcommands
  • packages/cli/test/unit/commands/tokens/: unit tests for all subcommands

Assessed at 5a951cd.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

🧪 Unit Test Strategy

Comparing: 8f171425a951cd (view diff)

Strategy: Affected packages only

✅ Only testing packages that have been modified or depend on modified packages.

Affected packages - 1 (3%)
  1. vercel
Unaffected packages - 39 (98%)
  1. @vercel-internals/get-package-json
  2. @vercel/backends
  3. @vercel/build-utils
  4. @vercel/cervel
  5. @vercel/cli-auth
  6. @vercel/client
  7. @vercel/config
  8. @vercel/detect-agent
  9. @vercel/edge
  10. @vercel/elysia
  11. @vercel/error-utils
  12. @vercel/express
  13. @vercel/fastify
  14. @vercel/firewall
  15. @vercel/frameworks
  16. @vercel/fs-detectors
  17. @vercel/functions
  18. @vercel/gatsby-plugin-vercel-builder
  19. @vercel/go
  20. @vercel/h3
  21. @vercel/hono
  22. @vercel/hydrogen
  23. @vercel/koa
  24. @vercel/nestjs
  25. @vercel/next
  26. @vercel/node
  27. @vercel/oidc
  28. @vercel/oidc-aws-credentials-provider
  29. @vercel/python
  30. @vercel/python-analysis
  31. @vercel/redwood
  32. @vercel/related-projects
  33. @vercel/remix-builder
  34. @vercel/routing-utils
  35. @vercel/ruby
  36. @vercel/rust
  37. @vercel/static-build
  38. @vercel/static-config
  39. examples

Results

  • Unit tests: Only affected packages will run unit tests
  • E2E tests: Running in parallel via E2E Tests workflow
  • Type checks: Only affected packages will run type checks

This comment is automatically generated based on the affected testing strategy

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

📦 CLI Tarball Ready

The Vercel CLI tarball for this PR is now available!

Quick Test

You can test this PR's CLI directly by running:

npx https://vercel-jmndp88i4.vercel.sh/tarballs/vercel.tgz --help

Use in vercel.json

To use this CLI version in your project builds, add to your vercel.json:

{
  "build": {
    "env": {
      "VERCEL_CLI_VERSION": "vercel@https://vercel-jmndp88i4.vercel.sh/tarballs/vercel.tgz"
    }
  }
}

Python Runtime Wheel

A vercel-runtime wheel was also built for this PR.
To use in your Python project builds, also set this environment variable:

VERCEL_RUNTIME_PYTHON="vercel-runtime @ https://vercel-jmndp88i4.vercel.sh/tarballs/vercel_runtime-0.13.0.dev1775166001+5a951cd-py3-none-any.whl"

Python Workers Wheel

A vercel-workers wheel was also built for this PR.
To use in your Python project builds, also set this environment variable:

VERCEL_WORKERS_PYTHON="vercel-workers @ https://vercel-jmndp88i4.vercel.sh/tarballs/vercel_workers-0.1.0.dev1775166001+5a951cd-py3-none-any.whl"

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 1, 2026

🦋 Changeset detected

Latest commit: 5a951cd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
vercel Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

- Align with other CLI errors (2 is reserved for help).
- Add unit tests for excess positional arguments.
- Add changeset for vercel tokens subcommands (minor).

Made-with: Cursor
- tokens add: classic-token and user-scope 403s emit structured JSON with
  verification_uri, hints, recovery next[] (open dashboard, export placeholder,
  re-run); optional verification_uri on AgentErrorPayload; export
  shouldEmitNonInteractiveCommandError; AGENT_REASON token_user_scope_required
- tokens rm: missing id uses next[] (tokens ls, tokens rm <token_id>) with
  buildCommandWithGlobalFlags; honor argv --non-interactive via outputAgentError
- Docs: non-interactive-mode notes for tokens add/rm
- Tests for add/rm agent output

Made-with: Cursor
Copy link
Copy Markdown
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Suggestion:

Missing return after writeAgentErrorPayloadAndExit in the isAPIError branch causes fall-through to the unexpected_error block when process.exit is mocked.

Fix on Vercel

@brookemosby brookemosby enabled auto-merge (squash) April 2, 2026 21:50
@brookemosby brookemosby merged commit 4b6a9b6 into main Apr 2, 2026
179 checks passed
@brookemosby brookemosby deleted the brooke/cli-parity-tokens branch April 2, 2026 21:58
ofhouse pushed a commit that referenced this pull request Apr 3, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## [email protected]

### Minor Changes

- Add `vercel tokens` subcommands (`ls`, `add`, `rm`) for auth token API
parity with the dashboard.
([#15812](#15812))

- Add `vercel project access-summary` subcommand to list member counts
by role for a project.
([#15813](#15813))

- Add `vercel project members` and `vercel project access-groups`
commands, and fix `vercel teams members` to fetch all pages from the
paginated team members API.
([#15786](#15786))

### Patch Changes

- Add `--id` flag to `vercel build` and `vercel env pull` to fetch
deployment-scoped environment variables
([#15805](#15805))

-   Updated dependencies \[]:
    -   @vercel/[email protected]

## @vercel/[email protected]

### Minor Changes

- Add Mastra framework preset
([#15076](#15076))

## @vercel/[email protected]

### Patch Changes

- Updated dependencies
\[[`d034d90dcf78316ddacdcce8fd51329fb7eefe82`](d034d90)]:
    -   @vercel/[email protected]

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants