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

# 创建代理任务

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

## Request

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

> **Deprecated.**

已废弃：请改用[使用 webhook 触发器的自定义自动化](/zh/api/automations/webhook)。创建一个在后台运行的新代理作业。该作业会异步处理提示词。轮询 get job 端点以跟踪进度。如果代理成功编辑文件，则会自动创建拉取请求（PR；亦称“合并请求”/Merge Request）。

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

## Path parameters

- `projectId` string, required

## Request body

- object
  - `prompt` string, required: 供代理执行的指令。

## Response `201`

代理作业创建成功

- AgentJob
  - `id` string: 代理任务的唯一标识符。
  - `status` 'active' | 'completed' | 'archived' | 'failed': 作业的当前状态。`active`——代理当前正在处理提示词。`completed`——代理已成功完成，并且可能已创建 PR（请检查 `prLink`）。`archived`——作业已归档。`failed`——代理遇到了不可恢复的错误。请持续轮询，直到状态变为 `completed`、`archived` 或 `failed`。
  - `source` object: 源存储库信息。
    - `repository` string: GitHub 存储库的完整 URL。
    - `ref` string, nullable: 代理正在处理的 Git branch。
  - `model` string: 此作业使用的 AI 模型。
  - `prLink` string, uri, nullable: 由代理创建的 GitHub 拉取请求（PR；亦称“合并请求”/Merge Request）URL。作业仍处于 `active` 状态或没有文件变更时，该值为 `null`。代理成功创建 PR 后，此字段会被填充。
  - `createdAt` string, date-time: 作业创建时的时间戳。
  - `archivedAt` string, date-time, nullable: 作业归档时的时间戳。

## Other responses

- `400`: 请求无效。缺少 `prompt` 或其为空、项目的主要 Git 来源不是 GitHub、项目未配置 GitHub 应用，或项目 ID 格式无效。
- `401`: API 密钥缺失或无效，或者你的套餐不包含 API 访问权限或代理功能。
- `403`: 你的 API 密钥没有写入权限，或者你的请求来自不在 API 密钥允许列表中的 IP 地址。
- `404`: 项目不存在或不属于你的组织。
- `429`: 你已超出每个组织每小时 100 次请求的速率限制，或者你的组织在过去一小时内创建了超过 20 个代理任务。
- `500`: 发生了意外的服务器错误。请重试该请求。如果错误仍然存在，请联系支持团队。

## Changes

> 25 revisions in range; 2 not diffed.

- **2026-11-10** `9cea627f345c`: 1 info
  - endpoint deprecated
- **2026-10-30** `8f632fe27713`: 4 info
  - 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`
  - added the non-success response with the status `500`
- **2026-03-12** `b4e58059b285`: 1 warning
  - added the new `archived` enum value to the `status` response property for the response status `201`

[Operation history](https://skmtc.dev/mintlify/apis/mintlify-admin-api/zh/changes/v2/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)
