> ## Documentation Index
> Fetch the complete documentation index at: https://smartac-justin-client-exports.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 触发预览部署

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

使用此端点以编程方式为 Git 分支创建或更新预览部署。如果指定分支已存在预览，该端点将触发重新部署，而不会创建重复项。

响应中包含一个 `statusId`，你可以将其传递给 [Get deployment status](/zh/api/update/status) 以跟踪部署进度。

<div id="use-cases">
  ## 用例
</div>

* **CI/CD 流水线**：在拉取请求被打开或更新时自动创建预览部署。
* **定时预览**：按计划为长期运行的功能分支生成预览。
* **自定义工具**：将预览创建集成到内部工作流或 Slack 机器人中。

<div id="rate-limits">
  ## 速率限制
</div>

此端点允许每个组织每分钟最多 5 个请求。


## OpenAPI

````yaml zh/openapi.json POST /project/preview/{projectId}
openapi: 3.0.1
info:
  title: Mintlify External API
  description: 用于管理 Mintlify 文档并访问各类资源的 API。
  version: 1.0.0
servers:
  - url: https://api.mintlify.com/v1
security:
  - bearerAuth: []
paths:
  /project/preview/{projectId}:
    post:
      summary: 触发预览部署
      description: 为特定分支创建或更新预览部署。如果该分支已有预览，则会触发重新部署。返回用于跟踪进度的状态 ID 和预览 URL。
      parameters:
        - name: projectId
          in: path
          description: >-
            项目 ID。可在控制台的 [API
            keys](https://dashboard.mintlify.com/settings/organization/api-keys)
            页面中复制。
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - branch
              properties:
                branch:
                  type: string
                  description: 要为其创建预览部署的 Git 分支名称。
                  minLength: 1
      responses:
        '202':
          description: 预览部署已成功加入队列。
          content:
            application/json:
              schema:
                type: object
                properties:
                  statusId:
                    type: string
                    description: >-
                      用于跟踪预览部署的状态 ID。可将其与 [Get deployment
                      status](/zh/api/update/status) 端点配合使用。
                  previewUrl:
                    type: string
                    description: 预览部署所托管的 URL。
        '400':
          description: 无效请求。`branch` 字段为必填项。
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        '403':
          description: 你当前的方案不支持预览部署。
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Authorization 请求头需要使用 Bearer token。请使用以 `mint_` 为前缀的管理员 API key。该 key
        是仅供服务端使用的机密密钥。你可以在控制台的 [API keys
        页面](https://dashboard.mintlify.com/settings/organization/api-keys)
        中生成一个。

````