/v2/miniprogram/message/send

POST /v2/miniprogram/message/send

The send API is used for Mini Program to allow merchants or Independent Software Vendors (ISV) to configure message templates, which faciliates merchants or ISV to send good-looking messages to wallets.

Message structure

Request

Property

Data type

Required

Description

Example

appId

String 

Yes

In Mini Program, the app ID.

Max. length: 32 characters.

"P000000000000001xxxx"

accessToken

String 

Yes

An access token that is used to access the user resource scope.

Max. length: 128 characters.

"2019112719074101000700000077771xxxx"

requestId

String 

Yes

A unique ID associated with a message.

For example, using this API to send a notification when the user completes a payment through the Mini Program, the value of the requestId can be the tradeNo .

Max. length: 64 characters.

"20191127190741010007013213123xxxx"

templateCode

String 

Yes

The template that the merchant or ISV selects on the Mini Program SaaS portal. The message is sent based on the selected template.

Max. length: 64 characters.

"TP_5800000001xxxx"

redirectUrl

String   

No

The Mini Program page that is redirected to after the user clicks the PUSH/INBOX message. Therefore, for the PUSH/INBOX message only, this property is required.

Max. length: 2048 characters.

"/page/dasdas/12312"

templates

Array<ContentTemplate>

Yes

A list of content templates of messages to send. The maximum array size is five.

[

       {

           "templateParameters": {

               "who": "string to represent a name, e.g. XiaoMing"

           },

           "language": "en-US"

       }

   ]

extendInfo

String 

No

The additionally extensive information to add.

Max. length: 4096 characters.

"This is additional information"

Response

Property

Data type

Required

Description

Example

result

Result

Yes

The request result, which contains information such as status and error codes.

{

   "resultCode": "SUCCESS",

   "resultStatus": "S",

   "resultMessage": "success"  

 }

entendInfo

String

No

The additionally extensive information to add.

Max. length: 4096 characters.

"This is additional information"

Result process logic

In the response, the result.resultStatus field indicates the result of processing a request as follows.

resultStatus

Decription 

S

The request is sent successful. 

The corresponding result.resultCode is "SUCCESS" and the  result.resultMessage  is "Success".

U

The API status is unknown. 

The corresponding result.resultCode is "UNKNOWN_EXCEPTION" and result.resultMessage  is "An API calling is failed, which is caused by unknown reasons.".

For details, see the Common error codes section.

F

The request fails to send. The corresponding result.resultCode  and result.resultMessage vary based on different situations. For details, see the following Error codes section.

Error codes

Error codes are usually classified into the following categories:

  • Common error codes: are common for all Mini Program OpenAPIs.  
  • API-specific error codes: this OpenAPI does not have its dedicated error codes.

Sample

/v2/miniprogram/message/send

Request

copy
{
    "appId": "P000000000000001xxxx",
    "accessToken": "2019112719074101000700000077771xxxx",
    "redirectUrl": "20191127190741010007013213123xxxx",
    "templateCode": "TP_5800000001xxxx",
    "actionUrl":"/page/dasdas/12312",
    "templates": [
        {
            "templateParameters": {
                "who": "string to represent a name, e.g. XiaoMing"
            },
            "language": "en-US"
        }
    ]
}

For example, the message template includes: Hello, ${who}, then the message will be like: Hello, XiaoMing .

Response

copy
{
 "result": {
    "resultCode":"SUCCESS",
    "resultStatus":"S"
 }
}