/v2/messages/sendInbox
Note: This API is no longer maintained. All the functionalities of this API have been migrated to the
/v2/miniprogram/message/send/
API. We recommend you to utilize the/v2/miniprogram/message/send/
API for new features or enhancements.
POST /v2/messages/sendInbox
The sendInbox
API is used for merchants or Independent Software Vendors (ISV) to send inbox messages to wallets by using access tokens.
Message structure
Request
Property | Data type | Required | Description | Example |
accessToken | String | Yes | An access token that is used to send inbox messages. Max. length: 128 characters. | "2019112719074101000700000077771xxxx" |
authClientId | String | No | The unqiue auth client ID Max. length: 128 characters. | "202016726873874774774xxxx" |
requestId | String | Yes | The unqiue ID to identifiy a request at a transaction. It is idempotent, whichi means if the API call has the same result no matter how many times the API call is applied. For example, if there is the same Max. length: 128 characters. | "20191127190741010007013213123xxxx" |
templateCode | String | Yes | An unique code to distinguish different content templates. Max. length: 256 characters. | "TP_5800000001xxxx" |
templates | Array<ContentTemplate> | Yes | A list of content templates of inbox 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 extensive information. The wallets and merchants can add additional information in this property. Max. length: 4096 characters. | "This is additional information" |
Response
Property | Data type | Required | Description | Example |
result | Yes | The request result, which contains information like status and error codes. | { "resultCode":"SUCCESS", "resultStatus":"S", "resultMessage":"success" } | |
messageId | String | No | The unqiue ID to identify a message. Max. length: 258 characters. | "20201235900212xxxx" |
extendInfo | String | No | The additionally extensive information. 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 | It means that sending inbox messages via access tokens is successful. The corresponding |
A | The request is accepted by wallets. The corresponding |
U | It means unknown exception occur on wallet side, the merchant or ISV may try again. The corresponding For details, see the Common error codes section. |
F | It means that sending inbox messages via access tokens 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: are listed in the following table.
resultStatus | resultCode | resultMessage | Further action |
F | INVALID_ACCESS_TOKEN | The access token is invalid. | Restart the OAuth again or refresh the token and try again. |
F | INVALID_AUTH_CLIENT | The authentication client ID is invalid. | The authClientId is the appId for mini programs. Check if the appId is correct; if yes, contact your service provider. |
F | USER_STATUS_ERROR | The user account status is wrong. | The user account might be locked or unregistered. |
F | VERIFY_REQUEST_ID_INVALID | The request ID is invalid. | Check the format of the requestId and try again. |
Sample
- Merchants send a request to send inbox messages to wallets by an access token
- Wallets returns a
messsageId
to merchants
Request
{
"accessToken": "2019112719074101000700000077771xxxx",
"authClientId": "202016726873874774774xxxx",
"requestId": "20191127190741010007013213123xxxx",
"templateCode": "TP_5800000001xxxx",
"templates": [
{
"templateParameters": {
"who": "string to represent a name"
},
"language": "en-US"
}
],
"extendInfo": "This is additional information"
}
Response
{
"messageId": "20201235900212xxxx",
"extendInfo": "This is additional information",
"result": {
"resultCode":"SUCCESS",
"resultStatus":"S",
"resultMessage":"success"
}
}