消息
向最终用户发送合作伙伴中心消息。
发送消息
POST /api/v1/messages
创建一条独立中心消息,而不是支持对话。
请求头
Authorization: Bearer <api_key>
Content-Type: application/json
正文参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
phone | string | 是 | E.164 目标号码 |
body | string | * | 文本正文 / 说明文字(text 类型必填) |
content_type | string | 否 | 默认为 text。请参阅媒体类型 |
template_code | string | 否 | 使用 vars 渲染 |
vars | object | 否 | 模板变量 |
priority | string | 否 | otp · notification · chat 等 |
idempotency_key | string | 否 | 对重试去重 |
media_url | string | * | 媒体类型的远程文件 URL |
media_base64 | string | * | 使用 Base64 文件代替 URL |
media_filename | string | 否 | 显示名称 |
media_mimetype | string | 否 | MIME 类型 |
link_url / url | string | * | 用于 content_type=link |
link_label / cta | string | 否 | 按钮标签 |
link_title | string | 否 | 卡片标题 |
link_description | string | 否 | 卡片说明 |
link_image_url | string | 否 | 卡片图片 |
html | string | * | 用于 content_type=html |
subject | string | 否 | 新闻简报标题(HTML) |
preview | string | 否 | 纯文本预览(HTML) |
文本示例
curl -X POST "$API/messages" \
-H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" \
-d '{
"phone": "+228XXXXXXXX",
"body": "Votre dossier est en cours de traitement.",
"priority": "notification",
"idempotency_key": "seed-dossier-1001"
}'
201 响应
{
"message_id": 142,
"ref": "52c22ee01478…",
"phone": "+228XXXXXXXX",
"partner": "seed",
"direction": "out",
"content_type": "text",
"body": "Votre dossier est en cours de traitement.",
"state": "delivered",
"priority": "notification",
"created_at": "2026-07-21 07:10:00"
}
获取消息
GET /api/v1/messages/{message_id}
返回消息及可选的投递尝试。
列出消息
GET /api/v1/messages
| 查询参数 | 说明 |
|---|---|
phone | 按账户手机号码筛选 |
state | queued · delivered · read 等 |
q | 搜索正文 / 联系人 |
limit | 页面大小 |
标记已读 / 未读(合作伙伴工具)
POST /api/v1/messages/{id}/read
POST /api/v1/messages/{id}/unread
POST /api/v1/messages/read
客服人员聊天发送
POST /api/v1/agent/messages
供合作伙伴中心的客服人员使用。适当时,它可以附加到未关闭的支持对话。自动化中心通知应优先使用 /messages。