跳到主要内容

批量发送短信-SendBatchUSMSMessage

支持在一次请求中向多个不同的手机号码发送不同内容的短信;在一次批量请求中,最多支持 200 个号码;更多接口说明,详见 短信服务 API 概览

Request Parameters

Parameter nameTypeDescriptionRequiredRemark
ActionString对应的 API 名称,SendBatchUSMSMessageYes公共参数
PublicKeyString对应的 API 公钥Yes公共参数
SignatureString根据 API 公私钥及 API 指令生成的用户签名,参见 签名算法Yes公共参数
ProjectIdstring服务账号 ID,主账号与财务账号为空时为 默认服务账号;子账号为必填字段,参见 获取 服务账号 IDYes公共参数
TaskContentstring批量发送参数,base64 编码后的 json 数组,编码前后的 json 数组参考下述示例:
Base64 编码前的 TaskContent 示例Base64 编码后的 TaskContent 示例
Yes
  • TaskContent(Base64 编码前)
Parameter nameTypeDescriptionCaseRequired
TemplateIdstring短信模板 IDUTB20092XXXXD02Yes
SigContentstring短信签名UMCloudYes
TargetArray号码及短信内容组合列表Yes
  • Target(Base64 编码前)
Parameter nameTypeDescriptionCaseRequired
TemplateParamsArray短信模板中的变量(数组格式)["UMCloud","13455"]Yes
Phonestring手机号码,手机号码格式为(60)1xxxxxxxx,()中为国际长途区号(如中国为 86 或 0086,两种格式都支持),后面为电话号码.若不传入国际区号,如 185XXXX0507,则默认为国内手机号185XXXX0507Yes
UserIdstring自定义的业务标识 ID,字符串( 长度不能超过 32 位),不支持 单引号、表情包符号等特殊字符umcloud-uhost-001No
ExtendCodestring短信扩展码,格式为阿拉伯数字串,默认不开通,如需开通请联系 UMCloud 技术支持123No

TaskContent 示例(Base64 编码前)

[
{
"TemplateId": "UTA20212831C85C",
"SigContent": "UMCloud",
"Target": [
{
"TemplateParams": ["顶级钻石用户刘大锤", "24680"],
"Phone": "185XXXX0507",
"UserId": "you man c define the content by yrself"
},
{
"TemplateParams": ["开心果挖土机", "13579"],
"Phone": "185XXXX0608",
"ExtendCode": "123",
"UserId": "catch the big fish"
}
]
}
]

TaskContent 示例(Base64 编码后)

WwogICAgewogICAgICAgICJUZW1wbGF0ZUlkIjoiVVRBMjAyMTI4MzFDODVDIiwKICAgICAgICAiU2lnQ29udGVudCI6IlVDbG91ZCIsCiAgICAgICAgIlRhcmdldCI6WwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAiVGVtcGxhdGVQYXJhbXMiOlsKICAgICAgICAgICAgICAgICAgICAi6aG257qn6ZK755+z55So5oi35YiY5aSn6ZSkIiwKICAgICAgICAgICAgICAgICAgICAiMjQ2ODAiCiAgICAgICAgICAgICAgICBdLAogICAgICAgICAgICAgICAgIlBob25lIjoiMTg1WFhYWDA1MDciLAogICAgICAgICAgICAgICAgIlVzZXJJZCI6InlvdSBtYW4gYyBkZWZpbmUgdGhlIGNvbnRlbnQgYnkgeXJzZWxmIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAiVGVtcGxhdGVQYXJhbXMiOlsKICAgICAgICAgICAgICAgICAgICAi5byA5b+D5p6c5oyW5Zyf5py6IiwKICAgICAgICAgICAgICAgICAgICAiMTM1NzkiCiAgICAgICAgICAgICAgICBdLAogICAgICAgICAgICAgICAgIlBob25lIjoiMTg1WFhYWDA2MDgiLAogICAgICAgICAgICAgICAgIkV4dGVuZENvZGUiOiIxMjMiLAogICAgICAgICAgICAgICAgIlVzZXJJZCI6ImNhdGNoIHRoZSBiaWcgZmlzaCIKICAgICAgICAgICAgfQogICAgICAgIF0KICAgIH0KXQ==

