|
通过托管认证访问 WATI(WhatsApp 团队收件箱)API。发送 WhatsApp 消息、管理联系人以及处理消息模板。
bash
https://gateway.maton.ai/wati/{native-api-path}
将 {native-api-path} 替换为实际的 WATI API 端点路径。网关将请求代理到您的 WATI 实例,并自动注入您的 API 令牌。
所有请求都需要在 Authorization 标头中包含 Maton API 密钥:
Authorization: Bearer $MATONAPIKEY
环境变量: 将您的 API 密钥设置为 MATONAPIKEY:
bash
export MATONAPIKEY=YOURAPIKEY
在 https://ctrl.maton.ai 管理您的 WATI 连接。
bash
python <
req = urllib.request.Request(https://ctrl.maton.ai/connections?app=wati&status=ACTIVE)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
bash
python <
data = json.dumps({app: wati}).encode()
req = urllib.request.Request(https://ctrl.maton.ai/connections, data=data, method=POST)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
req.add_header(Content-Type, application/json)
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
bash
python <
req = urllib.request.Request(https://ctrl.maton.ai/connections/{connection_id})
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
响应:
json
{
connection: {
connection_id: 21fd90f9-5935-43cd-b6c8-bde9d915ca80,
status: ACTIVE,
creation_time: 2025-12-08T07:20:53.488460Z,
lastupdatedtime: 2026-01-31T20:03:32.593153Z,
url: https://connect.maton.ai/?session_token=...,
app: wati,
metadata: {}
}
}
在浏览器中打开返回的 url 以完成授权。
bash
python <
req = urllib.request.Request(https://ctrl.maton.ai/connections/{connection_id}, method=DELETE)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
如果您有多个 WATI 连接,请使用 Maton-Connection 标头指定要使用的连接:
bash
python <
req = urllib.request.Request(https://gateway.maton.ai/wati/api/v1/getContacts?pageSize=10&pageNumber=1)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
req.add_header(Maton-Connection, 21fd90f9-5935-43cd-b6c8-bde9d915ca80)
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
如果省略,网关将使用默认(最旧)的活动连接。
bash
GET /wati/api/v1/getContacts?pageSize=10&pageNumber=1
查询参数:
属性运算符: contain、notContain、exist、notExist、==、!=、valid、invalid
bash
POST /wati/api/v1/addContact/{whatsappNumber}
Content-Type: application/json
{
name: John Doe,
customParams: [
{
name: member,
value: VIP
}
]
}
bash
POST /wati/api/v1/updateContactAttributes/{whatsappNumber}
Content-Type: application/json
{
customParams: [
{
name: member,
value: VIP
}
]
}
bash
GET /wati/api/v1/getMessages/{whatsappNumber}?pageSize=10&pageNumber=1
查询参数:
在活动会话中发送文本消息(24小时窗口):
bash
POST /wati/api/v1/sendSessionMessage/{whatsappNumber}
Content-Type: application/x-www-form-urlencoded
messageText=Hello%20from%20WATI!
在活动会话中发送文件:
bash
POST /wati/api/v1/sendSessionFile/{whatsappNumber}?caption=Check%20this%20out
Content-Type: multipart/form-data
file=@document.pdf
bash
GET /wati/api/v1/getMessageTemplates?pageSize=10&pageNumber=1
向单个联系人发送预批准的模板消息:
bash
POST /wati/api/v1/sendTemplateMessage?whatsappNumber={whatsappNumber}
Content-Type: application/json
{
templatename: orderupdate,
broadcastname: orderupdate,
parameters: [
{
name: name,
value: John
},
{
name: ordernumber,
value: 12345
}
]
}
向多个联系人发送模板消息:
bash
POST /wati/api/v1/sendTemplateMessages
Content-Type: application/json
{
templatename: orderupdate,
broadcastname: orderupdate,
receivers: [
{
whatsappNumber: 14155551234,
customParams: [
{
name: name,
value: John
},
{
name: ordernumber,
value: 12345
}
]
},
{
whatsappNumber: 14155555678,
customParams: [
{
name: name,
value: Jane
},
{
name: ordernumber,
value: 67890
}
]
}
]
}
bash
POST /wati/api/v1/sendTemplateMessageCSV?templatename=orderupdate&broadcastname=orderupdate
Content-Type: multipart/form-data
whatsappnumberscsv=@contacts.csv
v2 API 提供了增强的响应格式,包含消息跟踪 ID。
bash
POST /wati/api/v2/sendTemplateMessage?whatsappNumber={whatsappNumber}
Content-Type: application/json
{
templatename: orderupdate,
broadcast_name:
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 wati-1776102549 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 wati-1776102549 技能
skillhub install wati-1776102549
文件大小: 4.81 KB | 发布时间: 2026-4-15 14:54