---
title: "创建代理任务（v1）"
method: POST
path: "/v1/agent/{projectId}/job"
deprecated: true
language: "zh-Hans"
---

# 创建代理任务（v1）

`POST /v1/agent/{projectId}/job`

## Request

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

> **Deprecated.**

已废弃：请改用[使用 webhook 触发器的自定义自动化](/zh/api/automations/webhook)。此操作会创建一个新的代理任务，该任务可根据提供的消息和 Git branch 信息生成并编辑文档。

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

## Path parameters

- `projectId` string, required

## Request body

- object
  - `branch` string: 代理应处理的 Git branch 名称。如省略，代理会根据消息内容生成一个 branch 名称。
  - `messages` object[], required: 提供给代理的消息列表。系统始终会自动在前面添加一条默认的系统提示，因此通常只需包含用户消息。
    - `role` 'system' | 'user' | 'assistant', required: 消息发送者的角色。对于任务说明，请使用 `user`。使用 `system` 添加补充说明，这些说明会附加在默认系统提示之后（不会替换默认系统提示）。使用 `assistant` 提供用于少样本提示的 AI 助手示例回复。
    - `content` string, required: 消息的 content。
  - `asDraft` boolean: 控制拉取请求（PR；亦称“合并请求”/Merge Request）是以草稿模式还是非草稿模式创建。为 true 时，会创建草稿拉取请求（PR；亦称“合并请求”/Merge Request）。为 false 时（默认），会创建可供评审的常规拉取请求（PR；亦称“合并请求”/Merge Request）。
  - `model` 'sonnet' | 'opus': 用于代理任务的 AI 模型。使用 `sonnet` 可获得更快、更具成本效益的处理。使用 `opus` 可获得能力更强但速度较慢的处理。

## Response `200`

代理任务创建成功。返回 Server-Sent Events 流式响应。

## Other responses

- `400`: 请求体无效，或项目 ID 格式无效。响应体会说明具体错误。
- `401`: API 密钥缺失或无效，或者你的套餐不包含 API 访问权限或代理功能。
- `403`: 你所在的地区无法使用 AI 功能、你的 API 密钥没有写入权限，或者你的请求来自不在 API 密钥允许列表中的 IP 地址。
- `404`: 项目不存在或不属于你的组织。
- `429`: 你已超出每个组织每小时 100 次请求的速率限制。

## Changes

> 25 revisions in range; 2 not diffed.

- **2026-10-30** `8f632fe27713`: 5 info
  - added the non-success response with the status `400`
  - added the non-success response with the status `401`
  - added the non-success response with the status `403`
  - added the non-success response with the status `404`
  - …1 more
- **2026-03-23** `fdf9f166a0f5`: 1 breaking, 1 warning, 1 info
  - removed the media type `text/plain` for the response with the status `200`
  - the optional response header `X-Message-Id` removed for the status `200`
  - added the media type `text/event-stream` for the response with the status `200`

[Operation history](https://skmtc.dev/mintlify/apis/mintlify-admin-api/zh/changes/v1/agent/:projectId/job/post.md)

---

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