终极开发者 API 指南
经过审查的服务器到服务器 API,用于构建安全的 Chirps 集成。控制台账单与 OAuth 流程、公共小组件回调、提供商 Webhook、Cron 任务和内部路由均有意排除。
1. 认证及核心原则
基本 URL: https://chirps.cc
所有 API 端点都需要“授权”标头中的 Chirps API 密钥。您可以从仪表板的开发人员部分 中的 API 管理器生成 API 密钥。
Authorization: Bearer <YOUR_CHIRPS_API_KEY>请求示例:
curl -X GET https://chirps.cc/api/billing/usage \
-H "Authorization: Bearer <YOUR_CHIRPS_API_KEY>" \
-H "Content-Type: application/json"标准错误处理
| 状态码 | 描述 |
|---|---|
200 OK | 请求成功。 |
400 Bad Request | JSON 负载验证失败。包括一个详细信息数组。 |
401 Unauthorized | 令牌丢失或过期。 |
402 Payment Required | 工作区已达到计费限制。 |
| 《403 禁止》 | 用户没有所需的 RBAC 权限。 |
404 Not Found | 请求的资源不存在。 |
500 Server Error | 意外的平台错误。 |
409 Conflict | The request conflicts with current state, such as a booking slot that is no longer available. |
413 Payload Too Large | The request exceeds the endpoint's documented size limit. |
429 Too Many Requests | The API-key request limit was reached; retry after the current window resets. |
503 Service Unavailable | A required safety or rate-limit dependency is unavailable. Retry with backoff; the request is rejected rather than processed without protection. |
作用域与最小权限
每个密钥仅限于所选作用域。尽可能使用只读密钥,并为每个集成创建单独的密钥。写入作用域不会自动授予对应的读取作用域。
assistants:read
assistants:write
analytics:read
artifacts:read
artifacts:write
billing:read
bookings:read
bookings:write
chat:write
connectors:read
connectors:write
conversations:read
conversations:write
knowledge:read
knowledge:write
leads:read
leads:write
telephony:read
telephony:write
widget:writeAPI-key rate limit
Each developer key is limited to 300 requests per rolling minute by default. The limit is atomic across all application instances and can be changed by the platform with API_KEY_RATE_LIMIT_PER_MINUTE. A rejected request returns 429; retry only after the window resets.
2. 助理生命周期(创建)
GET /api/assistants
列出助理
获取与 API 密钥工作区关联的所有助手的列表。
创建助理
POST /api/assistants
创建具有所有基本配置的新助手。
{
"businessName": "Acme Corp",
"businessUrl": "https://acme.com",
"knowledgeBaseType": "both",
"knowledgeBaseUrl": "https://acme.com/help",
"knowledgeBaseText": "Raw text content of a document...",
"knowledgeBaseFileName": "company_handbook.pdf",
"language": "en",
"isMultiLanguage": false,
"tonePersonality": "professional",
"isCustomPersonality": false,
"supportEmail": "[email protected]",
"maxPages": 5,
"maxDepth": 2,
"welcomeMessageDelay": 2
}| 范围 | 类型 | 必需的 | 描述 |
|---|---|---|---|
businessName | 细绳 | 是的 | 公司名称(2-100 个字符)。 |
businessUrl | 细绳 | 是的 | 企业网站的有效 URL(最多 500 个字符)。 |
knowledgeBaseType | 枚举 | 是的 | 以下之一:“url”、“文档”、“两者”、“无”。 |
knowledgeBaseUrl | 细绳 | 不 | 如果类型是“url”或“both”,则必须提供。 |
knowledgeBaseText | 细绳 | 不 | 如果类型为“文档”或“两者”,则为原始文本。 |
knowledgeBaseFileName | 细绳 | 不 | 如果提供文本,则为上传文件的名称。 |
language | 细绳 | 是的 | 语言代码(例如“en”、“es”)。 |
isMultiLanguage | 布尔值 | 不 | 启用自动翻译。默认为“假”。 |
tonePersonality | 细绳 | 是的 | 例如,“专业”、“友好”。最多 100 个字符。 |
isCustomPersonality | 布尔值 | 不 | 启用自定义音调。默认为“假”。 |
customPersonalityDescription | 细绳 | 不 | 自定义提示音说明(如果启用)(最多 2000 个字符)。 |
additionalInstructions | 细绳 | 不 | 核心提示说明(最多 10000 个字符)。 |
supportEmail | 细绳 | 是的 | 用于升级的有效电子邮件地址。 |
maxPages | 数字 | 不 | 要抓取的页面。最小值 1,最大值 100。默认为“5”。 |
maxDepth | 数字 | 不 | 爬行深度。最小值 1,最大值 20。默认为“2”。 |
welcomeMessageDelay | 数字 | 不 | 问候前延迟几秒。最小值 0,最大值 6。默认为“2”。 |
删除助手
DELETE /api/assistants/:id
永久删除助手并级联删除其所有知识节点和历史记录。无需有效负载。
Creation validation and quota safety
| Input | Contract |
|---|---|
knowledgeBaseUrl | For url or both: 1–20 comma-separated public HTTP(S) URLs, with at most 2,000 characters in total. |
knowledgeBaseText | Required for document or both; maximum 2,000,000 characters. |
knowledgeBaseFileName | Optional source label; maximum 255 characters. |
maxPages / maxDepth | Requested values are bounded by both the documented hard limits and the workspace plan. |
Creation allowance is reserved atomically before insertion, so concurrent requests cannot exceed the monthly quota. Database insertion failures refund that reservation. A created assistant starts inactive in developer mode; call the setup endpoint and wait for its successful terminal event before publishing it.
3. 助理分析与统计
创建和使用后,您可以立即以编程方式获取助手的性能指标。
GET /api/analytics/overview?assistantId=uuid&range=30
获取指定助理的使用情况统计信息、消息总数、捕获的潜在客户以及一般参与度指标。 range 参数是可选的(天数,最小值 7,最大值 365,默认 30)。
预期反应
{
"totalConversations": 1245,
"totalMessages": 8420,
"totalLeads": 156,
"totalBookings": 42,
"satisfactionRate": 94,
"avgMessagesPerSession": 6.7,
"avgSessionsPerDay": 41.5,
"liveNow": 3,
"onlineNow": 12,
"dailySeries": [
{
"date": "2026-07-15",
"conversations": 45,
"messages": 310,
"leads": 5,
"bookings": 2
}
],
"agentStats": [
{
"name": "Jane Doe",
"messagesSent": 120,
"csat": 98
}
]
}| 财产 | 类型 | 描述 |
|---|---|---|
totalConversations | 数字 | 助理处理的聊天会话总数。 |
totalMessages | 数字 | 所有对话中发送的消息总数(用户 + AI)。 |
totalLeads | 数字 | 提取的唯一潜在客户(姓名、电子邮件、电话)总数。 |
totalBookings | 数字 | 成功预订的日历约会总数。 |
satisfactionRate | 数字 | 正面反馈评分占总评分的百分比 (0-100)。 |
avgMessagesPerSession | 数字 | 每次对话交换的平均消息数。 |
avgSessionsPerDay | 数字 | 在要求的范围内每天的平均会话数。 |
liveNow | 数字 | 当前由人工代理接管的活动对话数量。 |
onlineNow | 数字 | 最近2分钟内主动与AI聊天的用户数量。 |
| 「每日系列」 | 大批 | 每日对象数组,包含每个日期的“对话”、“消息”、“潜在客户”和“预订”计数。 |
agentStats | 大批 | 人工代理的性能指标,包括“messagesSent”和“csat”(客户满意度得分)。 |
4. 知识与培训
创建助手后,您可以通过“知识节点”管理它的大脑。每个节点代表一块数据(爬行的 URL、上传的文档或手动文本片段)。
管理知识节点
GET /api/assistants/:id/nodes - 列出该助手的所有知识节点。
POST /api/assistants/:id/nodes - 手动注入新的知识块。
{
"title": "Return Policy",
"refined_content": "We offer a 30-day return policy for all unused items...",
"type": "text",
"metadata": {}
}PATCH /api/assistants/:id/nodes/:nodeId - 修改现有节点的内容或切换其活动状态。
{
"title": "Updated Return Policy",
"refined_content": "We offer a 60-day return policy now...",
"is_active": true
}DELETE /api/assistants/:id/nodes/:nodeId - 完全删除知识块。
POST /api/assistants/:id/nodes/:nodeId/re-crawl - 强制抓取工具重新抓取与此节点关联的 URL 并更新其内容。有效负载:{}。
人工智能培训
POST /api/assistants/:id/train - 编译所有 is_active 知识节点并使用 AI 编排器动态合成新的主系统提示。有效负载:{}。
Upload, crawl, and index consistency
| Operation | Limits and guarantees |
|---|---|
| Manual node | Title: 1–200 characters; content: 1–200,000 characters; metadata: object up to 20,000 serialized characters. |
| File upload | PNG, JPEG, WebP, PDF, DOCX, TXT, or Markdown; maximum 10 MB. Failed extraction creates a disabled repairable node and returns vector_sync_pending: true. |
| Deep crawl | maxPages is a positive integer capped by the plan (100 hard maximum); depth is capped at 20. Only public HTTP(S) destinations are allowed, including redirects and browser subrequests. |
| Enable / disable | Disabled nodes are removed from the vector index and are also filtered at retrieval time. Re-enable or edit an active node to rebuild its vectors. |
vector_sync_pending response means the record was saved but is not yet guaranteed searchable; call the sync endpoint or retry the edit.POST /api/knowledge/urls is retained only to return an explicit 410 Gone; it never stores data. Migrate to POST /api/assistants/:id/nodes/deep-crawl.5. 小组件外观与行为
Every accepted PATCH field, its real default, bounds, plan behavior, and nested shape.
PATCH /api/assistants/:id/widget-config
Send only the fields you want to change. The API rejects unknown keys and invalid nested data instead of silently storing configuration the widget cannot use.
{
"designPreset": "corporate-soft",
"primaryColor": "#1972F5",
"theme": "dark",
"bubbleStyle": "branded-drawer",
"bubbleText": "Talk to our team",
"welcomeMessages": [
{
"text": "Hello! How can I help?",
"delay": 1.5
}
],
"welcomeSuggestions": [
"View pricing",
"Book a demo"
],
"pageVisibility": {
"mode": "exclude",
"paths": [
"/checkout/*"
]
},
"voiceEnabled": true,
"voiceName": "Aoede",
"copilotEnabled": true,
"gdprConsentEnabled": true,
"privacyPolicyUrl": "https://example.com/privacy"
}| Field | Type / bounds | Default | Effect | Plan behavior |
|---|---|---|---|---|
primaryColor | hex color | #000000 | 十六进制颜色代码(例如“#000000”)。 | — |
designPreset | enum | default | Visual system: default, legacy, corporate, corporate-soft, editorial. | — |
position | enum | bottom-right | “右下”、“左下”、“右上”、“左上”。 | — |
theme | enum | light | “亮”或“暗”。 | — |
fontFamily | enum | default | “默认”(国际)或“继承”。 | — |
bubbleStyle | enum | circle | "circle"、"bar"、"drawer"、“品牌圆”、“品牌吧台”、“品牌抽屉”`。 | Branded launcher styles require custom-branding access. |
bubbleText | string (1–80) | Chat with us | 显示在气泡旁边的文本(对于栏/抽屉样式)。 | — |
customLogoUrl | HTTP(S) URL or null | null | 自定义标题徽标图像的 URL。 | Requires custom-branding access. Prefer HTTPS or the widget-logo upload endpoint. |
title | string (1–50) | business name | 小部件标题中的标题。 | — |
headerSubtitle | string (0–100) | We typically reply instantly | 小部件标题中的副标题。 | — |
welcomeMessage | string (0–300) | Hi! How can I help you today? | 最初的问候语。 | — |
welcomeMessages | array (1–5) | one greeting | Ordered greeting objects with text (1–300) and delay in seconds (0–10). | — |
welcomeMessageDelay | number (0–10) | 2 | 问候前延迟几秒。 | — |
welcomeSuggestions | string[] (max 3) | [] | 用于初始快速回复芯片的字符串数组。 | — |
inputPlaceholder | string (1–100) | Type your message... | 消息输入的占位符文本。 | — |
language | language code | assistant language | 小部件语言代码(例如“en”、“fr”)。 | — |
showBranding | boolean | true | Show the Powered by Chirps attribution. | Plans without branding removal always force true. |
voiceEnabled | boolean | true | 启用语音通话。 | Plans without voice access always force false. |
voiceModel | string | platform default | Realtime voice model identifier. Normally leave unchanged so Chirps can use the supported platform model. | — |
voiceName | enum | Fenrir | 音频响应的语音标识。请参阅下面的可用声音。 | — |
fileUploadEnabled | boolean | true | 允许用户上传附件。 | Plans without file uploads always force false. |
dictationEnabled | boolean | true | 启用语音听写(语音转文本)。 | — |
copilotEnabled | boolean | plan default | Allow the DOM-navigation Copilot experience. | Plans without Copilot always force false. |
pageVisibility | object | { mode: all, paths: [] } | 确定小部件出现在哪些页面上(“mode”、“paths”)。 | — |
humanizerEnabled | boolean | true | Apply the conversational response-style pass. | — |
promptInjectionProtectionEnabled | boolean | true | Screen visitor and uploaded-file prompt injection attempts and keep lower-trust content from overriding assistant instructions. | — |
rateLimitEnabled | boolean | true | 启用聊天速率限制。默认为真。 | — |
rateLimitMaxMessages | integer (1–500) | 30 | 窗口中的最大消息数。默认 30。 | — |
rateLimitTimeWindow | integer minutes (1–1440) | 60 | 时间窗口以分钟为单位。默认 60。 | — |
privacyPolicyUrl | HTTP(S) URL | empty | 您的隐私政策的 URL。 | — |
gdprConsentEnabled | boolean | false | Show the compact chat privacy notice before the visitor sends data. | — |
gdprDataMaskingEnabled | boolean | false | 保存前屏蔽 PII。默认为 false。 | — |
cookieConsentEnabled | boolean | false | Enable widget cookie preferences and consent UI. | — |
cookieConsentAnalyticsEnabled | boolean | true | Offer optional analytics in cookie preferences. Analytics events remain blocked until the visitor affirmatively consents. | — |
Page visibility matching
Use exact paths such as /pricing, or append /* to include descendants such as /docs/*. include shows only matches; exclude hides matches; all ignores paths. Full URLs are normalized to their pathname by the widget.
Available voice names
Zephyr, Aoede, Kore, Leda, Callirrhoe, Despina, Erinome, Laomedeia, Achernar, Pulcherrima, Gacrux, Algenib, Sulafat, Puck, Charon, Fenrir, Orus, Enceladus, Iapetus, Umbriel, Algieba, Autonoe, Rasalgethi, Alnilam, Schedar, Sadachbia, Achird, Zubenelgenubi, Sadaltager
GET /api/assistants/:id/widget-config without an API key. That read is intentionally origin-bound to the authorized business domain in production mode and returns plan-normalized public configuration. It is not a server-to-server developer endpoint; never treat it as a way to read private assistant settings.6. 交互式组件
The complete configuration model for forms, bookings, cards, CSAT, and custom tools.
GET /api/assistants/:id/artifacts · PUT /api/assistants/:id/artifacts · PATCH /api/assistants/:id/artifacts
Artifacts are tool-driven UI. The model calls the enabled tool and Chirps renders it; integrations must send configuration JSON, never {{ARTIFACT: ...}} strings.
{
"form": {
"enabled": true,
"title": "Request a quote",
"description": "Collect the details needed for a quote.",
"triggerRules": "When a visitor explicitly asks for a quote.",
"fields": [
{
"key": "name",
"label": "Full name",
"type": "text",
"required": true,
"placeholder": "Jane Doe"
},
{
"key": "email",
"label": "Work email",
"type": "email",
"required": true
}
],
"submitLabel": "Request quote"
},
"booking": {
"enabled": true,
"title": "Book a consultation",
"description": "Choose an available time.",
"triggerRules": "When a visitor asks to book a meeting.",
"services_enabled": false,
"meetings_enabled": true,
"requiresScheduling": true,
"timezone": "Europe/Paris",
"slotDuration": 30,
"bufferMinutes": 10,
"workingHours": {
"monday": {
"enabled": true,
"start": "09:00",
"end": "17:00"
},
"tuesday": {
"enabled": true,
"start": "09:00",
"end": "17:00"
},
"wednesday": {
"enabled": true,
"start": "09:00",
"end": "17:00"
},
"thursday": {
"enabled": true,
"start": "09:00",
"end": "17:00"
},
"friday": {
"enabled": true,
"start": "09:00",
"end": "17:00"
},
"saturday": {
"enabled": false,
"start": "10:00",
"end": "14:00"
},
"sunday": {
"enabled": false,
"start": "10:00",
"end": "14:00"
}
},
"blockedDates": [
"2026-12-25"
],
"meeting_intake_fields": [
{
"key": "email",
"label": "Email",
"type": "email",
"required": true
}
],
"submitLabel": "Book meeting"
},
"card": {
"enabled": false,
"ctaLabel": "View details",
"ctaUrl": "",
"description": "",
"triggerRules": ""
},
"csat_survey": {
"enabled": true,
"title": "How was your experience?",
"description": "One-click feedback.",
"triggerRules": "Only after the request is resolved."
},
"custom": []
}| Section | Accepted properties | Runtime behavior |
|---|---|---|
form | enabled, title, description, triggerRules, fields, submitLabel | Lead capture and structured intake through show_form. |
booking | enabled, title, description, triggerRules, services_enabled, meetings_enabled, requiresScheduling, timezone, slotDuration, bufferMinutes, workingHours, blockedDates, categories, services, meeting_intake_fields, submitLabel | Meeting or service scheduling through show_booking; supplied values can be prefilled and exact requested slots are verified. |
card | enabled, ctaLabel, ctaUrl, description, triggerRules | Transactional rich-card behavior when verified product data exists. |
csat_survey | enabled, title, description, triggerRules | Thumbs-up/down feedback through show_csat_survey. |
custom | Array of enabled, name, type, description, triggerRules, schema, isCustom | Plan-gated custom tool-backed artifacts. |
Field schema
| Field | Type / bounds | Effect |
|---|---|---|
key | string | Stable machine key used by prefilled_data and requested_fields. |
label | string | Visitor-facing label. |
type | enum | text, email, tel, textarea, number, date, url, dropdown, radio, checkbox, slider, select, or location. |
required | boolean | Blocks submission until a valid value is supplied. |
placeholder | string (max 200) | Optional hint shown inside the control. |
options | string[] | Choices for dropdown, radio, and select controls. |
min, max, step | number | Numeric and slider bounds. |
geo_scope | object | Location boundary: worldwide, continent, country, state, city, or custom; optional value and map bounds. |
Booking service schema
| Field | Type / bounds | Effect |
|---|---|---|
id, name, description | string | Stable service identity and visitor-facing copy. |
duration | minutes | Service duration; the configured slot duration is the fallback. |
category, price | string | Optional filtering and display metadata. |
routing.type | enum | virtual, physical, or phone. |
routing.platform | enum | google_meet, teams, or custom for virtual services. |
routing.link, routing.address | string | Destination appropriate to the selected routing type. |
intake_fields | field[] | Service-specific information requested during booking. |
Validation limits and scheduling rules
| Field | Type / bounds | Effect |
|---|---|---|
fields, meeting_intake_fields, intake_fields | max 50 each | Every field needs a unique machine key, label, and supported type. |
services / categories | max 100 each | Service IDs should remain stable after clients begin storing them. |
slotDuration | integer 5–480 minutes | Length of generated calendar slots. |
bufferMinutes | integer 0–1440 minutes | Unavailable gap inserted around bookings. |
timezone | IANA time-zone name | Business schedule zone, for example Europe/Paris; visitor times are converted for display and calendar invitations. |
workingHours | seven day objects | Each enabled day uses 24-hour HH:mm and must end after it starts. |
blockedDates | YYYY-MM-DD[] (max 366) | Dates unavailable in the business time zone. |
custom | max 20 | Custom tools are plan-gated; names and types are required. |
Tool-call prefill behavior
| Field | Type / bounds | Effect |
|---|---|---|
prefilled_data | object | Values already learned in chat, keyed by configured field key. |
requested_fields | string[] | Show only the configured fields relevant to this intent. |
mode | meeting or service | Select the general meeting flow or a configured service flow. |
selected_service_id | string | Preselect a configured service; never invent an ID. |
requested_categories | string[] | Restrict the visible service list to configured categories. |
preferred_start_time_iso | ISO-8601 | Ask the widget to verify one visitor-requested instant before showing approval. |
artifacts array; streaming responses emit event: artifacts with { artifacts: [...] }. Chirps also keeps compatibility tags in message text for existing widgets and stored history. New clients should consume the structured field/event and treat message text as display copy.7. 连接器与工具
Discover provider schemas at runtime, store credentials securely, then activate only the tools an assistant needs.
Start with GET /api/marketplace/connectors. Its provider definitions are the source of truth for credential fields, configuration fields, available tools, defaults, and required values; this keeps custom and future providers discoverable without a documentation release.
{
"provider": "shopify",
"name": "Shopify",
"credentials": {}
}- Install the workspace connector record with
POST /api/assistants/:id/connectors;credentialsmust be omitted or{}. - Read its exact field schema from
GET /api/marketplace/connectorsand activate it withPOST /api/assistants/:id/connectors/:connectorId/activate. - Send
configValues, optionalenabledTools, and optionalinstructions. Chirps verifies non-custom connectors and discovers the tools before saving the integration. - Rotate secrets by calling the activation endpoint again.
PUTonly renames a named Custom API. - Use
DELETE /api/assistants/:id/connectorswith{ connectorId }to disable it for one assistant. Use the nestedDELETE .../:connectorIdonly to permanently remove it from the workspace and every assistant.
| Field | Type / bounds | Effect |
|---|---|---|
configValues | object (max 100 scalar values) | Exact keys from the marketplace schema. Values are bounded and secrets are write-only. |
enabledTools | string[] (max 200) | Optional allow-list of tools discovered from the verified connector. |
instructions | string (max 10,000) | Assistant-specific constraints for tool use. |
name | string (max 120) | Optional rename during activation, supported only for named Custom APIs. |
8. 集成与部署
配置并培训您的助手后,您可以通过两种主要方式来部署它:
选项 A:Web 嵌入(前端)
将助手集成到标准网站(WordPress、Shopify、React 等)的最简单方法。嵌入代码纯粹是确定性的。您不需要端点来获取它。只需将其放入站点的“<head>”即可:
<script>
window.chirpsConfig = { assistantId: "YOUR_ASSISTANT_ID" };
</script>
<script src="https://chirps.cc/embed.js" async></script>选项 B:无头集成(后端/CRM/机器人)
如果您正在构建自定义客户端(例如 Discord 机器人、Telegram 集成或本机 iOS 应用程序),您将不会使用 Web Embed。相反,您将直接与“/api/chat”端点交互。
POST /api/chat 或 /api/chat?stream=true
重要: 无头及服务器到服务器调用必须包含 Authorization: Bearer <YOUR_CHIRPS_API_KEY>。只有已安装的浏览器小组件使用与来源绑定的公开流程。切勿把 API 密钥放入前端 JavaScript。
{
"assistantId": "123e4567-e89b-12d3-a456-426614174000",
"sessionId": "unique-session-id-for-user",
"conversationId": "optional-uuid",
"message": "Hello, I need help with my billing."
}*(如果“fileUploadEnabled”为 true,还支持带有“file”附件字段的“multipart/form-data”)。*
| 范围 | 类型 | 必需的 | 描述 |
|---|---|---|---|
assistantId | 细绳 | 是的 | 助手的UUID。 |
sessionId | 细绳 | 是的 | 您生成此。 来自您自己的系统的唯一标识符,用于对聊天历史记录进行分组(例如,Discord 用户 ID、Telegram 聊天 ID 或随机 UUID)。 |
message | 细绳 | 是的 | 消息的文本内容(最多 5000 个字符)。 |
conversationId | 细绳 | 不 | 对话的 UUID(在您的第一个请求中返回)。 |
id | 细绳 | 不 | 可选的客户端消息 ID 以防止重复数据删除。 |
模式 1:标准 JSON 响应(默认)
通过向“/api/chat”发送 POST 请求(不带流参数),您可以等待完整的 AI 响应并接收标准 JSON 对象。
{
"message": "Here is the information you requested...",
"conversationId": "uuid-of-conversation",
"messageId": "uuid-of-message"
}*(如果返回“is_active_agent: true”,则表示有人接管了聊天,并且“message”将为“null”。)*
模式 2:服务器发送的事件流式传输 (?stream=true)
通过将“?stream=true”附加到 URL,您将收到实时服务器发送事件 (SSE) 流。您的代码应该侦听这些特定的事件类型:
- `event: token`:包含
{"text": "chunk"}。针对 AI 响应文本的每个块触发。 - `event: status`:包含
{"text": "Searching knowledge base..."}。表示后端工具执行状态。 - `event: done`:包含
{"messageId": "uuid", "conversationId": "uuid", "message": "full text"}。当生成完全完成时触发。 - `event: error`:包含
{"error": "Error message"}。如果发生速率限制或错误则触发。
实时接管端点
GET /api/chat/sessions
检索历史会话。
POST /api/chat/toggle-agent
暂停人工智能让人类接管。有效负载:{ "sessionId": "...", "isActive": true }
POST /api/chat/agent-message
发送人类消息。负载:{ "sessionId": "...", "message": "..." }
Complete chat response contract
{
"message": "I've opened the booking calendar for you.",
"messageId": "uuid",
"conversationId": "uuid",
"artifacts": [
{
"type": "booking",
"title": "Book a consultation"
}
],
"sources": []
}A human takeover returns { message: null, conversationId, is_active_agent: true }. A streaming request can therefore return JSON before an SSE stream begins; check the response Content-Type.
Complete SSE event reference
| Event | Payload and behavior |
|---|---|
token | { text } — committed assistant text chunk. |
status | { text } — tool or retrieval progress for user-facing status UI. |
artifacts | { artifacts: [...] } — structured tool-generated UI payloads. |
sources | { sources, tag } — structured citations when enhanced streaming is enabled. |
provisional | { text } — temporary pre-tool text with X-Chirps-Stream-Version: 2. |
reset | {} — discard accumulated provisional text. |
commit | {} — commit accumulated provisional text. |
done | { messageId, conversationId, message } — authoritative final message. |
error | { error } — terminal generation error. |
X-Chirps-Stream-Version: 2 to receive provisional/reset/commit and structured source events. Clients that do not implement those events should omit the header and rely on token, artifacts, done, and error.9. 高级助手设置
PATCH /api/assistants/:id
更新核心配置
修改助手的核心设置、角色和抓取范围。
{
"business_name": "Acme Corp",
"business_url": "acme.com",
"business_description": "We sell anvils.",
"system_prompt": "You are a helpful assistant.",
"language": "en",
"tone_personality": "Friendly",
"support_email": "[email protected]",
"additional_instructions": "Never mention the Roadrunner.",
"is_multi_language": true,
"is_dev_mode": false,
"is_active": true,
"max_pages": 15,
"max_depth": 2,
"widget_config_merge": {
"rateLimitEnabled": true
}
}*注意:所有字段都是可选的。仅发送您要更新的字段。*
删除助手
DELETE /api/assistants/:id
永久删除助手,并级联删除所有知识节点、对话、消息。如果助手从未完全设置,则会退还每月创建配额。
10. 电话和语音
GET /api/phone-numbers - 列出可用号码。
POST /api/phone-numbers/:subscriptionId/assign assigns an already-purchased Chirps phone subscription to an assistant. Send { "assistantId": "uuid" }; send { "assistantId": null } to unassign it. This endpoint does not purchase or provision a new number.
POST /api/assistants/:id/outbound - 触发出站呼叫。有效负载:{ "phoneNumber": "+123...", "callReason": "Confirm the requested appointment", "conversationId": "optional-uuid" }
11. 线索提取
GET /api/leads?assistantId=uuid&page=1&limit=50&status=new - 获取对话期间人工智能提取的分页、结构化线索。
GET /api/leads?id=leadId - 获取单个潜在客户的详细信息,包括完整的对话记录。
Public lead response
Lead objects contain id, assistant_id, conversation_id, session_id, name, email, phone, status, notes, artifact_id, ai_score, ai_summary, form_data, created_at, and the assistant business name. Internal voice-confirmation/idempotency identifiers are never returned.
12. 预订和日历
GET /api/bookings?assistantId=uuid&start=ISO-8601&end=ISO-8601 - 检索助理安排的日历约会,可以选择按日期过滤。
GET /api/bookings?id=bookingId - 获取单个预订的详细信息,包括对话记录。
DELETE /api/bookings/cancel?id=bookingId - 取消有效预约。仅当您的集成确实要阻止 Chirps 发送备用取消邮件时,才添加 &silent=true。
POST /api/bookings/reschedule - 调整预订。有效负载:{ "bookingId": "uuid", "newStartTime": "ISO-8601", "newEndTime": "ISO-8601" }
Public booking response and time zones
Booking objects contain the public appointment, guest, status, notes, and timestamp fields plus business_timezone. Times are ISO-8601 instants; format them in the viewer's time zone while preserving the returned business zone for schedule context. Internal confirmation IDs, provider calendar-event IDs, and database range columns are omitted.
13. 账户和账单使用
GET /api/billing/usage
检索工作区的计费周期使用情况、订阅计划限制和助理总数。 注意: 使用 API 密钥时,请求的范围将自动限定在 API 密钥的工作区;您不需要提供“teamId”。
响应(`200 OK`):
{
"planName": "Pro",
"periodStr": "2023-10-01",
"assistantCount": 3,
"usage": {
"message_count": 1450,
"harvest_count": 12,
"recrawl_count": 5,
"train_count": 2,
"assistants_created_count": 1,
"voice_minutes_used": 0,
"sms_count": 0,
"email_count": 0,
"whatsapp_count": 0
},
"limits": {
"messages": 5000,
"assistants": 5,
"training": 50,
"recrawls": 20
},
"workspaceOwnerId": "uuid"
}14. 完整端点目录
The reviewed, API-key-compatible surface. Paths and JSON property names are never translated.
What belongs in the public developer API
These routes accept a scoped Chirps API key and enforce its workspace boundary. Dashboard-only billing/OAuth routes, browser widget callbacks, provider webhooks, cron jobs, and internal MCP routes are intentionally excluded.
id for duplicate protection. Do not automatically retry other write operations unless the response is clearly safe to retry. 402 means a plan quota was reached; 429 means throttled; 5xx may be transient.Assistants
| Method | Path | Scope | Request | Successful result |
|---|---|---|---|---|
GET | /api/assistants | assistants:read | — | Assistant array; credential fields omitted |
POST | /api/assistants | assistants:write | Assistant creation JSON | Created assistant and setup identifiers |
GET | /api/assistants/:id | assistants:read | — | Assistant configuration; secrets omitted |
PATCH | /api/assistants/:id | assistants:write | Supported fields only | Updated assistant |
DELETE | /api/assistants/:id | assistants:write | — | Deletion confirmation |
GET | /api/assistants/:id/setup | assistants:read | — | Setup and crawl status |
POST | /api/assistants/:id/setup | assistants:write | Empty body | SSE setup progress stream |
GET | /api/analytics/overview?assistantId=:id&range=30 | analytics:read | Query: range 7–365 | Engagement, lead, booking and agent metrics |
Knowledge and training
| Method | Path | Scope | Request | Successful result |
|---|---|---|---|---|
GET | /api/assistants/:id/nodes | knowledge:read | — | Knowledge node array |
POST | /api/assistants/:id/nodes | knowledge:write | { title, refined_content, type?, metadata? } | Stored and vectorized node |
PATCH | /api/assistants/:id/nodes/:nodeId | knowledge:write | { title?, refined_content?, is_active? } | Updated and re-vectorized node |
DELETE | /api/assistants/:id/nodes/:nodeId | knowledge:write | — | Node deletion confirmation |
POST | /api/assistants/:id/nodes/:nodeId/re-crawl | knowledge:write | Empty body | Refreshed URL node |
POST | /api/assistants/:id/nodes/upload | knowledge:write | multipart/form-data: file, title? | Extracted knowledge node |
POST | /api/assistants/:id/nodes/deep-crawl | knowledge:write | { maxPages? } | SSE crawl progress stream |
POST | /api/assistants/:id/nodes/sync | knowledge:write | Empty body | Vector store synchronization result |
POST | /api/assistants/:id/train | knowledge:write | Empty body | Compiled assistant prompt |
POST | /api/assistants/:id/harvest | knowledge:write | Empty body | Conversation insights added to knowledge |
POST | /api/knowledge/urls | knowledge:write | Deprecated | Always returns 410 with the assistant-scoped deep-crawl replacement path |
Widget, artifacts and connectors
| Method | Path | Scope | Request | Successful result |
|---|---|---|---|---|
PATCH | /api/assistants/:id/widget-config | widget:write | Partial widget configuration | Normalized widget configuration |
POST | /api/assistants/:id/widget-logo | widget:write | multipart/form-data: file (PNG/JPEG/WebP, max 2 MB) | Public logo URL |
GET | /api/assistants/:id/artifacts | artifacts:read | — | Form, booking, card and CSAT configuration |
PUT | /api/assistants/:id/artifacts | artifacts:write | Complete artifact configuration | Normalized configuration |
PATCH | /api/assistants/:id/artifacts | artifacts:write | Partial artifact configuration | Merged normalized configuration |
GET | /api/marketplace/connectors | connectors:read | — | Installable connector definitions; no credentials |
GET | /api/assistants/:id/connectors | connectors:read | — | Workspace connectors and assistant integrations |
POST | /api/assistants/:id/connectors | connectors:write | { provider, name, credentials?: {} } | Installed connector record; no operational access yet |
PUT | /api/assistants/:id/connectors/:connectorId | connectors:write | { name } (named custom APIs only) | Renamed connector; credentials omitted |
DELETE | /api/assistants/:id/connectors | connectors:write | { connectorId } | Connector disabled for this assistant only |
DELETE | /api/assistants/:id/connectors/:connectorId | connectors:write | — | Workspace connector and all assistant integrations deleted |
POST | /api/assistants/:id/connectors/:connectorId/activate | connectors:write | { configValues, enabledTools?, instructions?, name? } | Activated integration and tool list |
Conversations, leads and bookings
| Method | Path | Scope | Request | Successful result |
|---|---|---|---|---|
POST | /api/chat or /api/chat?stream=true | chat:write | { assistantId, sessionId, message, conversationId?, id? } | JSON reply with artifacts/sources or SSE token/artifacts/status/done events |
GET | /api/chat/sessions?assistantId=:id | conversations:read | — | 20 most recent session summaries |
GET | /api/assistants/:id/conversations?limit=20&status=active | conversations:read | Query: limit 1–50, status optional | Conversation summaries |
DELETE | /api/assistants/:id/conversations | conversations:write | { conversationIds: [uuid] } (max 100) | Deletion confirmation |
POST | /api/chat/toggle-agent | conversations:write | { sessionId, isActive } | Takeover state |
POST | /api/chat/agent-message | conversations:write | { sessionId, message } | Stored human-agent message |
POST | /api/chat/typing | conversations:write | { assistantId, sessionId, isTyping } | Typing-state confirmation |
POST | /api/chat/followup-draft | conversations:write | { conversationId|leadId, assistantId?, channel? } | AI-generated draft; consumes AI-message usage |
POST | /api/chat/conversation-followup | conversations:write | { conversationId|leadId, channel, recipient, subject?, message } | Dispatched follow-up result |
GET | /api/leads | leads:read | Query: id, or assistantId with page, limit, status | Lead detail with transcript or paginated leads; internal confirmation identifiers omitted |
POST | /api/leads | artifacts:write | Artifact submission JSON | Captured lead/booking result |
PATCH | /api/leads | leads:write | { leadId, status?, notes? } | Updated lead |
DELETE | /api/leads | leads:write | { leadId } or { leadIds: [uuid] } | Deletion count |
GET | /api/bookings | bookings:read | Query: id, or assistantId with start and end | Booking detail or booking array; provider and idempotency identifiers omitted |
DELETE | /api/bookings/cancel?id=:id | bookings:write | Query: silent=true optional | Cancellation and calendar-sync state |
POST | /api/bookings/reschedule | bookings:write | { bookingId, newStartTime, newEndTime } | Updated booking or available alternatives |
Telephony and account
| Method | Path | Scope | Request | Successful result |
|---|---|---|---|---|
GET | /api/phone-numbers | telephony:read | — | Numbers and assignable assistants in this workspace |
POST | /api/phone-numbers/:subscriptionId/assign | telephony:write | { assistantId } or { assistantId: null } | Routing update confirmation |
POST | /api/assistants/:id/outbound | telephony:write | { phoneNumber, callReason, conversationId? } | Provider call SID and conversation ID |
GET | /api/billing/usage | billing:read | — | Workspace plan, limits and current usage |
GET | /api/metadata?url=:httpsUrl | artifacts:read | Query: public HTTP(S) URL | Bounded page title, description and image metadata |