百人公司
⌘ 开发者 API · REST + Webhook

用一个请求,把 100 人 AI 团队装进你的产品

POST 一句话需求,百人公司的 AI 团队自动接力 —— 参谋长拆解、跨部门协作、主编汇总,产出一份可直接执行的方案。 任务在后台跑完后,带签名的 webhook 回调你,也可主动轮询。

1

鉴权

个人中心 · 开发者 生成密钥(形如 opc_live_…),放进每个请求的请求头。明文密钥只在生成时展示一次。

Authorization: Bearer opc_live_你的密钥
2

创建任务 · POST /api/v1/tasks

请求体:brief(必填,4–8000 字的一句话需求)、webhookUrl(可选,必须是 https,任务完成后回调)。

curl -X POST https://opcagent.site/api/v1/tasks \
  -H "Authorization: Bearer opc_live_你的密钥" \
  -H "Content-Type: application/json" \
  -d '{
    "brief": "帮我写一条小红书种草文案,产品是手冲咖啡壶",
    "webhookUrl": "https://你的域名/hook"
  }'

立即返回 202,任务在后台执行:

HTTP/1.1 202 Accepted
{
  "success": true,
  "data": {
    "taskId": "8f3a…",
    "status": "planning",
    "statusUrl": "https://opcagent.site/api/v1/tasks/8f3a…",
    "webhook": { "configured": true, "status": "pending" },
    "quotaRemaining": 9
  }
}
3

查询结果 · GET /api/v1/tasks/{id}

用同样的 Bearer 鉴权轮询 statusUrl。当 status 变为 donefinalOutput 就是方案 markdown。

{
  "success": true,
  "data": {
    "id": "8f3a…",
    "status": "done",
    "brief": "帮我写一条小红书种草文案…",
    "flow": "general",
    "plan": { "summary": "…", "steps": [ … ] },
    "finalOutput": "# 小红书种草文案\n\n## 标题\n…",
    "createdAt": "2026-06-09T03:00:00.000Z",
    "updatedAt": "2026-06-09T03:02:30.000Z",
    "webhook": { "configured": true, "status": "delivered", "attempts": 1 }
  }
}
4

Webhook 回调(推荐)

配置了 webhookUrl 后,任务结束(task.completed task.failed)会 POST 到你的地址,失败自动重试 3 次。

POST https://你的域名/hook
Headers:
  X-OPC-Event: task.completed
  X-OPC-Signature: sha256=<hmac>

{
  "event": "task.completed",
  "taskId": "8f3a…",
  "status": "done",
  "brief": "帮我写一条小红书种草文案…",
  "flow": "general",
  "finalOutput": "# 小红书种草文案\n\n…",
  "error": null,
  "createdAt": "2026-06-09T03:00:00.000Z",
  "completedAt": "2026-06-09T03:02:30.000Z"
}

用你那把密钥的「Webhook 签名密钥」(whsec_…)校验 X-OPC-Signature,确认回调来自百人公司:

import crypto from "node:crypto";

// Express 示例:用你的 Webhook 签名密钥校验回调真伪
app.post("/hook", express.raw({ type: "application/json" }), (req, res) => {
  const sig = req.headers["x-opc-signature"];
  const expected =
    "sha256=" +
    crypto.createHmac("sha256", process.env.OPC_WEBHOOK_SECRET)
      .update(req.body) // 原始 body buffer
      .digest("hex");
  if (sig !== expected) return res.status(401).end();

  const event = JSON.parse(req.body.toString());
  // event.status === "done" → event.finalOutput 就是方案 markdown
  res.json({ ok: true });
});
5

状态机 & 错误码

任务状态
  • planning · 参谋长规划中
  • running · AI 团队执行中
  • done · 完成,有 finalOutput
  • failed · 失败,见 error 字段
HTTP 错误码
  • 401 · 密钥无效 / 缺失
  • 402 · 配额已用完
  • 400 · 参数错误
  • 404 · 任务不存在 / 无权访问

配额说明:API 调用与网页端共用同一份任务配额(免费每月 10 次 + 邀请奖励 + 已购套餐)。配额不足时返回 402 + code: QUOTA_EXHAUSTED

几行代码,给你的产品装上一支 AI 团队

免费起步,按任务计费。生成密钥即可调用,无需对接销售。

生成 API 密钥 →