vercel
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCall the Vercel REST API with . The user's token is in
; every call needs . Base URL: . If the resource is
team-scoped, append (set only when the user connected a
team token).
curl + jq$VERCEL_ACCESS_TOKENAuthorization: Bearer $VERCEL_ACCESS_TOKENhttps://api.vercel.com?teamId=$VERCEL_TEAM_IDErrors come back as — show verbatim.
usually means the token can't see that team/project →
re-connect with the right scope.
{"error":{"code","message"}}message403 forbiddenHelper for the optional team param:
bash
TEAM=""; [ -n "$VERCEL_TEAM_ID" ] && TEAM="?teamId=$VERCEL_TEAM_ID"
AUTH="Authorization: Bearer $VERCEL_ACCESS_TOKEN"使用调用Vercel REST API。用户的令牌存储在中;每次调用都需要携带请求头。基础URL:。如果资源属于团队范围,则追加(仅当用户关联了团队令牌时设置)。
curl + jq$VERCEL_ACCESS_TOKENAuthorization: Bearer $VERCEL_ACCESS_TOKENhttps://api.vercel.com?teamId=$VERCEL_TEAM_ID错误返回格式为——直接展示字段内容。通常表示令牌无权限访问该团队/项目→请使用正确权限范围重新关联令牌。
{"error":{"code","message"}}message403 forbidden团队参数辅助脚本:
bash
TEAM=""; [ -n "$VERCEL_TEAM_ID" ] && TEAM="?teamId=$VERCEL_TEAM_ID"
AUTH="Authorization: Bearer $VERCEL_ACCESS_TOKEN"Projects & deployments
项目与部署
bash
undefinedbash
undefinedProjects
查看项目
curl -sS -H "$AUTH" "https://api.vercel.com/v9/projects$TEAM"
| jq '.projects[] | {name, framework, latestProduction: .latestDeployments[0].url}'
| jq '.projects[] | {name, framework, latestProduction: .latestDeployments[0].url}'
curl -sS -H "$AUTH" "https://api.vercel.com/v9/projects$TEAM"
| jq '.projects[] | {name, framework, latestProduction: .latestDeployments[0].url}'
| jq '.projects[] | {name, framework, latestProduction: .latestDeployments[0].url}'
Recent deployments (optionally filter by ?projectId=… or &state=ERROR)
最近的部署(可通过?projectId=…或&state=ERROR进行筛选)
curl -sS -H "$AUTH" "https://api.vercel.com/v6/deployments${TEAM:-?}&limit=20"
| jq '.deployments[] | {uid, name, url, state, readyState, created}'
| jq '.deployments[] | {uid, name, url, state, readyState, created}'
undefinedcurl -sS -H "$AUTH" "https://api.vercel.com/v6/deployments${TEAM:-?}&limit=20"
| jq '.deployments[] | {uid, name, url, state, readyState, created}'
| jq '.deployments[] | {uid, name, url, state, readyState, created}'
undefinedDiagnose a failed build
诊断失败的构建
bash
undefinedbash
undefinedDeployment detail
部署详情
curl -sS -H "$AUTH" "https://api.vercel.com/v13/deployments/DEPLOYMENT_ID${TEAM:+&teamId=$VERCEL_TEAM_ID}"
| jq '{name, url, state: .readyState, error: .errorMessage}'
| jq '{name, url, state: .readyState, error: .errorMessage}'
curl -sS -H "$AUTH" "https://api.vercel.com/v13/deployments/DEPLOYMENT_ID${TEAM:+&teamId=$VERCEL_TEAM_ID}"
| jq '{name, url, state: .readyState, error: .errorMessage}'
| jq '{name, url, state: .readyState, error: .errorMessage}'
Build / runtime events (the actual logs)
构建/运行时事件(实际日志)
curl -sS -H "$AUTH" "https://api.vercel.com/v3/deployments/DEPLOYMENT_ID/events${TEAM:+?teamId=$VERCEL_TEAM_ID}"
| jq -r '.[] | select(.type=="stdout" or .type=="stderr") | .payload.text'
| jq -r '.[] | select(.type=="stdout" or .type=="stderr") | .payload.text'
undefinedcurl -sS -H "$AUTH" "https://api.vercel.com/v3/deployments/DEPLOYMENT_ID/events${TEAM:+?teamId=$VERCEL_TEAM_ID}"
| jq -r '.[] | select(.type=="stdout" or .type=="stderr") | .payload.text'
| jq -r '.[] | select(.type=="stdout" or .type=="stderr") | .payload.text'
undefinedDomains & redeploy
域名与重新部署
bash
undefinedbash
undefinedProject domains
项目域名
curl -sS -H "$AUTH" "https://api.vercel.com/v9/projects/PROJECT_ID/domains${TEAM:+?teamId=$VERCEL_TEAM_ID}"
| jq '.domains[] | {name, verified}'
| jq '.domains[] | {name, verified}'
To **redeploy**, POST to `https://api.vercel.com/v13/deployments` with a
`deploymentId` (or git source) body — **confirm with the user first**, it ships
to production.curl -sS -H "$AUTH" "https://api.vercel.com/v9/projects/PROJECT_ID/domains${TEAM:+?teamId=$VERCEL_TEAM_ID}"
| jq '.domains[] | {name, verified}'
| jq '.domains[] | {name, verified}'
要**重新部署**,请向`https://api.vercel.com/v13/deployments`发送POST请求,请求体携带`deploymentId`(或Git源)——**请先与用户确认**,因为这会部署到生产环境。Gotchas
注意事项
- Never print env-var values. Listing project env vars returns metadata;
the decrypt route returns secrets — don't call it unless the user explicitly asks, and even then summarize, don't echo.
/v1/.../env/{id} - Deployment /
state:readyState.QUEUED → BUILDING → READY | ERROR | CANCELED - /
createdare epoch ms — divide by 1000 for human time.ready
- 切勿打印环境变量值。列出项目环境变量仅返回元数据;解密接口会返回敏感信息——除非用户明确要求,否则不要调用该接口,即使调用也仅需汇总信息,不要直接输出内容。
/v1/.../env/{id} - 部署的/
state状态流程:readyState。QUEUED → BUILDING → READY | ERROR | CANCELED - /
created字段为毫秒级时间戳——除以1000即可转换为人类可读时间。ready