请求方式
POST /whatsapp/messages HTTP/1.1
Host: https://{your-domain}/api/open/v1
请求头
| 字段 | 类型 | 注释 |
| X-API-Key | string | 必填,API 密钥 |
通用请求参数
| 字段 | 类型 | 注释 |
| to | string | 是,接收方电话号码 |
| type | string | 是,消息类型 |
| phone_number_id | string | 是,发送方电话号码 ID |
文本消息 (text)
{
“to”: “+15551234567”,
“type”: “text”,
“phone_number_id”: “1906385232743451”,
“text”: {“body”: “Hello, this is a test message!”, “preview_url”: false}
}
| 字段 | 类型 | 注释 |
| text.body | string | 是,消息正文 |
| text.preview_url | bool | 否,是否预览 URL,默认 false |
图片消息 (image)
{
“to”: “+15551234567”,
“type”: “image”,
“phone_number_id”: “1906385232743451”,
“image”: {“link”: “https://example.com/image.jpg”, “caption”: “Check out this image”}
}
| 字段 | 类型 | 注释 |
| image.link | string | 是,图片链接 |
| image.caption | string | 否,图片说明 |
模板消息 (template)
{
“to”: “+15551234567”,
“type”: “template”,
“phone_number_id”: “1906385232743451”,
“template”: {
“name”: “order_confirmation”,
“language”: { “code”: “en_US”, “policy”: “deterministic” },
“components”: [
{
“type”: “header”,
“parameters”: [ { “type”: “text”, “text”: “Order #1234” } ]
},
{
“type”: “body”,
“parameters”: [
{ “type”: “text”, “text”: “John” },
{ “type”: “currency”, “currency”: { “fallback_code”: “USD”, “amount”: “25.00” } }
]
},
{
“type”: “button”,
“sub_type”: “url”,
“index”: “0”,
“parameters”: [ { “type”: “text”, “text”: “track123” } ]
}
]
}
}
| 字段 | 类型 | 注释 |
| template.name | string | 是,已审核通过的模板名称 |
| template.language.code | string | 是,语言代码(如 en_US、zh_CN) |
| template.language.policy | string | 否,回退策略,固定 deterministic |
| template.components | array | 否,模板参数组件数组 |
| components[].type | string | 是,组件类型:header / body / button / footer / media |
| components[].sub_type | string | 否,button 组件子类型:url / quick_reply |
| components[].index | string | 否,button 组件的序号(从 “0” 开始) |
| components[].parameters[].type | string | 是,参数类型:text / image / document / video / audio / currency / datetime / button |
| components[].parameters[].text | string | 否,type=text 时的文本值 |
| components[].parameters[].currency | object | 否,type=currency 时,含 fallback_code / amount / code 等 |
| components[].parameters[].datetime | object | 否,type=datetime 时,含 fallback_value / component 等 |
视频消息(video)
{
“to”: “+15551234567”,
“type”: “video”,
“phone_number_id”: “1906385232743451”,
“video”: { “link”: “https://example.com/video.mp4“, “caption”: “Check out this video” }
}
| 字段 | 类型 | 注释 |
|---|---|---|
| video.link | string | 否,视频链接 URL(与 video.id 二选一) |
| video.id | string | 否,已上传媒体的 ID(与 video.link 二选一) |
| video.caption | string | 否,视频说明文字 |
音频消息(audio)
{
“to”: “+15551234567”,
“type”: “audio”,
“phone_number_id”: “1906385232743451”,
“audio”: { “link”: “https://example.com/audio.mp3” }
}
| 字段 | 类型 | 注释 |
|---|---|---|
| audio.link | string | 否,音频链接 URL(与 audio.id 二选一) |
| audio.id | string | 否,已上传媒体的 ID(与 audio.link 二选一) |
文档消息(document)
{
“to”: “+15551234567”,
“type”: “document”,
“phone_number_id”: “1906385232743451”,
“document”: {
“link”: “https:file.pdf”,
“filename”: “invoice-2026.pdf”,
“caption”: “Your monthly invoice”
}
}
| 字段 | 类型 | 注释 |
|---|---|---|
| document.link | string | 否,文档链接 URL(与 document.id 二选一) |
| document.id | string | 否,已上传媒体的 ID(与 document.link 二选一) |
| document.filename | string | 否,文件名(建议带上扩展名) |
| document.caption | string | 否,文档说明文字 |
贴纸消息(sticker)
{
“to”: “+15551234567”,
“type”: “sticker”,
“phone_number_id”: “1906385232743451”,
“sticker”: { “link”: “https://example.com/sticker.webp” }
}
| 字段 | 类型 | 注释 |
|---|---|---|
| sticker.link | string | 否,贴纸链接 URL(与 sticker.id 二选一,需为 animated/static 贴纸格式) |
| sticker.id | string | 否,已上传贴纸的媒体 ID(与 sticker.link 二选一) |
位置消息(location)
{
“to”: “+15551234567”,
“type”: “location”,
“phone_number_id”: “1906385232743451”,
“location”: {
“longitude”: -122.425559,
“latitude”: 37.774797,
“name”: “Meta HQ”,
“address”: “1 Hacker Way, Menlo Park, CA 94025”
}
}
| 字段 | 类型 | 注释 |
|---|---|---|
| location.longitude | number | 是,经度 |
| location.latitude | number | 是,纬度 |
| location.name | string | 否,地点名称 |
| location.address | string | 否,详细地址 |
联系人消息(contacts)
{
“to”: “+15551234567”,
“type”: “contacts”,
“phone_number_id”: “1906385232743451”,
“contacts”: [
{
“name”: {
“formatted_name”: “John Smith”,
“first_name”: “John”,
“last_name”: “Smith”
},
“birthday”: “1990-01-01”,
“phones”: [
{ “phone”: “+15551234567”, “type”: “CELL”, “wa_id”: “15551234567” }
]
}
]
}
| 字段 | 类型 | 注释 |
|---|---|---|
| contacts[].name.formatted_name | string | 是,联系人全名 |
| contacts[].name.first_name | string | 否,名 |
| contacts[].name.last_name | string | 否,姓 |
| contacts[].birthday | string | 否,生日,格式 YYYY-MM-DD |
| contacts[].phones[].phone | string | 否,电话号码(带 + 的国际格式) |
| contacts[].phones[].type | string | 否,号码类型:CELL / MAIN / IPHONE / HOME / WORK |
| contacts[].phones[].wa_id | string | 否,该号码对应的 WhatsApp ID |
互动消息(interactive)
1)按钮(button)
{
“to”: “+15551234567”,
“type”: “interactive”,
“phone_number_id”: “1906385232743451”,
“interactive”: {
“type”: “button”,
“body”: { “text”: “Please choose an option” },
“footer”: { “text”: “Powered by PandaGPT” },
“action”: {
“buttons”: [
{ “type”: “reply”, “reply”: { “id”: “btn_yes”, “title”: “Yes” } },
{ “type”: “reply”, “reply”: { “id”: “btn_no”, “title”: “No” } }
]
}
}
}
| 字段 | 类型 | 注释 |
|---|---|---|
| interactive.type | string | 是,固定 button |
| interactive.header | object | 否,标题区,header.type: text/image/video/document |
| interactive.header.text | string | 否,header.type=text 时的标题文本 |
| interactive.body.text | string | 是,正文文本 |
| interactive.footer.text | string | 否,页脚文本 |
| interactive.action.buttons[].type | string | 是,固定 reply |
| interactive.action.buttons[].reply.id | string | 是,按钮回传 ID |
| interactive.action.buttons[].reply.title | string | 是,按钮显示文案 |
button 类型最多 3 个按钮,title 长度有限制。
2)列表(list)
{
“to”: “+15551234567”,
“type”: “interactive”,
“phone_number_id”: “1906385232743451”,
“interactive”: {
“type”: “list”,
“header”: { “type”: “text”, “text”: “Menu” },
“body”: { “text”: “Pick one item” },
“footer”: { “text”: “Tap to browse” },
“action”: {
“button”: “View options”,
“sections”: [
{
“title”: “Section 1”,
“rows”: [
{ “id”: “row_1”, “title”: “Item A”, “description”: “Desc A” },
{ “id”: “row_2”, “title”: “Item B” }
]
}
]
}
}
}
| 字段 | 类型 | 注释 |
|---|---|---|
| interactive.type | string | 是,固定 list |
| interactive.body.text | string | 是,正文文本 |
| interactive.action.button | string | 是,列表触发按钮文案 |
| interactive.action.sections[].title | string | 否,分组标题 |
| interactive.action.sections[].rows[].id | string | 是,行回传 ID |
| interactive.action.sections[].rows[].title | string | 是,行标题 |
| interactive.action.sections[].rows[].description | string | 否,行描述 |
3)商品目录(product / product_list / catalog_message)
{
“to”: “+15551234567”,
“type”: “interactive”,
“phone_number_id”: “1906385232743451”,
“interactive”: {
“type”: “product”,
“body”: { “text”: “Featured product” },
“action”: { “catalog_id”: “999888777666555”, “product_retailer_id”: “item-001” }
}
}
| 字段 | 类型 | 注释 |
|---|---|---|
| interactive.type | string | 是,product / product_list / catalog_message 之一 |
| interactive.action.catalog_id | string | 条件必填,product / product_list 所需商品目录 ID |
| interactive.action.product_retailer_id | string | 条件必填,product 类型的单品零售 ID |
| interactive.action.sections | array | 条件必填,product_list 的商品分组(含 product_retailer_id) |
| interactive.action.product_retailer_id (catalog_message) | string | 条件必填,catalog_message 使用的零售商品 ID |
4)Flow / 订单(flow / order_details / order_status)
{
“to”: “+15551234567”,
“type”: “interactive”,
“phone_number_id”: “1906385232743451”,
“interactive”: {
“type”: “flow”,
“body”: { “text”: “Complete your booking” },
“action”: {
“mode”: “published”,
“flow_message_version”: “3”,
“flow_token”: “a-token”,
“flow_id”: “FLOW_ID”,
“flow_cta”: “Open”
}
}
}
| 字段 | 类型 | 注释 |
|---|---|---|
| interactive.type | string | 是,flow / order_details / order_status 之一 |
| interactive.action.mode | string | flow 必填,published 或 draft |
| interactive.action.flow_message_version | string | flow 必填,Flow 消息版本 |
| interactive.action.flow_token | string | flow 必填,鉴权 token |
| interactive.action.flow_id | string | flow 必填,Flow ID |
| interactive.action.flow_cta | string | flow 必填,按钮文案 |
| interactive.action.type | string | order_details / order_status 必填,订单动作类型 |
回应消息(reaction)
{
“to”: “+15551234567”,
“type”: “reaction”,
“phone_number_id”: “1906385232743451”,
“reaction”: { “message_id”: “wamid.HBgLMTU1NTEyMzQ1NjcVAgASGBQ…”, “emoji”: “👍” }
}
| 字段 | 类型 | 注释 |
|---|---|---|
| reaction.message_id | string | 是,要回应的那条消息的 ID |
| reaction.emoji | string | 否,表情符号;不传则移除已有回应 |