This guide documents the API commands used to optimize Vercel credit consumption by disabling automatic deployments and enabling smart build skipping.
The Vercel CLI stores your auth token at:
cat "/Users/$(whoami)/Library/Application Support/com.vercel.cli/auth.json"Extract the token value from the JSON output.
# List all projects to find the one you want
vercel project ls
# Get project details including ID
vercel project inspect <project-name>The project ID format is prj_... and team ID is team_...
You can also get these from the .vercel/project.json file if the project is linked:
cat .vercel/project.jsonSet these variables for the commands below:
VERCEL_TOKEN="<your-token-from-auth.json>"
PROJECT_ID="<your-project-id>"
TEAM_ID="<your-team-id>"This prevents Vercel from automatically deploying on every git push or PR:
curl -s -X PATCH "https://api.vercel.com/v9/projects/${PROJECT_ID}?teamId=${TEAM_ID}" \
-H "Authorization: Bearer ${VERCEL_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"gitProviderOptions": {
"createDeployments": "disabled"
}
}'Options for createDeployments:
"enabled"- Deploy on every push (default)"disabled"- Never auto-deploy (manual only)
Skip deployments when no relevant files changed (useful for monorepos):
curl -s -X PATCH "https://api.vercel.com/v9/projects/${PROJECT_ID}?teamId=${TEAM_ID}" \
-H "Authorization: Bearer ${VERCEL_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"enableAffectedProjectsDeployments": true
}'Add a script that determines whether to build based on changed files:
curl -s -X PATCH "https://api.vercel.com/v9/projects/${PROJECT_ID}?teamId=${TEAM_ID}" \
-H "Authorization: Bearer ${VERCEL_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"commandForIgnoringBuildStep": "bash scripts/vercel-ignore-build.sh"
}'Apply all optimizations at once:
curl -s -X PATCH "https://api.vercel.com/v9/projects/${PROJECT_ID}?teamId=${TEAM_ID}" \
-H "Authorization: Bearer ${VERCEL_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"gitProviderOptions": {
"createDeployments": "disabled"
},
"enableAffectedProjectsDeployments": true,
"commandForIgnoringBuildStep": "bash scripts/vercel-ignore-build.sh"
}'Check current project settings:
curl -s -X GET "https://api.vercel.com/v9/projects/${PROJECT_ID}?teamId=${TEAM_ID}" \
-H "Authorization: Bearer ${VERCEL_TOKEN}" \
-H "Content-Type: application/json" | jq '{
name: .name,
gitProviderOptions: .gitProviderOptions,
enableAffectedProjectsDeployments: .enableAffectedProjectsDeployments,
commandForIgnoringBuildStep: .commandForIgnoringBuildStep
}'Create scripts/vercel-ignore-build.sh in your project:
#!/bin/bash
# Vercel Ignored Build Step
# https://vercel.com/docs/project-configuration/vercel-json#ignorecommand
#
# Exit 0 = SKIP build (no relevant changes)
# Exit 1 = PROCEED with build (relevant changes detected)
set -e
echo "Checking if relevant files changed..."
PREV_SHA="${VERCEL_GIT_PREVIOUS_SHA:-HEAD~1}"
CURR_SHA="${VERCEL_GIT_COMMIT_SHA:-HEAD}"
# Paths that should trigger a rebuild (adjust for your project)
TRIGGER_PATHS=(
"apps/web/" # Your app directory
"package.json" # Root package.json
"bun.lock" # Lockfile
)
for path in "${TRIGGER_PATHS[@]}"; do
if git diff --name-only "$PREV_SHA" "$CURR_SHA" 2>/dev/null | grep -q "^${path}"; then
echo "Changes detected in: $path"
exit 1 # Build
fi
done
echo "No relevant changes - skipping build"
exit 0 # SkipAlso add to vercel.json:
{
"ignoreCommand": "bash scripts/vercel-ignore-build.sh"
}With automatic deployments disabled, deploy manually:
# Production deployment
vercel --prod
# Preview deployment
vercel| Setting | API Field | Value | Effect |
|---|---|---|---|
| Disable auto-deploy | gitProviderOptions.createDeployments |
"disabled" |
No deploys on push/PR |
| Smart skip | enableAffectedProjectsDeployments |
true |
Skip unchanged projects |
| Custom check | commandForIgnoringBuildStep |
"bash ..." |
Run script to decide |
If you want to re-enable automatic deployments:
curl -s -X PATCH "https://api.vercel.com/v9/projects/${PROJECT_ID}?teamId=${TEAM_ID}" \
-H "Authorization: Bearer ${VERCEL_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"gitProviderOptions": {
"createDeployments": "enabled"
}
}'