Vercel Manager
Manage Vercel projects and deployments using the Vercel REST API with single-file Python scripts.
Setup
Create a .env file at your project root with your Vercel token:
VERCEL_TOKEN=your_token_here
Get a token from Vercel Dashboard > Account Settings > Tokens.
Available Operations
List Projects
List all Vercel projects for your account or team:
./scripts/list_projects.py
Output format:
{
"projects": [
{
"id": "prj_abc123",
"name": "my-project",
"framework": "nextjs",
"createdAt": 1705312200000,
"updatedAt": 1705312200000
}
]
}
Create Project
Create a new Vercel project with optional GitHub integration, environment variables, framework, and build command overrides:
echo '<json>' | ./scripts/create_project.py
Input JSON format:
{
"name": "my-project",
"framework": "nextjs",
"buildCommand": "npx convex deploy --cmd 'npm run build'",
"installCommand": "npm install",
"outputDirectory": ".next",
"gitRepository": {
"repo": "owner/repo-name",
"type": "github"
},
"envVars": [
{
"key": "DATABASE_URL",
"value": "postgresql://...",
"type": "encrypted",
"target": ["production", "preview"]
}
]
}
Fields:
name(required): Project nameframework(optional):nextjs,vite,remix,nuxtjs,gatsby,astro, etc.buildCommand(optional): Override the build commandinstallCommand(optional): Override the install commandoutputDirectory(optional): Override the output directorygitRepository(optional): Link to a GitHub/GitLab/Bitbucket reporepo:owner/repo-nameformattype:github,gitlab, orbitbucket
envVars(optional): Array of environment variableskey: Variable namevalue: Variable valuetype:encryptedorplaintarget: Array ofproduction,preview,development
Examples:
Simple project:
echo '{"name": "my-app"}' | ./scripts/create_project.py
Next.js with Convex:
echo '{
"name": "my-convex-app",
"framework": "nextjs",
"buildCommand": "npx convex deploy --cmd '''npm run build'''",
"gitRepository": {
"repo": "myorg/my-convex-app",
"type": "github"
},
"envVars": [
{"key": "CONVEX_DEPLOY_KEY", "value": "prod:xxx", "type": "encrypted", "target": ["production"]}
]
}' | ./scripts/create_project.py
Deploy to Production
Deploy a project to Vercel production:
./scripts/deploy.py <project_directory>
Arguments:
project_directory: Path to the project to deploy (required)
Example:
./scripts/deploy.py ./my-app
Output format:
{
"status": "success",
"projectDirectory": "/path/to/my-app",
"deploymentUrl": "https://my-app.vercel.app"
}
This script:
- Reads VERCEL_TOKEN from the .env file
- Runs
bunx vercel deploy --prod --yeswith the token - Returns the deployment URL on success
Error Handling
Missing .env file:
Error: .env file not found in current directory or parent directories
Create a .env file at the project root with your VERCEL_TOKEN.
Missing token in .env:
Error: VERCEL_TOKEN not found in .env file
Add VERCEL_TOKEN=your_token to your .env file.
Invalid token:
Error: Unauthorized - verify your token is correct
Get a new token from the Vercel Dashboard under Account Settings > Tokens.
Project already exists:
Error: Project with this name already exists
Choose a different project name.