服务端 REST API 概述

JSMS 提供遵从 REST 规范的 HTTP API,以供开发者远程调用 JSMS 提供的服务。

与此同时,为方便开发者使用 JSMS API,还提供多种常用编程语言的开发包(SDK)


REST API 基本约束

  • API 被设计为符合 HTTP, REST 规范。例如:查询请求使用 Get 方法,提交请求使用 Post 方法。如果一个请求不是相应的 HTTP 方法,将返回错误。
  • 如无特殊说明,调用参数值应转码为:UTF-8, URL编码 [^1]。

    [1]: URL编码 - WikiPedia定义


API 资源列表

短信发送 API

短信定时发送 API

短信余量查询 API


返回码

若请求失败,API 会返回如下 JSON 格式的返回码及说明

  1. {
  2. "error": {
  3. "code": *****,
  4. "message": "*****"
  5. }
  6. }

REST API 返回码汇总

HTTP CODE CODE MESSAGE DESC
200 50000 success 请求成功
400 50001 missing auth auth 为空
401 50002 auth failed auth 鉴权失败
400 50003 missing body body 为空
400 50004 missing mobile 手机号码为空
400 50005 missing temp_id 模版ID 为空
403 50006 invalid mobile 手机号码无效
403 50007 invalid body body 无效
403 50008 no sms code auth 未开通短信业务
403 50009 out of freq 下发超频
403 50010 invalid code 验证码无效
403 50011 expired code 验证码过期
403 50012 verified code 验证码已验证过
403 50013 invalid temp_id 模版ID 无效
403 50014 no money 可发短信余量不足
400 50015 missing code 验证码为空
404 50016 api not found API 不存在
415 50017 media not supported 媒体类型不支持
405 50018 request method not support 请求方法不支持
500 50019 server error 服务端异常
403 50020 template auditing 模板审核中
403 50021 template not pass 模板审核未通过
403 50022 parameters not all replaced 模板中参数未全部替换
403 50023 parameters is empty 参数为空
403 50024 unsubscribed mobile 手机号码已退订
403 50025 wrong template type 该 API 不支持此模版类型
403 50026 wrong msg_id msg_id 无效
403 50027 invalid send_time send_time 为空或在当前时间之前
403 50028 invalid schedule_id schedule_id 无效
403 50029 wrong schedule status 定时短信已发送或已删除,无法再修改
403 50030 recipients is empty recipients 为空
403 50031 too much recipients recipients 短信接收者数量超过1000
403 50034 repeat send 重复发送
403 50035 illegal IP 非法 IP 请求
403 50036 app in black 应用被列为黑名单
403 50037 has black word 短信内容存在敏感词汇
403 50038 invalid content length 短信内容长度错误,文本短信长度不超过350个字,语音短信验证码长度4~8数字
403 50039 invalid code type 语音验证码内容错误,验证码仅支持数字
403 50040 invalid voice language type 语音验证码播报语言类型错误
403 50041 invalid ttl value 验证码有效期错误
403 50042 template is empty 模板内容为空
403 50043 template too long 模板内容过长,含签名长度限制为350字符
403 50044 template parameter invalid 模板参数无效
403 50045 remark too long 备注内容过长,长度限制为500字符
403 50046 signature not set 该应用未设置签名,请先设置签名
403 50047 modify template not allow 只有审核不通过状态的模板才允许修改
403 50052 template contains special symbol 模板不能含有特殊符号,如【】 
403 50053 special template parameter need extra remark for confirmation 模板中存在链接变量,请在 remark 参数中填写链接以报备,避免短信发送时因进入人工审核而导致发送延迟
403 50054 content contains special symbol 短信正文不能含有特殊符号,如【】
403 50101 invalid image 非法的图片
403 50102 invalid sign id 非法的签名 ID 
403 50103 other signatures in the audit 已经存在其他待审核的签名,不能提交
403 50104 invalid signature 非法签名内容
403 50105 default signature cannot be deleted 默认签名不能删除