请求方式
POST /whatsapp/getMediaContent HTTP/1.1
Host: https://{your-domain}/api/open/v1
请求头
| 字段 | 类型 | 注释 |
| X-API-Key | string | 必填,API 密钥 |
请求参数
| 字段 | 类型 | 注释 |
| media_id | string | 是,素材id |
| phone_number_id | string | 是,关联手机号phone_number_id |
返回的结果:
文件流
POST /whatsapp/getMediaContent HTTP/1.1
Host: https://{your-domain}/api/open/v1
| 字段 | 类型 | 注释 |
| X-API-Key | string | 必填,API 密钥 |
| 字段 | 类型 | 注释 |
| media_id | string | 是,素材id |
| phone_number_id | string | 是,关联手机号phone_number_id |
返回的结果:
文件流
转发WhatsApp Business 开放平台发送过来的信息,数据结构不做变动
数据:
account_alerts 参考文档:account_alerts Webhook 参考文档 | 开发者文档 (facebook.com)
account_review_update参考文档:account_review_update Webhook 参考文档 | 开发者文档 (facebook.com)
account_update参考文档:account_update Webhook 参考文档 | 开发者文档 (facebook.com)
business_capability_update参考文档:business_capability_update Webhook 参考文档 | 开发者文档 (facebook.com)
history(历史记录)参考文档:history(历史记录)Webhook 参考文档 | 开发者文档 (facebook.com)
message_template_components_update参考文档:message_template_components_update Webhook 参考文档 | 开发者文档 (facebook.com)
message_template_quality_update参考文档:message_template_quality_update Webhook 参考文档 | 开发者文档 (facebook.com)
message_template_status_update参考文档:message_template_status_update Webhook 参考文档 | 开发者文档 (facebook.com)
消息 参考文档:消息 Webhook 参考文档 | 开发者文档 (facebook.com)
partner_solutions 参考文档:partner_solutions Webhook 参考文档 | 开发者文档 (facebook.com)
payment_configuration_update 参考文档:payment_configuration_update Webhook 参考文档 | 开发者文档 (facebook.com)
phone_number_name_update 参考文档:phone_number_name_update Webhook 参考文档 | 开发者文档 (facebook.com)
phone_number_quality_update 参考文档:phone_number_quality_update Webhook 参考文档 | 开发者文档 (facebook.com)
安全 参考文档:安全 Webhook 参考文档 | 开发者文档 (facebook.com)
smb_app_state_sync 参考文档:smb_app_state_sync Webhook 参考文档 | 开发者文档 (facebook.com)
smb_message_echoes 参考文档:smb_message_echoes Webhook 参考文档 | 开发者文档 (facebook.com)
template_category_update 参考文档:template_category_update Webhook 参考文档 | 开发者文档 (facebook.com)
user_preferences 参考文档:user_preferences Webhook 参考文档 | 开发者文档 (facebook.com)
POST /whatsapp/uploadAttachment HTTP/1.1
Host: https://{your-domain}/api/open/v1
| 字段 | 类型 | 注释 |
| X-API-Key | string | 必填,API 密钥 |
{
“waba_id”: “1083606018111111”,
“file_type”: “image/jpeg”,
“file”: “文件流”,
“filename”: “文件名称”
}
| 字段 | 类型 | 注释 |
| waba_id | string | 是,WABA账户ID |
| file_type | string | 否,MIME类型 (可选,如 image/jpeg, video/mp4, audio/mpeg, application/pdf) |
| file | file | 是,multipart/form-data,file 字段上传附件 |
| filename | string | 否,文件名 |
{
“code”: 1,
“data”: {
“handle”: “4:MTIzMTIzMjE=:aW1hZ2UvcG5n:ARbZiIePV5AwoQsa1bD7GD47CUCMBdI2koNNbCCk1Z9z22tSoQOJl-qrzWfxt7r90K8C9FAiv-3HuPOqUR-hnAAW9jtj14rVGx31yeyvIFaepg:e:1789119311:708496041332449:61590501153676:ARazgi2rvF7LYOHPcJE”
},
“msg”: “OK”
}
| 字段 | 类型 | 注释 |
| code | int | 状态码 |
| msg | string | 提示信息 |
| data | object | 返回数据 |
| -handle | string | 媒体素材句柄 |
POST /whatsapp/uploadMedia HTTP/1.1
Host: https://{your-domain}/api/open/v1
| 字段 | 类型 | 注释 |
| X-API-Key | string | 必填,API 密钥 |
{
“phone_number_id”: “1083606018111111”,
“media_type”: “image/jpeg”,
“file”: “文件流”,
“url”: “文件地址”
}
| 字段 | 类型 | 注释 |
| phone_number_id | string | 是,WABA 手机号id |
| media_type | string | 否,MIME类型 (可选,如 image/jpeg, video/mp4, audio/mpeg, application/pdf) |
| file | file | 否,multipart/form-data,file 字段上传附件 |
| url | string | 否,附件URL (URL方式必填) |
{
“code”: 1,
“data”: {
“media_id”: “1543107790406532”
},
“msg”: “OK”
}
| 字段 | 类型 | 注释 |
| code | int | 状态码 |
| msg | string | 提示信息 |
| data | object | 返回数据 |
| -media_id | string | 素材id |
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 |
{
“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 |
{
“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 | 否,图片说明 |
{
“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 | 否,表情符号;不传则移除已有回应 |
POST /whatsapp/templates/delete HTTP/1.1
Host: https://{your-domain}/api/open/v1
| 字段 | 类型 | 注释 |
| X-API-Key | string | 必填,API 密钥 |
{“waba_id”: “918802267845274”, “hsm_id”: “960321963707594”}
或批量删除:
{“waba_id”: “918802267845274”, “hsm_ids”: [“960321963707594”, “1398810078762909”]}
| 字段 | 类型 | 注释 |
| waba_id | string | 是,WABA 账户 ID |
| template_name | string | 三选一,模板名称 |
| hsm_id | string | 三选一,模板 ID |
| hsm_ids | array | 三选一,模板 ID 列表,最多 100 个 |
{
“code”: 1,
“msg”: “OK”,
“data”: {}
}
| 字段 | 类型 | 注释 |
| code | int | 状态码 |
| msg | string | 提示信息 |
| data | object | 返回数据 |
POST /whatsapp/templates/update HTTP/1.1
Host: https://{your-domain}/api/open/v1
| 字段 | 类型 | 注释 |
| X-API-Key | string | 必填,API 密钥 |
| 字段 | 类型 | 注释 |
| template_id | string | 是,模板 ID |
| name | string | 否,模板名称 |
| category | string | 否,模板分类 |
| language | string | 否,语言代码 |
| components | array | 否,模板组件列表 |
| allow_category_change | bool | 否,是否允许分类变更 |
{
“code”: 1,
“msg”: “OK”,
“data”: {}
}
| 字段 | 类型 | 注释 |
| code | int | 状态码 |
| msg | string | 提示信息 |
| data | object | 返回数据 |
POST /whatsapp/templates/create HTTP/1.1
Host: https://{your-domain}/api/open/v1
| 字段 | 类型 | 注释 |
| X-API-Key | string | 必填,API 密钥 |
| 字段 | 类型 | 注释 |
| waba_id | string | 是,WABA 账户 ID |
| name | string | 是,模板名称(小写字母、数字、下划线) |
| category | string | 是,模板分类:MARKETING / UTILITY / AUTHENTICATION |
| language | string | 是,语言代码 规范:支持的语言 | 开发者文档 (facebook.com) |
| components | array | 是,模板组件列表 |
| allow_category_change | bool | 否,是否允许分类变更 |
[
{“type”: “HEADER”, “format”: “TEXT”, “text”: “标题文本”, “example”: {“header_text”: [“示例”]}},
{“type”: “BODY”, “text”: “正文内容,支持 {{1}} 变量”, “example”: {“body_text”: [[“变量1”, “变量2”]]}},
{“type”: “FOOTER”, “text”: “页脚文本”},
{“type”: “BUTTONS”, “buttons”: [
{“type”: “QUICK_REPLY”, “text”: “按钮文字”},
{“type”: “URL”, “text”: “访问网站”, “url”: “https://example.com”},
{“type”: “PHONE_NUMBER”, “text”: “拨打电话”, “phone_number”: “+15551234567”}
]}
]
组件类型说明: – HEADER – 头部(TEXT / IMAGE / VIDEO / DOCUMENT) – BODY – 正文(必填) – FOOTER – 页脚 – BUTTONS – 按钮组(QUICK_REPLY / URL / PHONE_NUMBER)
{
“code”: 1,
“msg”: “OK”,
“data”: {}
}
| 字段 | 类型 | 注释 |
| code | int | 状态码 |
| msg | string | 提示信息 |
| data | object | 返回数据 |
GET /whatsapp/templates HTTP/1.1
Host: https://{your-domain}/api/open/v1
| 字段 | 类型 | 注释 |
| X-API-Key | string | 必填,API 密钥 |
| 字段 | 类型 | 注释 |
| waba_id | string | 是,WABA 账户 ID |
| template_id | string | 否,模板 ID |
| page | int | 否,页码,默认 1 |
| limit | int | 否,每页条数,默认 10 |
| fields | string | 否,指定返回字段 |
可用 fields 字段:id, name, status, category, language, parameter_format, components, previous_category, sub_category, message_send_ttl_seconds, is_primary_device_delivery_only, is_sms_fallback_enabled, quality_score, health_status, source, rejected_reason, library_template_name, bid_spec, correct_category, cta_url_link_tracking_opted_out, degrees_of_freedom_spec, display_format, last_updated_time
{
“code”: 1,
“msg”: “OK”,
“data”: {
“data”: {
“0”: {
“id”: “960321963707594”,
“name”: “subsidy”,
“status”: “APPROVED”,
“category”: “MARKETING”,
“language”: “zh_CN”,
“parameter_format”: “NAMED”,
“message_send_ttl_seconds”: 86400,
“is_primary_device_delivery_only”: false,
“quality_score”: {“score”: “UNKNOWN”, “date”: 1784204376},
“source”: “manual”,
“components”: {
“0”: {“type”: “HEADER”, “format”: “IMAGE”, “example”: {“header_handle”: [“https://…”]}},
“1”: {“type”: “BODY”, “text”: “【河北省卫健委】您的{{subsidy_name}}已成功发送…”}
}
}
},
“total”: 7,
“per_page”: 10,
“current_page”: 1
}
}
| 字段 | 类型 | 注释 |
| id | string | 模板 ID |
| name | string | 模板名称 |
| status | string | 模板状态 |
| category | string | 模板分类 |
| language | string | 语言 |
| parameter_format | string | 参数格式 |
| message_send_ttl_seconds | int | 消息发送有效期(秒) |
| is_primary_device_delivery_only | bool | 是否仅主设备投递 |
| quality_score | object | 质量评分 |
| source | string | 来源 |
| components | array | 模板组件列表 |
| total | int | 总记录数 |
| per_page | int | 每页条数 |
| current_page | int | 当前页码 |
POST /whatsapp/phoneNumbers/requestCode HTTP/1.1
Host: https://{your-domain}/api/open/v1
| 字段 | 类型 | 注释 |
| X-API-Key | string | 必填,API 密钥 |
{
“phone_number_id”: “1906385232743451”,
“code_method”: “SMS”,
“language”: “en_US”
}
| 字段 | 类型 | 注释 |
| phone_number_id | string | 是,电话号码 ID |
| code_method | string | 否,验证码方式,默认 SMS,可选 SMS 或 VOICE |
| language | string | 否,语言,默认 en_US |
{
“code”: 1,
“msg”: “OK”,
“data”: {}
}
| 字段 | 类型 | 注释 |
| code | int | 状态码 |
| msg | string | 提示信息 |
| data | object | 返回数据 |