---
title: Authenticate Vercel CLI from CI/CD with OIDC
description: Run Vercel CLI in GitHub Actions and other CI/CD providers without storing access tokens, by exchanging the OpenID Connect (OIDC) token from your...
url: "https://vercel.com/docs/cli/oidc"
last_updated: 2018-10-20
related:
  - /docs/oidc/policies
  - /docs/accounts/access-tokens
  - /docs/cli/oidc-policies
  - /docs/cli/global-options
  - /docs/oidc
install_vercel_plugin: npx plugins add vercel/vercel-plugin
search_with_vercel_cli: npx vercel@latest docs search "<query>"
search_kb_with_vercel_cli: npx vercel@latest kb search "<query>"
---

# Authenticate Vercel CLI from CI/CD with OIDC

You can run Vercel CLI from an external CI/CD provider, such as GitHub Actions, without storing a long-lived access token as a secret. Instead, you exchange the OpenID Connect (OIDC) token that your provider issues to each job for a short-lived Vercel CLI access token.

This approach is known as Workload Identity Federation (WIF). Vercel trusts your CI/CD provider's identity for the workload, instead of a secret you create and rotate yourself. Vercel CLI is one of several [built-in apps](/docs/oidc/policies#built-in-apps) that support it.

Compared to a [Personal Access Token](/docs/accounts/access-tokens), the Vercel CLI access token you get from an OIDC exchange:

- Is short-lived, and there's no secret to store, leak, or rotate
- Only grants the permissions that your OIDC policy allows, and optionally only on the projects you select
- Belongs to your team, rather than to a specific team member, so it keeps working when people leave the team

## How it works

