API 参考

通过 AutoManus REST API 以编程方式创建 AI 销售代理。

基础 URL

https://automanus.io/api/v1/public
POST

/agents

根据网站 URL 或结构化的代码库上下文创建一个新的 AI 销售代理。

请求体

字段类型必填说明
emailstring拥有该代理的账户的电子邮件地址。
company_namestring代理所代表的公司名称。
website_urlstring用于抓取知识的网站。使用此项或 codebase_context。
codebase_contextobject结构化的产品与公司信息。使用此项或 website_url。
agent_namestring代理的自定义名称。默认使用自动生成的名称。
sourcestring请求的来源,例如 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_idstring要添加知识的代理 ID。
titlestring知识条目的简短标题。
contentstring要存储并嵌入的文本内容。
item_typestringfaq, product, policy, or document
categorystring可选的分类标签,用于整理条目。

示例

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

错误代码

状态码错误说明
400email and company_name are required缺少必填字段。
400Invalid email format电子邮件格式无效。
401Invalid API keyAPI 密钥缺失或无效。
409An agent already exists for this website该网站已存在一个代理。
429Rate 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;
}