/v2/customers/message/sendByAccessToken
POST /v2/customers/message/sendByAccessToken
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 users.
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 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" |
templates | Array<ContentTemplate> | Yes | A list of content templates of messages to send. The maximum array size is 5. | [     {       "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 | Yes | The request result, which contains information such as status and error codes. | { Â Â "resultCode": "SUCCESS", Â Â "resultStatus": "S", Â Â "resultMessage": "success" Â Â } | |
extendInfo | 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 message sending request is successful. The corresponding |
A | The request is accepted by wallets. The corresponding |
U | The API status is unknown.Â
The corresponding For details, see the Common error codes section. |
F | The message sending request fails. The corresponding |
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: the current OpenAPI does not have its dedicated error codes.
Sample
Request
{
"appId": "2171xxxxxxxxxxxx",
"accessToken": "2019112719074101000700000077771xxxx",
"templateCode": "2021xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"templates": [
{
"templateParameters": {
"who": "string to represent a name, e.g. XiaoMing",
"pushContentUrl": "http://redirecturl"
},
"language": "en-US"
}
]
}
For example, the message template includes: Hello, ${who}
, then the message will be like: Hello, XiaoMing
 .
Response
{
"result": {
"resultCode":"SUCCESS",
"resultStatus":"S"
}
}