Response Elements

Parameter nameTypeDescriptionRequired
RetCodeint返回状态码,为 0 则为成功返回,非 0 为失败Yes
Actionstring操作指令名称Yes
Messagestring返回错误消息,当 RetCode 非 0 时提供详细的描述信息Yes
SessionNostring本次提交发送任务的唯一 ID,可根据该值查询本次发送的短信列表。注:成功提交短信数大于 0 时,才返回该字段No
ReqUuidstring本次请求 UuidNo
SuccessCountint成功提交短信(未拆分)条数No
FailContentarray未发送成功的详情,返回码非 0 时该字段有效,可根据该字段数据重发No

BatchInfo

Parameter nameTypeDescriptionRequired
TemplateIdstring短信模板 IDYes
SigContentstring短信签名Yes
Targetarray具体手机号码、模板变量等信息组合Yes
FailureDetailsstring未能成功发送的详情。注:模板/签名检验失败时,该字段有效No

FailPhoneDetail

Parameter nameTypeDescriptionRequired
TemplateParamsarray短信模板参数Yes
Phonestring手机号Yes
ExtendCodestring扩展号码No
UserIdstring用户自定义 IDNo
FailureDetailsstring发送失败原因。注:若模板/签名校验失败,该字段为空No

Request Example

https://api.ucloud.cn/?Action=SendBatchUSMSMessage
&PublicKey=vsRhB0Qzo9elXXXXXkw8o/vmss8Tb0vxi74A=
&Signature=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
&ProjectId=org1234
&TaskContent=WwogICAgewogICAgICAgICJUZW1wbGF0ZUlkIjoiVVRBMjAyMTI4MzFDODVDIiwKICAgICAgICAiU2lnQ29udGVudCI6IlVDbG91ZCIsCiAgICAgICAgIlRhcmdldCI6WwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAiVGVtcGxhdGVQYXJhbXMiOlsKICAgICAgICAgICAgICAgICAgICAi6aG257qn6ZK755+z55So5oi35YiY5aSn6ZSkIiwKICAgICAgICAgICAgICAgICAgICAiMjQ2ODAiCiAgICAgICAgICAgICAgICBdLAogICAgICAgICAgICAgICAgIlBob25lIjoiMTg1WFhYWDA1MDciLAogICAgICAgICAgICAgICAgIlVzZXJJZCI6InlvdSBtYW4gYyBkZWZpbmUgdGhlIGNvbnRlbnQgYnkgeXJzZWxmIgogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAiVGVtcGxhdGVQYXJhbXMiOlsKICAgICAgICAgICAgICAgICAgICAi5byA5b+D5p6c5oyW5Zyf5py6IiwKICAgICAgICAgICAgICAgICAgICAiMTM1NzkiCiAgICAgICAgICAgICAgICBdLAogICAgICAgICAgICAgICAgIlBob25lIjoiMTg1WFhYWDA2MDgiLAogICAgICAgICAgICAgICAgIkV4dGVuZENvZGUiOiIxMjMiLAogICAgICAgICAgICAgICAgIlVzZXJJZCI6ImNhdGNoIHRoZSBiaWcgZmlzaCIKICAgICAgICAgICAgfQogICAgICAgIF0KICAgIH0KXQ==

Response Example

{
"RetCode": 0,
"Action": "SendBatchUSMSMessageResponse",
"Message": "submit success",
"SessionNo": "abcd-dadd-dafs-dadfa-dafdsa",
"ReqUuid": "abcd-dadd-dafs-dadfa-dafdsa",
"SuccessCount": 2,
"FailContent": [
{
"TemplateId": "UTA20212831C85C",
"SigContent": "UMCloud",
"Target": [
{
"TemplateParams": ["开心果挖土机", "13579"],
"Phone": "185XXXX0608",
"ExtendCode": "123",
"UserId": "catch the big fish"
}
],
"FailureDetails": "phone in the black list"
}
]
}