Profile
Back to NewsBack
GitHub Trending 16 min
Reader Mode
vercel/sdk: Vercel SDK is a type-safe Typescript SDK that gives you access to the Vercel REST API.

vercel/sdk: Vercel SDK is a type-safe Typescript SDK that gives you access to the Vercel REST API.

8 hours ago

Vercel

Develop. Preview. Ship.

Join the Vercel Community

@vercel/sdk

The @vercel/sdk is a type-safe Typescript SDK that gives you full control over the entire Vercel platform through the Vercel REST API.

Table of Contents

* SDK Installation * Requirements * Access Tokens * Authentication * SDK Example Usage * Available Resources and Operations * Standalone functions * File uploads * Retries * Error Handling * Server Selection * Custom HTTP Client * Debugging * Maturity * Contributions

SDK Installation

The SDK can be installed with either npm, pnpm, bun or yarn package managers.

NPM

npm add @vercel/sdk

PNPM

pnpm add @vercel/sdk

Bun

bun add @vercel/sdk

Yarn

yarn add @vercel/sdk
[!NOTE]
This package is published as an ES Module (ESM) only. For applications using
CommonJS, use await import("@vercel/sdk") to import and use this package.

Requirements

For supported JavaScript runtimes, please consult RUNTIMES.md.

Access Tokens

You need to pass a valid access token to be able to use any resource or operation. Refer to Creating an Access Token to learn how to create one. Make sure that you create a token with the correct Vercel scope. If you face permission (403) errors when you are already sending a token, it can be one of the following problems:

  • The token you are using has expired. Check the expiry date of the token in the Vercel dashboard.
  • The token does not have access to the correct scope, either not the right team or it does not have account level access.
  • The resource or operation you are trying to use is not available for that team. For example, AccessGroups is an Enterprise only feature and you are using a token for a team on the pro plan.

Authentication

Per-Client Security Schemes

This SDK supports the following security scheme globally:

| Name | Type | Scheme | | ------------- | ---- | ----------- | | bearerToken | http | HTTP Bearer |

To authenticate with the API the bearerToken parameter must be set when initializing the SDK client instance. For example:

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

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

async function run() { const result = await vercel.replaceDomainsByDomainRecords({ domain: "example.com", });

console.log(result); }

run();

SDK Example Usage

Update an existing project

Update the fields of a project using either its name or id.

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

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

async function run() { const result = await vercel.projects.updateProject({ idOrName: "prj_12HKQaOmR5t5Uy6vdcQsNIiZgHGB", teamId: "team_1a2b3c4d5e6f7g8h9i0j1k2l", slug: "my-team-url-slug", requestBody: { name: "a-project-name", sandbox: { region: "iad1", failoverRegions: [ "sfo1", "cle1", ], }, }, });

console.log(result); }

run();

Available Resources and Operations

Available methods

Vercel SDK

AccessGroups

AiGateway

Aliases

Artifacts

Authentication

Billing

BulkRedirects

Certs

~~Checks~~

ChecksV2

Connect

Deployments

Dns

Domains

DomainsRegistrar

Drains

EdgeCache

Environment

FeatureFlags

GlobalConfig

Integrations

Kms

LogDrains

Logs

Marketplace

Microfrontends

Networking

Observability

ProjectRoutes

ProjectMembers

Projects

RollingRelease

Sandboxes

Security

StaticIps

Storage

Teams

User

Vcr

... (README truncated for length)
Chat with me