---
title: "触发预览部署"
method: POST
path: "/project/preview/{projectId}"
language: "zh-Hans"
---

# 触发预览部署

`POST /project/preview/{projectId}`

## Request

- Base URL: `https://api.mintlify.com/v1`
- URL: `https://api.mintlify.com/v1/project/preview/{projectId}`
- Auth: HTTP bearer

为特定分支创建或更新预览部署。如果该分支已有预览，则会触发重新部署。返回用于跟踪进度的状态 ID 和预览 URL。

使用管理员 API 密钥进行身份验证。

## Path parameters

- `projectId` string, required

## Request body

- object
  - `branch` string, required: 要为其创建预览部署的 Git 分支名称。
  - `auth` union: 要应用于预览的访问限制。省略此项可保持预览当前的访问设置不变。需要包含预览身份验证的方案，并且你的站点必须已启用身份验证或预览身份验证。
    - object
      - `type` 'password', required: 为预览设置密码保护。任何拥有密码的人都可以查看。
      - `password` string, required: 审阅者查看预览时输入的密码。长度必须至少为 8 个字符。会替换该预览上已有的任何密码。
    - object
      - `type` 'mintlify', required: 将预览限制为已登录 Mintlify 的组织成员访问。

## Response `202`

预览部署已成功加入队列。

- object
  - `statusId` string: 用于跟踪预览部署的状态 ID。可将其与 [Get deployment status](/zh/api/update/status) 端点配合使用。
  - `previewUrl` string: 预览部署所托管的 URL。

## Other responses

- `400`: 请求体无效。`branch` 字段为必填项，且 `auth` 必须符合受支持的格式之一。
- `401`: API 密钥缺失或无效，或者你的方案不包含 API 访问权限。
- `403`: 你当前的方案不支持预览部署、提供了 `auth` 但你当前的方案不支持预览部署身份验证、你的 API 密钥没有写入权限，或者你的请求来自不在 API 密钥允许列表中的 IP 地址。
- `404`: 该项目不存在或不属于你的组织。
- `409`: 提供了 `auth`，但未启用身份验证。在设置预览身份验证之前，请为你的项目启用身份验证或预览身份验证，并确保已在该预览上启用身份验证。
- `429`: 你已超出速率限制：每个组织每分钟 5 个请求。
- `500`: Mintlify 未能更新预览的身份验证设置。

## Changes

- **2026-10-30** `bf07d949aec9`: 3 info
  - added the non-success response with the status `401`
  - added the non-success response with the status `404`
  - added the non-success response with the status `429`
- **2026-10-16** `892da3c8f6be`: 3 info
  - added the new optional request property `auth`
  - added the non-success response with the status `409`
  - added the non-success response with the status `500`
- **2026-04-21** `89833a142190`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/mintlify/apis/mintlify-external-api/zh/changes/project/preview/:projectId/post.md)

---

[API](https://skmtc.dev/mintlify/apis/mintlify-external-api/zh.md) - [All operations](https://skmtc.dev/mintlify/apis/mintlify-external-api/zh/llms.txt) - [OpenAPI document](https://skmtc.dev/mintlify/apis/mintlify-external-api/zh/revisions/e670268dd03a?raw)
