开放接口 v1 · 供前端 SDK / 小程序 / 租户服务端集成。所有 JSON 请求均携带 Content-Type: application/json。
客服云提供三类接口:
Bearer JWT):登录后访问企业后台、座席工作台、平台后台。Bearer api_token):把客服能力接入你自有的 CRM / 工单系统。Host: https://你的域名 鉴权头(管理接口): Authorization: Bearer <登录返回的 access_token> 鉴权头(开放接口): Authorization: Bearer <企业后台「接入配置」重新生成的 api_token>
| 参数 | 说明 |
|---|---|
| slug | 路径参数,企业标识,如 your-brand |
curl https://你的域名/api/public/demo/brand
// =>
{"brand_name":"演示企业","brand_color":"#2962ff","brand_logo":"","welcome_title":"您好,欢迎咨询演示企业","welcome_text":"我们在线,很高兴为您服务。请描述您的问题。","enable_file_upload":true,"enable_rating":true,...}
conversation_id / customer_id / ws_url,随后建立 WebSocket 连接。| 参数 | 类型 | 说明 |
|---|---|---|
| external_id | string | 访客外部唯一标识(业务侧带来,可选) |
| nickname | string | 访客昵称,默认“访客” |
| channel | string | web / miniprogram / app,默认 web |
curl -X POST https://你的域名/api/public/demo/ticket \
-H "Content-Type: application/json" -d '{"external_id":"u_10086","nickname":"张三","channel":"web"}'
// => {"conversation_id":12,"customer_id":34,"tenant_id":5,"ws_url":"/ws/customer/demo?external_id=u_10086&nickname=张三"}
| 参数 | 说明 |
|---|---|
| file | multipart/form-data 文件字段 |
| kind | image / file |
// 表单二进制上传
POST /api/public/demo/upload?kind=image (multipart: file=@photo.jpg)
// => {"url":"/uploads/tenants/1/2026/09/uuid.jpg","name":"photo.jpg","size":10240,"ext":"jpg"}
curl https://你的域名/api/plans
// => [{"slug":"trial","name":"体验版","agent_quota":1,"bot_enabled":false,"price_cents":0,"billing_cycle":"month",...}]
curl -X POST https://你的域名/api/auth/register -H "Content-Type: application/json" \
-d '{"email":"a@x.com","password":"pass123456","tenant_name":"我的公司","tenant_slug":"mybrand","nickname":"管理员"}'
// => {"access_token":"eyJ...","token_type":"bearer"}
account 可为邮箱或手机号。curl -X POST https://你的域名/api/auth/login -H "Content-Type: application/json" \
-d '{"account":"a@x.com","password":"pass123456"}'
// => {"access_token":"eyJ...","token_type":"bearer"}
使用企业后台「接入配置」中生成的 api_token,攻击面隔离于租户,用于你自有系统对接,例如工单系统把处理结果推回会话。
status 可取 open / pending / closed。curl -X POST https://你的域名/api/openapi/conversations/messages \
-H "Authorization: Bearer kf_xxxx" -H "Content-Type: application/json" \
-d '{"conversation_id":12,"content":"您的工单已处理完成,感谢耐心等待。","msg_type":"text"}'
// => {"id":88}
is_staff 与 tenant。defs(每项 key/label/type/value) 与 brand。api_token。{"target_agent_id":2}{"query":"退换货流程","top_k":5}{"plan_slug":"pro"} 返回 order_no。{type:"message",content,msg_type:"text|image|file",meta}、{type:"read",conversation_id,last_message_id}、{type:"ping"}。Server→Client:{type:"message",data:{id,sender_role,msg_type,content,meta_json,created_at}}。{type:"conversations",data:[...]};可发 message / take / close / ping;收 message / read / taken / closed。<!-- 在官网任意位置粘贴即可,样式自动跟随品牌 --> <script src="https://你的域名/sdk/widget.js" data-slug="your-brand"></script>
/chat.html?slug=your-brand。uni-app 组件见工程 c-sdk/kefuChat.vue。