API概述

知我云SMS提供简单易用的HTTP API接口,支持短信发送、查询等功能。

  • 接口协议:HTTPS
  • 请求方式:POST
  • 数据格式:JSON
  • 字符编码:UTF-8

认证方式

所有API请求需要在请求头中携带认证信息:

{
  "username": "your_username",
  "password": "md5(your_password)",
  "tKey": "timestamp"
}

说明:

  • username: 您的账号用户名
  • password: 密码的MD5值(32位小写)
  • tKey: 当前时间戳(秒)

模板短信发送

POST /api/v1/sendSmsTp

请求参数

参数名 类型 必填 说明
mobile string 手机号
tpId string 模板ID
signature string 签名(含【】)
tpContent object 模板变量

请求示例

{
  "username": "test_user",
  "password": "c36be9377fab8270c4507d65d852fa6b",
  "tKey": "1234567890",
  "mobile": "13800138000",
  "tpId": "123456",
  "signature": "【知我云】",
  "tpContent": {
    "code": "123456"
  }
}

响应示例

{
  "code": 200,
  "msg": "发送成功",
  "data": {
    "msgId": "msg_1234567890"
  }
}

批量发送短信

POST /api/v1/sendSmsTp

说明:批量发送使用相同的接口,通过 records 数组传入多个手机号即可。

请求示例

{
  "username": "test_user",
  "password": "c36be9377fab8270c4507d65d852fa6b",
  "tKey": "1234567890",
  "tpId": "123456",
  "signature": "【知我云】",
  "records": [
    {
      "mobile": "13800138000",
      "tpContent": {
        "code": "123456"
      }
    },
    {
      "mobile": "13800138001",
      "tpContent": {
        "code": "654321"
      }
    }
  ]
}

查询余额

POST /api/v1/user/balance

响应示例

{
  "code": 200,
  "msg": "success",
  "data": {
    "balance": 1000.00,
    "currency": "CNY"
  }
}

错误码说明

错误码 说明
200成功
400参数错误
401认证失败
403余额不足
404资源不存在
500服务器错误