You create a **Vercel CLI policy**, an [OIDC policy](/docs/oidc/policies) that describes which workloads may authenticate (for example, a specific GitHub repository, workflow, or branch) and what they may do (the Vercel CLI commands and projects you allow). Your CI/CD job then exchanges its OIDC token for a short-lived Vercel CLI access token, and sets it as `VERCEL_TOKEN` together with your team ID as `VERCEL_ORG_ID`, so that later Vercel CLI commands are authenticated. See [How the exchange works](/docs/oidc/policies#how-the-exchange-works) for the details.

When you exchange an OIDC token for a Vercel CLI access token, Vercel attributes the resources you create and the actions you take with that token to Vercel CLI on your team, rather than to a team member.

## Understand command-based permissions

When you configure a Vercel CLI policy, you select the `vercel` commands that the policy allows. Vercel doesn't restrict the token to exactly those commands. Instead, each command maps to the set of permissions (scopes) it needs, and the policy grants the union of those permissions. The issued token can then do anything those permissions allow, so enabling one command can enable others.

Read-write permissions include read access. For example, `read-write:deployment` satisfies a command that only needs `read:deployment`.

The policy form shows the effect of your selection as you build it. Commands that your selection enables without you selecting them are marked **implicitly enabled**, and the **Scopes enabled** list shows the exact permissions the token receives. For an existing policy, [`vercel oidc-policies inspect`](/docs/cli/oidc-policies#inspect) shows the same permissions.

## Set up OIDC for Vercel CLI

- ### Create a Vercel CLI policy
  #### Dashboard
  On the Vercel dashboard, go to your team's **Settings → Build and Deployment →** [**OIDC Policies**](/d?to=%2F%5Bteam%5D%2F%7E%2Fsettings%2Fbuild-and-deployment%23oidc-cli-policies\&title=OIDC+Policies), then click **Add** next to **Vercel CLI Policies**. You can also [open the form directly](/d?to=%2F%5Bteam%5D%2F%7E%2Fsettings%2Fbuild-and-deployment%3FaddOidcPolicy%3Dvercel-cli\&title=Add+a+Vercel+CLI+OIDC+Policy).

  You can also add a Vercel CLI policy from a project's **Settings → Build and Deployment** page. A policy you create there applies to that project.

  Fill out the form:
  1. Enter a **policy name**.
  2. Select your CI/CD provider. For any other provider, choose **Custom provider** and enter its issuer URL and the claims to match.
  3. Identify the workload. For GitHub Actions, select the GitHub account and repository that run the workflow. You can optionally restrict the policy to a specific workflow or branch, and customize the audience.
  4. Choose the **project scope**: all projects, or only specific projects.
  5. Select the **commands** the policy allows. See [Understand command-based permissions](#understand-command-based-permissions) for how your selection maps to permissions.
  #### Vercel CLI
  From a machine where you're signed in to Vercel CLI, run [`vercel oidc-policies create`](/docs/cli/oidc-policies#create). Pass the issuer and claims that identify the workload, the commands the policy allows with `--command`, and optionally the projects with `--project`. Without `--project`, the policy applies to all projects.

  For example, to let GitHub Actions workflows in the `acme/web` repository deploy the `web` project and pull its production environment variables:
  ```bash filename="terminal"
  vercel oidc-policies create --name deploy-web \
    --issuer https://token.actions.githubusercontent.com \
    --claim aud=https://github.com/acme --claim repository=acme/web \
    --command deploy --command "env pull (production)" \
    --project web
  ```
  The command names are the ones listed in the dashboard's policy form. To see the permissions that the policy grants, including those that its commands imply, run `vercel oidc-policies inspect` with the policy ID that `create` printed. See [Understand command-based permissions](#understand-command-based-permissions).

  Every policy must match the `aud` (audience) claim, plus at least one claim that identifies the workload. See [Match workloads to a policy](/docs/oidc/policies#match-workloads-to-a-policy).

- ### Add your team and project IDs as repository variables
  Vercel CLI needs your team ID in `VERCEL_ORG_ID`. You can find the ID (it looks like `team_…`) on your team's [**General** settings page](/d?to=%2F%5Bteam%5D%2F%7E%2Fsettings\&title=Find+Team+ID). Vercel CLI doesn't accept a team slug here.

  To run commands against a project without running `vercel link`, also set `VERCEL_PROJECT_ID` to the project's ID (it looks like `prj_…`), which you can find on the project's **General** settings page. See [CLI Global Options](/docs/cli/global-options#project) for more about selecting a project.

  The exact steps depend on your CI/CD provider. For GitHub, use the [GitHub CLI](https://cli.github.com/) from your repository:
  ```bash filename="terminal"
  gh variable set VERCEL_ORG_ID --body "team_your-team-id"
  gh variable set VERCEL_PROJECT_ID --body "prj_your-project-id"
  ```
  Or add them through the GitHub UI under **Settings → Secrets and variables → Actions**, on the [**Variables** tab](https://docs.github.com/en/actions/learn-github-actions/variables#creating-configuration-variables-for-a-repository).
  > **💡 Note:** Use repository variables rather than secrets. These IDs aren't sensitive, and
  > CI/CD providers like GitHub censor secret values in log output, which makes
  > logs harder to read.

- ### Exchange the OIDC token in your job
  #### GitHub Actions
  Add [`vercel/authenticate-cli-action`](https://github.com/vercel/authenticate-cli-action) before any step that runs Vercel CLI. The action requests a GitHub OIDC token, exchanges it for a short-lived Vercel CLI access token, and sets `VERCEL_TOKEN` and `VERCEL_ORG_ID` for later steps.

  The job needs the [`id-token: write` permission](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect) so that it can request a GitHub OIDC token:
  ```yaml filename=".github/workflows/deploy.yml" {7-9,19-22}
  name: Deploy

  on:
    push:
      branches: [main]

  permissions:
    contents: read
    id-token: write

  jobs:
    deploy:
      runs-on: ubuntu-latest
      env:
        VERCEL_PROJECT_ID: ${{ vars.VERCEL_PROJECT_ID }}
      steps:
        - uses: actions/checkout@v5

        - name: Authenticate Vercel CLI
          uses: vercel/authenticate-cli-action@v1.0.0
          with:
            team: ${{ vars.VERCEL_ORG_ID }}

        - run: npm install --global vercel@latest

        - run: vercel deploy
  ```
  The action accepts the following inputs:

  | Input      | Required | Description                                                                                                                                       |
  | ---------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
  | `team`     | Yes      | Your team ID (`team_…`). The action exports it as `VERCEL_ORG_ID`, and fails if you pass a team slug.                                         |
  | `audience` | No       | A custom audience for the GitHub OIDC token's `aud` claim. It must match the audience in your Vercel CLI policy.                                |
  | `policy`   | No       | The ID of the Vercel CLI policy to use. Set it when more than one of your team's policies could match the workflow.                             |

  You can tell it's working when the action succeeds and later Vercel CLI commands run without prompting you to log in.
  #### curl
  On any provider, you can exchange the token yourself with `curl`. First, request an OIDC token from your provider with the audience your policy expects. Then send it to Vercel's token endpoint, and set the result as `VERCEL_TOKEN`:
  ```bash filename="exchange-oidc-token.sh"
  # $OIDC_TOKEN: the OIDC token issued by your CI/CD provider
  # $VERCEL_ORG_ID: your Vercel team ID (team_…)

  export VERCEL_TOKEN=$(curl -sS -f -X POST https://api.vercel.com/login/oauth/token \
    --data "grant_type=urn:ietf:params:oauth:grant-type:token-exchange" \
    --data "client_id=cl_HYyOPBNtFMfHhaUn9L4QPfTZz6TP47bp" \
    --data "subject_token_type=urn:ietf:params:oauth:token-type:id_token" \
    --data "requested_token_type=urn:ietf:params:oauth:token-type:access_token" \
    --data-urlencode "team_id_or_slug=$VERCEL_ORG_ID" \
    --data-urlencode "subject_token=$OIDC_TOKEN" \
    | jq -r '.access_token')
  export VERCEL_ORG_ID

  vercel deploy
  ```
  See [Exchange a token](/docs/oidc/policies#exchange-a-token) for all the request parameters. Vercel CLI itself needs the team ID in `VERCEL_ORG_ID`, even though the token endpoint also accepts a team slug.

  For example, in GitHub Actions you can request the OIDC token with `curl` too. The job needs the `id-token: write` permission:
  ```bash filename="get-github-oidc-token.sh"
  export OIDC_TOKEN=$(curl -sS -f -G \
    -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
    "$ACTIONS_ID_TOKEN_REQUEST_URL" \
    | jq -r '.value')
  ```
  To request a custom audience, add `--data-urlencode "audience=$AUDIENCE"`.

## Use multiple policies

If more than one of your Vercel CLI policies matches the OIDC token, the exchange fails with `Multiple OIDC policies matched.` Narrow your policies' claims, or pass the ID of the policy you want, which `vercel oidc-policies list --app vercel-cli` shows:

- With the GitHub Action, set the `policy` input.
- With `curl`, add `--data-urlencode "policy_id=$POLICY_ID"`.

See [Use more than one policy](/docs/oidc/policies#use-more-than-one-policy).

## Troubleshooting

| Error or symptom                                       | Cause and fix                                                                                                                                                                          |
| ------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `OIDC environment variables are missing.`              | The GitHub Actions job is missing the `id-token: write` permission. Add it to the workflow or job.                                                                                    |
| `The "team" input must be a canonical Vercel team ID`  | You passed a team slug to the GitHub Action. Use the team ID (`team_…`) instead.                                                                                                    |
| A Vercel CLI command fails with a permissions error    | The policy doesn't grant the permissions this command needs, or the project isn't in the policy's project scope. Add the command, or the project, to the policy.                     |

For errors from the token endpoint, such as `Not authorized.`, see [OIDC Policies troubleshooting](/docs/oidc/policies#troubleshooting).

## More resources

- [OIDC Policies](/docs/oidc/policies)
- [`vercel oidc-policies`](/docs/cli/oidc-policies)
- [OpenID Connect (OIDC) Federation](/docs/oidc)
- [`vercel/authenticate-cli-action`](https://github.com/vercel/authenticate-cli-action)
- [CLI Global Options](/docs/cli/global-options)
- [Use Remote Caching from External CI/CD](/docs/monorepos/remote-caching/external-ci-cd)
- [Push Images from GitHub Actions](/docs/container-registry/github-actions)

## Search the docs from your terminal

Search the Vercel docs and read pages as Markdown with the Vercel CLI. No login required.

```bash
# Find docs pages by keyword
npx vercel@latest docs search "environment variables"
npx vercel@latest docs search "function timeout"

# Print a docs page as Markdown, by path or URL
npx vercel@latest docs inspect <page>
```

## Search guides from your terminal

Search the Knowledge Base and read guides as Markdown with the Vercel CLI. No login required.

```bash
# Find guides by keyword
npx vercel@latest kb search "rewrites and redirects"
npx vercel@latest kb search "AI SDK streaming"

# Show the latest guides
npx vercel@latest kb

# Print a guide as Markdown, by slug or URL
npx vercel@latest kb inspect <guide>
```

---

[View full sitemap](/docs/sitemap)


If you encounter incorrect information, can’t find what you need, need a capability Vercel doesn’t currently offer, or have any other feedback to report, please do it by following the instructions at https://vercel.com/feedback.md.
