Authentication

March 28, 2026 ยท View on GitHub

Overview

Available Operations

exchangeSsoToken

During the autorization process, Vercel sends the user to the provider redirectLoginUrl, that includes the OAuth authorization code parameter. The provider then calls the SSO Token Exchange endpoint with the sent code and receives the OIDC token. They log the user in based on this token and redirects the user back to the Vercel account using deep-link parameters included the redirectLoginUrl. Providers should not persist the returned id_token in a database since the token will expire. See Authentication with SSO for more details.

Example Usage

import { Vercel } from "@vercel/sdk";

const vercel = new Vercel();

async function run() {
  const result = await vercel.authentication.exchangeSsoToken({
    code: "<value>",
    clientId: "<id>",
    clientSecret: "<value>",
    grantType: "authorization_code",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { VercelCore } from "@vercel/sdk/core.js";
import { marketplaceExchangeSsoToken } from "@vercel/sdk/funcs/marketplaceExchangeSsoToken.js";

// Use `VercelCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const vercel = new VercelCore();

async function run() {
  const res = await marketplaceExchangeSsoToken(vercel, {
    code: "<value>",
    clientId: "<id>",
    clientSecret: "<value>",
    grantType: "authorization_code",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("marketplaceExchangeSsoToken failed:", res.error);
  }
}

run();

Parameters

ParameterTypeRequiredDescription
requestmodels.ExchangeSsoTokenRequestBody:heavy_check_mark:The request object to use for the request.
optionsRequestOptions:heavy_minus_sign:Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit:heavy_minus_sign:Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retriesRetryConfig:heavy_minus_sign:Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.ExchangeSsoTokenResponseBody>

Errors

Error TypeStatus CodeContent Type
models.SDKError4XX, 5XX*/*

listAuthTokens

Retrieve a list of the current User's authentication tokens.

Example Usage

import { Vercel } from "@vercel/sdk";

const vercel = new Vercel({
  bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await vercel.authentication.listAuthTokens();

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { VercelCore } from "@vercel/sdk/core.js";
import { authenticationListAuthTokens } from "@vercel/sdk/funcs/authenticationListAuthTokens.js";

// Use `VercelCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const vercel = new VercelCore({
  bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await authenticationListAuthTokens(vercel);
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("authenticationListAuthTokens failed:", res.error);
  }
}

run();

Parameters

ParameterTypeRequiredDescription
optionsRequestOptions:heavy_minus_sign:Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit:heavy_minus_sign:Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retriesRetryConfig:heavy_minus_sign:Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.ListAuthTokensResponseBody>

Errors

Error TypeStatus CodeContent Type
models.SDKError4XX, 5XX*/*

createAuthToken

Creates and returns a new authentication token for the currently authenticated User. The bearerToken property is only provided once, in the response body, so be sure to save it on the client for use with API requests.

Example Usage

import { Vercel } from "@vercel/sdk";

const vercel = new Vercel({
  bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await vercel.authentication.createAuthToken({
    teamId: "team_1a2b3c4d5e6f7g8h9i0j1k2l",
    slug: "my-team-url-slug",
    requestBody: {
      name: "<value>",
    },
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { VercelCore } from "@vercel/sdk/core.js";
import { authenticationCreateAuthToken } from "@vercel/sdk/funcs/authenticationCreateAuthToken.js";

// Use `VercelCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const vercel = new VercelCore({
  bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await authenticationCreateAuthToken(vercel, {
    teamId: "team_1a2b3c4d5e6f7g8h9i0j1k2l",
    slug: "my-team-url-slug",
    requestBody: {
      name: "<value>",
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("authenticationCreateAuthToken failed:", res.error);
  }
}

run();

Parameters

ParameterTypeRequiredDescription
requestmodels.CreateAuthTokenRequest:heavy_check_mark:The request object to use for the request.
optionsRequestOptions:heavy_minus_sign:Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit:heavy_minus_sign:Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retriesRetryConfig:heavy_minus_sign:Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.CreateAuthTokenResponseBody>

Errors

Error TypeStatus CodeContent Type
models.SDKError4XX, 5XX*/*

getAuthToken

Retrieve metadata about an authentication token belonging to the currently authenticated User.

Example Usage

import { Vercel } from "@vercel/sdk";

const vercel = new Vercel({
  bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await vercel.authentication.getAuthToken({
    tokenId: "5d9f2ebd38ddca62e5d51e9c1704c72530bdc8bfdd41e782a6687c48399e8391",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { VercelCore } from "@vercel/sdk/core.js";
import { authenticationGetAuthToken } from "@vercel/sdk/funcs/authenticationGetAuthToken.js";

// Use `VercelCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const vercel = new VercelCore({
  bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await authenticationGetAuthToken(vercel, {
    tokenId: "5d9f2ebd38ddca62e5d51e9c1704c72530bdc8bfdd41e782a6687c48399e8391",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("authenticationGetAuthToken failed:", res.error);
  }
}

run();

Parameters

ParameterTypeRequiredDescription
requestmodels.GetAuthTokenRequest:heavy_check_mark:The request object to use for the request.
optionsRequestOptions:heavy_minus_sign:Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit:heavy_minus_sign:Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retriesRetryConfig:heavy_minus_sign:Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.GetAuthTokenResponseBody>

Errors

Error TypeStatus CodeContent Type
models.SDKError4XX, 5XX*/*

deleteAuthToken

Invalidate an authentication token, such that it will no longer be valid for future HTTP requests.

Example Usage

import { Vercel } from "@vercel/sdk";

const vercel = new Vercel({
  bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await vercel.authentication.deleteAuthToken({
    tokenId: "5d9f2ebd38ddca62e5d51e9c1704c72530bdc8bfdd41e782a6687c48399e8391",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { VercelCore } from "@vercel/sdk/core.js";
import { authenticationDeleteAuthToken } from "@vercel/sdk/funcs/authenticationDeleteAuthToken.js";

// Use `VercelCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const vercel = new VercelCore({
  bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await authenticationDeleteAuthToken(vercel, {
    tokenId: "5d9f2ebd38ddca62e5d51e9c1704c72530bdc8bfdd41e782a6687c48399e8391",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("authenticationDeleteAuthToken failed:", res.error);
  }
}

run();

Parameters

ParameterTypeRequiredDescription
requestmodels.DeleteAuthTokenRequest:heavy_check_mark:The request object to use for the request.
optionsRequestOptions:heavy_minus_sign:Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit:heavy_minus_sign:Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retriesRetryConfig:heavy_minus_sign:Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.DeleteAuthTokenResponseBody>

Errors

Error TypeStatus CodeContent Type
models.SDKError4XX, 5XX*/*