请求验证码

请求方式

POST /whatsapp/phoneNumbers/requestCode HTTP/1.1
Host: https://{your-domain}/api/open/v1

请求头

字段类型注释
X-API-Keystring必填,API 密钥

请求参数

{
  “phone_number_id”: “1906385232743451”,
  “code_method”: “SMS”,
  “language”: “en_US”
}

字段类型注释
phone_number_idstring是,电话号码 ID
code_methodstring否,验证码方式,默认 SMS,可选 SMS 或 VOICE
languagestring否,语言,默认 en_US

返回的结果

{
  “code”: 1,
  “msg”: “OK”,
  “data”: {}
}

字段类型注释
codeint状态码
msgstring提示信息
dataobject返回数据

注册验证电话号码 

请求方式

POST /whatsapp/phoneNumbers/registerPin HTTP/1.1
Host: https://{your-domain}/api/open/v1

请求头

字段类型注释
X-API-Keystring必填,API 密钥

请求参数

{
  “phone_number_id”: “1906385232743451”,
  “pin”: “123456”
}

字段类型注释
phone_number_idstring是,电话号码 ID
pinstring是,6位 PIN 码

返回的结果

{
  “code”: 1,
  “msg”: “OK”,
  “data”: {}
}

字段类型注释
codeint状态码
msgstring提示信息
dataobject返回数据

创建电话号码

请求方式

POST /whatsapp/phoneNumbers/register HTTP/1.1
Host: https://{your-domain}/api/open/v1

请求头

字段类型注释
X-API-Keystring必填,API 密钥

请求参数

{
  “waba_id”: “918802267845274”,
  “phone_number”: “+15551234567”,
  “verified_name”: “My Business”,
  “cc”: “US”,
  “migrate_phone_number”: false
}

字段类型注释
waba_idstring是,WABA 账户 ID
phone_numberstring是,电话号码
verified_namestring是,已验证名称
ccstring是,国家代码
migrate_phone_numberbool否,是否迁移电话号码,默认 false

返回的结果

{
  “code”: 1,
  “msg”: “OK”,
  “data”: {}
}

字段类型注释
codeint状态码
msgstring提示信息
dataobject返回数据

获取手机号列表

请求方式

GET /whatsapp/phoneNumbers HTTP/1.1
Host: https://{your-domain}/api/open/v1

请求头

字段类型注释
X-API-Keystring必填,API 密钥

请求参数

字段类型注释
waba_idstring是,WABA 账户 ID
pageint否,页码,默认 1
limitint否,每页条数,默认 10
fieldsstring否,指定返回字段

可用 fields 字段:id, display_phone_number, verified_name, status, quality_rating, country_code, country_dial_code, code_verification_status, account_mode, host_platform, messaging_limit_tier, is_official_business_account

返回的结果

{
  “code”: 1,
  “msg”: “OK”,
  “data”: {
    “data”: {
      “0”: {
        “id”: “1906385232743451”,
        “display_phone_number”: “+1 631-555-5555”,
        “verified_name”: “Jasper’s Market”,
        “status”: “CONNECTED”,
        “quality_rating”: “GREEN”,
        “country_code”: “US”,
        “country_dial_code”: “1”,
        “code_verification_status”: “VERIFIED”,
        “account_mode”: “LIVE”,
        “host_platform”: “CLOUD_API”,
        “messaging_limit_tier”: “TIER_1K”,
        “is_official_business_account”: true
      }
    },
    “total”: 1,
    “per_page”: 10,
    “current_page”: 1
  }
}

字段类型注释
idstring电话号码 ID
display_phone_numberstring显示电话号码
verified_namestring已验证名称
statusstring连接状态
quality_ratingstring质量评级
country_codestring国家代码
country_dial_codestring国家拨号代码
code_verification_statusstring验证码验证状态
account_modestring账户模式
host_platformstring托管平台
messaging_limit_tierstring消息发送限制层级
is_official_business_accountbool是否为官方商业账户
totalint总记录数
per_pageint每页条数
current_pageint当前页码

获取 WABA 账户信息

请求方式

GET /whatsapp/wabaInfo HTTP/1.1
Host: https://{your-domain}/api/open/v1

请求头

字段类型注释
X-API-Keystring必填,API 密钥

请求参数

字段类型注释
waba_idstring否,WABA账户ID,不传则返回该团队下所有WABA

返回的结果

{
  “code”: 1,
  “msg”: “OK”,
  “data”: {
    “id”: “1234567890123456”,
    “name”: “My Business WhatsApp Account”,
    “timezone_id”: “1”,
    “message_template_namespace”: “ba30dd89_2ebd_41e4_b805_f2c05ae04cc9”,
    “account_review_status”: “APPROVED”,
    “business_verification_status”: “VERIFIED”,
    “country”: “US”,
    “ownership_type”: “SELF”,
    “primary_business_location”: “US”
  }
}

注:查询全部时,data 为以索引为 key 的对象列表,例如:

{
  “code”: 1,
  “msg”: “OK”,
  “data”: {
    “0”: {“id”: “918802267845274”, “name”: “My Business”},
    “1”: {“id”: “918802267845275”, “name”: “Another Business”}
  }
}

字段类型注释
idstringWABA 账户 ID
namestring账户名称
timezone_idstring时区 ID
message_template_namespacestring消息模板命名空间
account_review_statusstring账户审核状态
business_verification_statusstring企业认证状态
countrystring国家代码
ownership_typestring所有权类型
primary_business_locationstring主要业务所在地

入门指导

概述

WhatsApp 开放 API 提供了一套完整的 WhatsApp Business API 接入能力,支持手机号管理、模板管理、消息发送、WABA 信息查询等功能。

先决条件:需要在JoinMC完成WABA账号申请,公司完成认证与账号状态正常,才能发送消息。申请WABA等操作指导可以查看帮助文档:https://www.kdocs.cn/l/cuxBnjmOoEtD

基础信息

  • Base URL: https://cn.joinmc.cn/api/open/v1
  • 认证方式: 请求头 X-API-Key: {your_secret_key}(从 JoinMC打开社交账号页面选择WhatsApp页签,点击页面右上角的API设置按钮后获取
  • Content-Type: application/json
  • 响应格式: JSON

通用响应结构

{
  “code”: 1,
  “msg”: “OK”,
  “data”: {  }
}

字段类型注释
codeint1-成功,0-失败,400-参数错误,401-认证失败,403-无权限,404-未找到
msgstring提示信息
dataobject/array返回数据

错误码说明

字段类型注释
1int成功
0int业务失败
400int参数错误
401int认证失败(API Key无效或缺失)
403int无权限访问该资源
404int资源未找到(WABA或手机号不存在)

注意事项

  1. 所有接口均需通过 X-API-Key 请求头认证,密钥从 JoinMC后台获取。
  2. 手机号列表接口会自动从 WhatsApp 官方同步最新数据。
  3. 模板列表接口会自动同步最新模板数据到本地库。
  4. 发送模板消息时,系统会自动判断是否收费并记录消费。
  5. 接口访问频率请合理控制,避免触发 WhatsApp 官方限制。

demo文件:demo py文件 请用python执