{"slug":"vercel-api-platform","title":"Vercel API and CLI: Deployments, Projects, Domains, and Env Vars","tags":["vercel","deployment","api","cli","domains","env-vars"],"agent_summary":"Vercel REST API and CLI reference — deployments, projects, domains, DNS, environment variables, teams, webhooks, edge config, and CI/CD automation. 200+ endpoints across 30 categories.","trigger_phrases":["Vercel API","Vercel deploy","Vercel CLI","Vercel env vars","Vercel domains","Vercel project","Vercel deployment logs","vercel --prod"],"runnable":false,"markdown":"\n## Overview\n\nThe Vercel platform API (`https://api.vercel.com`) exposes 200+ endpoints for deployments, projects, domains, DNS, environment variables, teams, and more. The CLI wraps most operations for local use.\n\n## Authentication\n\n```bash\n# Personal Access Token\ncurl -H \"Authorization: Bearer $VERCEL_TOKEN\" https://api.vercel.com/v2/user\n\n# Team scope (append to all requests)\nhttps://api.vercel.com/v6/deployments?teamId=team_xxxxx\n\n# CLI team scope\nvercel --scope my-team deploy --prod\n```\n\nToken types: Personal Access Token (vercel.com/account/tokens), OAuth (integrations), Scoped (limited-permission automation).\n\n## CLI Installation and Core Commands\n\n```bash\nnpm i -g vercel\n\n# Deploy\nvercel deploy --prod\n\n# Link project\nvercel link\n\n# Environment variables\nvercel env pull .env.local        # Pull to local file\nvercel env add KEY production     # Add to production\nvercel env ls                     # List all\n\n# Logs\nvercel logs <deployment-url>\nvercel logs --follow              # Stream live\n\n# Domains\nvercel domains add example.com\nvercel domains ls\n\n# Rollback\nvercel rollback <deployment-url>\n\n# Project info\nvercel inspect <deployment-url>\n```\n\n## REST API Endpoint Categories\n\n| Category | Key Operations |\n|----------|----------------|\n| **Projects** (27 endpoints) | CRUD, domains, env vars, members, settings |\n| **Deployments** (10) | Create, get, list, cancel, delete |\n| **Domains** (6) | Add, remove, verify, transfer |\n| **DNS** (4) | List, add, update, remove records |\n| **Environment** (11) | Create, update, delete, list per target |\n| **Aliases** (6) | Set, remove, list custom domain aliases |\n| **Teams** (14) | Create, invite, manage members |\n| **Logs** (1) | Runtime log retrieval (streaming) |\n| **Webhooks** (4) | Create, list, get, delete |\n| **Edge-Config** (17) | Create, read, update, delete |\n| **Checks** (10) | Deployment checks for CI integration |\n\n## Common API Patterns\n\n### List Deployments\n\n```bash\ncurl -H \"Authorization: Bearer $VERCEL_TOKEN\" \\\n  \"https://api.vercel.com/v6/deployments?projectId=prj_xxx&limit=5\"\n```\n\n### Create Deployment via API\n\n```bash\ncurl -X POST \\\n  -H \"Authorization: Bearer $VERCEL_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"my-app\",\"gitSource\":{\"type\":\"github\",\"repoId\":\"123\",\"ref\":\"main\"}}' \\\n  \"https://api.vercel.com/v13/deployments\"\n```\n\n### Set Environment Variable\n\n```bash\ncurl -X POST \\\n  -H \"Authorization: Bearer $VERCEL_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"key\":\"DATABASE_URL\",\"value\":\"postgres://...\",\"target\":[\"production\"],\"type\":\"encrypted\"}' \\\n  \"https://api.vercel.com/v10/projects/prj_xxx/env\"\n```\n\n### Add DNS Record\n\n```bash\ncurl -X POST \\\n  -H \"Authorization: Bearer $VERCEL_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"api\",\"type\":\"CNAME\",\"value\":\"target.example.com\"}' \\\n  \"https://api.vercel.com/v2/domains/example.com/records\"\n```\n\n## Environment Variable Targets\n\n| Target | When Used |\n|--------|-----------|\n| `production` | `vercel deploy --prod` |\n| `preview` | Branch and PR deployments |\n| `development` | `vercel dev` local server |\n\nAlways set sensitive keys in Vercel dashboard, not in `.env` files committed to git.\n\n## Deploy from GitHub Actions\n\n```yaml\n- name: Deploy to Vercel\n  env:\n    VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}\n    VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}\n    VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}\n  run: |\n    npm i -g vercel\n    vercel pull --yes --environment=production --token=$VERCEL_TOKEN\n    vercel build --prod --token=$VERCEL_TOKEN\n    vercel deploy --prebuilt --prod --token=$VERCEL_TOKEN\n```\n\n## Edge Config\n\nEdge Config is a global key-value store with sub-millisecond reads at the edge. Use for feature flags and A/B config.\n\n```bash\n# Create via API\ncurl -X POST -H \"Authorization: Bearer $VERCEL_TOKEN\" \\\n  -d '{\"slug\":\"my-flags\"}' \\\n  \"https://api.vercel.com/v1/edge-config\"\n\n# Read in code (Next.js)\nimport { get } from \"@vercel/edge-config\";\nconst isEnabled = await get(\"feature-x\");\n```\n\n## Webhooks\n\n```bash\ncurl -X POST -H \"Authorization: Bearer $VERCEL_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"url\":\"https://api.example.com/webhook\",\"events\":[\"deployment.created\",\"deployment.ready\"]}' \\\n  \"https://api.vercel.com/v1/webhooks\"\n```\n\nEvents: `deployment.created`, `deployment.ready`, `deployment.error`, `deployment.canceled`.\n\n## Project Settings via API\n\n```bash\n# Get project\ncurl -H \"Authorization: Bearer $VERCEL_TOKEN\" \\\n  \"https://api.vercel.com/v9/projects/prj_xxx\"\n\n# Update build command\ncurl -X PATCH -H \"Authorization: Bearer $VERCEL_TOKEN\" \\\n  -d '{\"buildCommand\":\"npm run build:prod\"}' \\\n  \"https://api.vercel.com/v9/projects/prj_xxx\"\n```\n","html":"<h2>Overview</h2>\n<p>The Vercel platform API (<code>https://api.vercel.com</code>) exposes 200+ endpoints for deployments, projects, domains, DNS, environment variables, teams, and more. The CLI wraps most operations for local use.</p>\n<h2>Authentication</h2>\n<pre><code class=\"language-bash\"># Personal Access Token\ncurl -H \"Authorization: Bearer $VERCEL_TOKEN\" https://api.vercel.com/v2/user\n\n# Team scope (append to all requests)\nhttps://api.vercel.com/v6/deployments?teamId=team_xxxxx\n\n# CLI team scope\nvercel --scope my-team deploy --prod\n</code></pre>\n<p>Token types: Personal Access Token (vercel.com/account/tokens), OAuth (integrations), Scoped (limited-permission automation).</p>\n<h2>CLI Installation and Core Commands</h2>\n<pre><code class=\"language-bash\">npm i -g vercel\n\n# Deploy\nvercel deploy --prod\n\n# Link project\nvercel link\n\n# Environment variables\nvercel env pull .env.local        # Pull to local file\nvercel env add KEY production     # Add to production\nvercel env ls                     # List all\n\n# Logs\nvercel logs &#x3C;deployment-url>\nvercel logs --follow              # Stream live\n\n# Domains\nvercel domains add example.com\nvercel domains ls\n\n# Rollback\nvercel rollback &#x3C;deployment-url>\n\n# Project info\nvercel inspect &#x3C;deployment-url>\n</code></pre>\n<h2>REST API Endpoint Categories</h2>\n<p>| Category | Key Operations |\n|----------|----------------|\n| <strong>Projects</strong> (27 endpoints) | CRUD, domains, env vars, members, settings |\n| <strong>Deployments</strong> (10) | Create, get, list, cancel, delete |\n| <strong>Domains</strong> (6) | Add, remove, verify, transfer |\n| <strong>DNS</strong> (4) | List, add, update, remove records |\n| <strong>Environment</strong> (11) | Create, update, delete, list per target |\n| <strong>Aliases</strong> (6) | Set, remove, list custom domain aliases |\n| <strong>Teams</strong> (14) | Create, invite, manage members |\n| <strong>Logs</strong> (1) | Runtime log retrieval (streaming) |\n| <strong>Webhooks</strong> (4) | Create, list, get, delete |\n| <strong>Edge-Config</strong> (17) | Create, read, update, delete |\n| <strong>Checks</strong> (10) | Deployment checks for CI integration |</p>\n<h2>Common API Patterns</h2>\n<h3>List Deployments</h3>\n<pre><code class=\"language-bash\">curl -H \"Authorization: Bearer $VERCEL_TOKEN\" \\\n  \"https://api.vercel.com/v6/deployments?projectId=prj_xxx&#x26;limit=5\"\n</code></pre>\n<h3>Create Deployment via API</h3>\n<pre><code class=\"language-bash\">curl -X POST \\\n  -H \"Authorization: Bearer $VERCEL_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"my-app\",\"gitSource\":{\"type\":\"github\",\"repoId\":\"123\",\"ref\":\"main\"}}' \\\n  \"https://api.vercel.com/v13/deployments\"\n</code></pre>\n<h3>Set Environment Variable</h3>\n<pre><code class=\"language-bash\">curl -X POST \\\n  -H \"Authorization: Bearer $VERCEL_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"key\":\"DATABASE_URL\",\"value\":\"postgres://...\",\"target\":[\"production\"],\"type\":\"encrypted\"}' \\\n  \"https://api.vercel.com/v10/projects/prj_xxx/env\"\n</code></pre>\n<h3>Add DNS Record</h3>\n<pre><code class=\"language-bash\">curl -X POST \\\n  -H \"Authorization: Bearer $VERCEL_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"api\",\"type\":\"CNAME\",\"value\":\"target.example.com\"}' \\\n  \"https://api.vercel.com/v2/domains/example.com/records\"\n</code></pre>\n<h2>Environment Variable Targets</h2>\n<p>| Target | When Used |\n|--------|-----------|\n| <code>production</code> | <code>vercel deploy --prod</code> |\n| <code>preview</code> | Branch and PR deployments |\n| <code>development</code> | <code>vercel dev</code> local server |</p>\n<p>Always set sensitive keys in Vercel dashboard, not in <code>.env</code> files committed to git.</p>\n<h2>Deploy from GitHub Actions</h2>\n<pre><code class=\"language-yaml\">- name: Deploy to Vercel\n  env:\n    VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}\n    VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}\n    VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}\n  run: |\n    npm i -g vercel\n    vercel pull --yes --environment=production --token=$VERCEL_TOKEN\n    vercel build --prod --token=$VERCEL_TOKEN\n    vercel deploy --prebuilt --prod --token=$VERCEL_TOKEN\n</code></pre>\n<h2>Edge Config</h2>\n<p>Edge Config is a global key-value store with sub-millisecond reads at the edge. Use for feature flags and A/B config.</p>\n<pre><code class=\"language-bash\"># Create via API\ncurl -X POST -H \"Authorization: Bearer $VERCEL_TOKEN\" \\\n  -d '{\"slug\":\"my-flags\"}' \\\n  \"https://api.vercel.com/v1/edge-config\"\n\n# Read in code (Next.js)\nimport { get } from \"@vercel/edge-config\";\nconst isEnabled = await get(\"feature-x\");\n</code></pre>\n<h2>Webhooks</h2>\n<pre><code class=\"language-bash\">curl -X POST -H \"Authorization: Bearer $VERCEL_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"url\":\"https://api.example.com/webhook\",\"events\":[\"deployment.created\",\"deployment.ready\"]}' \\\n  \"https://api.vercel.com/v1/webhooks\"\n</code></pre>\n<p>Events: <code>deployment.created</code>, <code>deployment.ready</code>, <code>deployment.error</code>, <code>deployment.canceled</code>.</p>\n<h2>Project Settings via API</h2>\n<pre><code class=\"language-bash\"># Get project\ncurl -H \"Authorization: Bearer $VERCEL_TOKEN\" \\\n  \"https://api.vercel.com/v9/projects/prj_xxx\"\n\n# Update build command\ncurl -X PATCH -H \"Authorization: Bearer $VERCEL_TOKEN\" \\\n  -d '{\"buildCommand\":\"npm run build:prod\"}' \\\n  \"https://api.vercel.com/v9/projects/prj_xxx\"\n</code></pre>\n"}