/v1/health
使用 health
节点可检查您的 WhatsApp Business API 客户端状态。
此 health
节点支持 Bearer 口令以及 API 密钥身份验证。
health
, metrics
, and stats
nodes from an orchestrator, Bearer tokens are not the best option for ongoing checks as they expire every 7 days. To mediate this, you can use an API key, which can be set using the WA_API_KEY
environment variable in the waweb
environment section in the .yml
file of your installation setup.
services: ... waweb: ... environment: ... WA_API_KEY: your-api-key-tokenThe API key you set must have a minimum of 12 characters and a maximum of 128 characters. The Webapp must be restarted whenever you change the API key.
对于您设置的 API 密钥而言,长度范围必须介于 12 个字符至 128 个字符之间。
向此节点发出 GET
调用,检索您的 WhatsApp Business API 客户端状态。
请求:
GET /v1/health { Authorization: Bearer your-auth-token | Apikey your-api-key-token }
该响应将向 WhatsApp 服务器提供网关的运行状况。如果 Authorization
标头不存在或是无效,系统将返回错误代码 401
。
{ "health": { "gateway_status": "connected | connecting | disconnected | uninitialized | unregistered" } }
{ "health": { "your-hostname1:your-container-id1": { "gateway_status": "connected | connecting | disconnected | uninitialized | unregistered", "role": "primary_master | secondary_master | coreapp" }, "your-hostname2:your-container-id2": { "gateway_status": "connected | connecting | disconnected | uninitialized | unregistered", "role": "primary_master | secondary_master | coreapp" }, } }
在高可用性模式下,仅有一个核心应用会连接到 Whatsapp 服务器;所有其他节点(包括主 Master)的 gateway_status
状态都将为 disconnected
。在采用 X
分片的多连接模式下, X 个
核心应用与主 Master 都将与 WhatsApp 服务器相连。
名称 | 描述 |
---|---|
类型:对象 | 包含描述 WhatsApp Business API 客户端运行状态的字段。 |
类型:字符串 | 核心应用与 WhatsApp 服务器之间的连接状态。 支持的值:
|
类型:字符串 | 高可用性/多连接设置中的容器身份。有关设置详情,请参阅可用性和扩展文档。 支持的值: |