WhatsApp Cloud API Skill
Use this skill to run WhatsApp Business Platform Cloud API operations through uxc + OpenAPI.
Reuse the uxc skill for shared execution, auth, and error-handling guidance.
Prerequisites
- -
uxc is installed and available in PATH. - Network access to
https://graph.facebook.com/v25.0. - Access to the curated OpenAPI schema URL:
-
https://raw.githubusercontent.com/holon-run/uxc/main/skills/whatsapp-openapi-skill/references/whatsapp-cloud.openapi.json
- - A Meta app and WhatsApp Business account with Cloud API access.
- A valid system-user or app access token that can call the target WhatsApp assets.
- At least one
phone_number_id, and for phone number listing, the related waba_id.
Scope
This skill covers a compact Cloud API request/response surface:
- - phone number listing
- phone number metadata reads
- business profile reads and updates
- outbound message sends
This skill does not cover:
- - inbound webhook receiver runtime
- template lifecycle management
- embedded signup or broader business onboarding flows
- media upload/download lifecycle
- the full WhatsApp Business Platform surface
API Version
This skill is pinned to Graph API v25.0, based on current Meta developer examples at implementation time. Keep the base URL versioned:
If Meta deprecates this version later, the wrapper should be revised in a follow-up update rather than assuming unversioned compatibility.
Authentication
WhatsApp Cloud API uses Authorization: Bearer <access_token>.
Configure one bearer credential and bind it to the versioned Graph API base path:
CODEBLOCK0
Validate the active mapping when auth looks wrong:
CODEBLOCK1
Core Workflow
- 1. Use the fixed link command by default:
-
command -v whatsapp-openapi-cli
- If missing, create it:
uxc link whatsapp-openapi-cli https://graph.facebook.com/v25.0 --schema-url https://raw.githubusercontent.com/holon-run/uxc/main/skills/whatsapp-openapi-skill/references/whatsapp-cloud.openapi.json
- INLINECODE13
- 2. Inspect operation schema first:
-
whatsapp-openapi-cli get:/{waba_id}/phone_numbers -h
-
whatsapp-openapi-cli get:/{phone_number_id}/whatsapp_business_profile -h
- INLINECODE16
- 3. Prefer read/setup validation before writes:
-
whatsapp-openapi-cli get:/{waba_id}/phone_numbers waba_id=123456789012345
-
whatsapp-openapi-cli get:/{phone_number_id} phone_number_id=123456789012345
- INLINECODE19
- 4. Execute with key/value or positional JSON:
- key/value:
whatsapp-openapi-cli get:/{phone_number_id} phone_number_id=123456789012345 fields=display_phone_number,verified_name
- positional JSON:
INLINECODE21
Operation Groups
Asset Discovery
- - INLINECODE22
- INLINECODE23
Business Profile
- - INLINECODE24
- INLINECODE25
Messaging
Guardrails
- - Keep automation on the JSON output envelope; do not use
--text. - Parse stable fields first:
ok, kind, protocol, data, error. - INLINECODE33 is a high-risk write. Require explicit user confirmation before execution.
- Message delivery is still constrained by WhatsApp conversation rules, template approval rules, recipient opt-in expectations, and account policy state. Auth success does not imply a send is allowed.
- This v1 skill does not manage media uploads. If you send
image or document content, use already hosted URLs or existing asset references as allowed by the platform. - Webhook subscription and verification are intentionally documented only. This skill does not configure a receiver runtime.
- Business profile update fields are partial. Only send the fields you intend to change.
- INLINECODE36 is equivalent to
uxc https://graph.facebook.com/v25.0 --schema-url <whatsapp_openapi_schema> <operation> ....
References
- - Usage patterns: INLINECODE38
- Curated OpenAPI schema: INLINECODE39
- WhatsApp Cloud API docs: https://developers.facebook.com/docs/whatsapp/cloud-api
- Graph API access tokens: https://developers.facebook.com/docs/graph-api/overview/access-tokens/
WhatsApp Cloud API 技能
使用此技能通过 uxc + OpenAPI 运行 WhatsApp Business Platform Cloud API 操作。
复用 uxc 技能以获取共享执行、身份验证和错误处理指导。
前提条件
- - uxc 已安装并可在 PATH 中使用。
- 可访问 https://graph.facebook.com/v25.0 网络。
- 可访问精选的 OpenAPI 模式 URL:
- https://raw.githubusercontent.com/holon-run/uxc/main/skills/whatsapp-openapi-skill/references/whatsapp-cloud.openapi.json
- - 拥有一个具有 Cloud API 访问权限的 Meta 应用和 WhatsApp Business 账户。
- 拥有一个有效的系统用户或应用访问令牌,可调用目标 WhatsApp 资产。
- 至少有一个 phonenumberid,对于电话号码列表,还需要相关的 waba_id。
范围
此技能涵盖紧凑的 Cloud API 请求/响应接口:
- - 电话号码列表
- 电话号码元数据读取
- 商业资料读取和更新
- 出站消息发送
此技能不涵盖:
- - 入站 Webhook 接收器运行时
- 模板生命周期管理
- 嵌入式注册或更广泛的业务入驻流程
- 媒体上传/下载生命周期
- 完整的 WhatsApp Business Platform 接口
API 版本
此技能固定使用 Graph API v25.0,基于实现时当前的 Meta 开发者示例。请保持基础 URL 带版本号:
- - https://graph.facebook.com/v25.0
如果 Meta 后续弃用此版本,应在后续更新中修订封装器,而不是假设无版本兼容性。
身份验证
WhatsApp Cloud API 使用 Authorization: Bearer 。
配置一个 Bearer 凭证并将其绑定到带版本的 Graph API 基础路径:
bash
uxc auth credential set whatsapp-cloud \
--auth-type bearer \
--secret-env WHATSAPPCLOUDACCESS_TOKEN
uxc auth binding add \
--id whatsapp-cloud \
--host graph.facebook.com \
--path-prefix /v25.0 \
--scheme https \
--credential whatsapp-cloud \
--priority 100
当身份验证出现问题时,验证活动映射:
bash
uxc auth binding match https://graph.facebook.com/v25.0
核心工作流程
- 1. 默认使用固定链接命令:
- command -v whatsapp-openapi-cli
- 如果缺失,创建它:
uxc link whatsapp-openapi-cli https://graph.facebook.com/v25.0 --schema-url https://raw.githubusercontent.com/holon-run/uxc/main/skills/whatsapp-openapi-skill/references/whatsapp-cloud.openapi.json
- whatsapp-openapi-cli -h
- 2. 首先检查操作模式:
- whatsapp-openapi-cli get:/{waba
id}/phonenumbers -h
- whatsapp-openapi-cli get:/{phone
numberid}/whatsapp
businessprofile -h
- whatsapp-openapi-cli post:/{phone
numberid}/messages -h
- 3. 在写入前优先进行读取/设置验证:
- whatsapp-openapi-cli get:/{waba
id}/phonenumbers waba_id=123456789012345
- whatsapp-openapi-cli get:/{phone
numberid} phone
numberid=123456789012345
- whatsapp-openapi-cli get:/{phone
numberid}/whatsapp
businessprofile phone
numberid=123456789012345
- 4. 使用键/值或位置 JSON 执行:
- 键/值:
whatsapp-openapi-cli get:/{phone
numberid} phone
numberid=123456789012345 fields=display
phonenumber,verified_name
- 位置 JSON:
whatsapp-openapi-cli post:/{phone
numberid}/messages {phone
numberid:123456789012345,messaging_product:whatsapp,to:15551234567,type:text,text:{body:Hello from UXC}}
操作组
资产发现
- - get:/{wabaid}/phonenumbers
- get:/{phonenumberid}
商业资料
- - get:/{phonenumberid}/whatsappbusinessprofile
- post:/{phonenumberid}/whatsappbusinessprofile
消息发送
- - post:/{phonenumberid}/messages
防护措施
- - 保持自动化在 JSON 输出信封上;不要使用 --text。
- 首先解析稳定字段:ok、kind、protocol、data、error。
- post:/{phonenumberid}/messages 是高风险的写入操作。执行前需要明确的用户确认。
- 消息投递仍受 WhatsApp 对话规则、模板审批规则、收件人选择加入期望和账户政策状态的约束。身份验证成功并不意味着允许发送。
- 此 v1 技能不管理媒体上传。如果发送 image 或 document 内容,请使用平台允许的已托管 URL 或现有资产引用。
- Webhook 订阅和验证仅作为文档记录。此技能不配置接收器运行时。
- 商业资料更新字段是部分的。只发送您打算更改的字段。
- whatsapp-openapi-cli ... 等同于 uxc https://graph.facebook.com/v25.0 --schema-url openapischema> ...。
参考
- - 使用模式:references/usage-patterns.md
- 精选的 OpenAPI 模式:references/whatsapp-cloud.openapi.json
- WhatsApp Cloud API 文档:https://developers.facebook.com/docs/whatsapp/cloud-api
- Graph API 访问令牌:https://developers.facebook.com/docs/graph-api/overview/access-tokens/