API 参考
通过 AutoManus REST API 以编程方式创建 AI 销售代理。
基础 URL
https://automanus.io/api/v1/publicPOST
/agents
根据网站 URL 或结构化的代码库上下文创建一个新的 AI 销售代理。
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| string | 是 | 拥有该代理的账户的电子邮件地址。 | |
| company_name | string | 是 | 代理所代表的公司名称。 |
| website_url | string | 否 | 用于抓取知识的网站。使用此项或 codebase_context。 |
| codebase_context | object | 否 | 结构化的产品与公司信息。使用此项或 website_url。 |
| agent_name | string | 否 | 代理的自定义名称。默认使用自动生成的名称。 |
| source | string | 否 | 请求的来源,例如 cursor 或 claude_code。 |
示例:网站模式
curl -X POST https://automanus.io/api/v1/public/agents \
-H "Content-Type: application/json" \
-d '{
"email": "founder@startup.com",
"company_name": "TechStartup",
"website_url": "https://techstartup.com",
"source": "cursor"
}'示例:代码库模式
当没有可抓取的公开网站时,直接传入结构化上下文。
curl -X POST https://automanus.io/api/v1/public/agents \
-H "Content-Type: application/json" \
-d '{
"email": "dev@startup.com",
"company_name": "TechStartup",
"codebase_context": {
"company_description": "AI-powered platform for workflow automation",
"value_proposition": "10x your productivity with AI",
"products": [
{
"name": "Pro Plan",
"description": "Full access to all AI features",
"price": "$99/month"
}
]
},
"source": "claude_code"
}'响应
{
"success": true,
"agent_id": "uuid-here",
"agent_name": "TechStartup Assistant",
"company_name": "TechStartup",
"webchat_embed_code": "<script src=\"https://automanus.io/widget/automanus-chat.js\" data-widget-key=\"wc_abc123\"></script>",
"webchat_widget_key": "wc_abc123",
"whatsapp_link": "https://wa.me/16506053956?text=Hi!%20I'd%20like%20to%20talk%20to%20TechStartup",
"is_new_user": true,
"claim_url": "https://automanus.io/login?invite=token-here",
"dashboard_url": "https://automanus.io/dashboard/ai-agent",
"trial_info": {
"expires_in_days": null,
"message_limit": 100
},
"knowledge_base_count": 5
}响应字段
| 字段 | 说明 |
|---|---|
| webchat_embed_code | 可直接粘贴的脚本标签,用于在你的网站上加载聊天小部件。 |
| whatsapp_link | 点击即可聊天的 WhatsApp 链接,已预填问候语。 |
| claim_url | 用户打开以认领并管理新代理的链接。 |
| trial_info.message_limit | 试用期内允许的消息数量。 |
| knowledge_base_count | 为该代理创建的知识库条目数量。 |
身份验证
有两种方式对请求进行身份验证。
基于电子邮件(默认)
提供电子邮件和公司名称。系统会创建一个演示代理并返回认领链接。
{
"email": "you@company.com",
"company_name": "Acme Corp"
}API 密钥(现有用户)
包含 Authorization 标头。代理将在你的账户下创建。在 automanus.io/dashboard/settings/api 生成密钥。
curl -X POST https://automanus.io/api/v1/public/agents \
-H "Authorization: Bearer ak_your_api_key" \
-H "Content-Type: application/json" \
-d '{"company_name": "Acme Corp", "website_url": "https://acme.com"}'POST
/knowledge
向现有代理添加一个知识库条目。内容会被嵌入以便检索。
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| agent_id | string | 是 | 要添加知识的代理 ID。 |
| title | string | 是 | 知识条目的简短标题。 |
| content | string | 是 | 要存储并嵌入的文本内容。 |
| item_type | string | 否 | faq, product, policy, or document |
| category | string | 否 | 可选的分类标签,用于整理条目。 |
示例
curl -X POST https://automanus.io/api/v1/public/knowledge \
-H "Authorization: Bearer ak_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"agent_id": "uuid-from-create-agent",
"title": "Pricing FAQ",
"content": "Our Pro plan starts at $99/month with unlimited users.",
"item_type": "faq",
"category": "Pricing"
}'响应
{
"success": true,
"knowledge_item_id": "uuid-here",
"agent_id": "uuid-here",
"agent_name": "Company Assistant",
"embedding_generated": true
}身份验证:需要 API 密钥。该代理必须属于你的账户。对于通过电子邮件流程创建的演示代理,无需身份验证。
速率限制
| 限制项 | 数值 |
|---|---|
| 每个电子邮件每天可创建的代理数 | 10 |
| 每分钟请求数 | 60 |
错误代码
| 状态码 | 错误 | 说明 |
|---|---|---|
| 400 | email and company_name are required | 缺少必填字段。 |
| 400 | Invalid email format | 电子邮件格式无效。 |
| 401 | Invalid API key | API 密钥缺失或无效。 |
| 409 | An agent already exists for this website | 该网站已存在一个代理。 |
| 429 | Rate limit exceeded | 请求过多。你已达到速率限制。 |
集成示例
使用一个小型 React 组件将网页聊天小部件添加到你的网站。
// React component
import { useEffect } from 'react';
export function SalesChat({ widgetKey }) {
useEffect(() => {
const script = document.createElement('script');
script.src = 'https://automanus.io/widget/automanus-chat.js';
script.setAttribute('data-widget-key', widgetKey);
script.async = true;
document.body.appendChild(script);
return () => document.body.removeChild(script);
}, [widgetKey]);
return null;
}