This API should be called on the server side and cannot be called directly on the client side (Mini Program, web page, APP, etc.). For details, please refer to API Call Guide.
API English Name: sendHardwareDeviceMessage
Send a device message to the user through this API.
1. Call Method
HTTPS Call
POST https://api.weixin.qq.com/cgi-bin/message/device/subscribe/send?access_token=ACCESS_TOKEN
Cloud Call
- This API does not support cloud call.
Third-party Call
-
This API supports third-party platforms on behalf of Merchant call.
-
The permission set ID of this API is: 118
-
After the service provider obtains one of the permission set authorizations, it can use authorizer_access_token to call on behalf of Merchant, for details please refer to Third-party Call documentation.
2. Request Parameters
Query Parameters Query String Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| access_token | string | Yes | API call credential, you can use access_token, authorizer_access_token |
Request Body Request Payload
| Parameter | Type | Required | Description |
|---|---|---|---|
| template_id | string | Yes | The ID of the subscription template to be delivered. |
| sn | string | Yes | The unique serial number of the device. Assigned by the manufacturer, with a length not exceeding 128 bytes. Characters must be limited to digits, uppercase and lowercase letters, underscores (_), and hyphens (-). |
| page | string | Yes | The page to navigate to after clicking the template card. Limited to pages within this Mini Program. Supports parameters (e.g., index?foo=bar). If this field is empty, the template will have no navigation. |
| to_openid_list | array | Yes | List of openid values for the recipients (users). |
| miniprogram_state | string | No | The Mini Program version type for navigation: developer for the Development version; trial for the Trial version; formal for the Release version. The default is the Release version. |
| modelId | string | Yes | The device model ID, obtained during device registration. |
| data | string | Yes | This is an object, not a string. The template content, in the format { "key1": { "value": "xxx" }, "key2": { "value": "xxx" } }, where value is an enum value. |
| lang | string | Yes | The language type for the "Go to Mini Program " text. Supports zh_CN (Simplified Chinese), en_US (English), zh_HK (Traditional Chinese), and zh_TW (Traditional Chinese). The default is zh_CN. |
3. Response Parameters
Response Body Response Payload
| Parameter | Type | Description |
|---|---|---|
| errcode | number | Error code |
| errmsg | string | Error message |
4. Notes
Call limit: 10,000,000 per day.
5. Code Example
Request Example
{
"to_openid_list": [
"OPENID_1",
"OPENID_2"
],
"sn": "XXXXXXX",
"template_id": "TEMPLATE_ID",
"page": "index",
"miniprogram_state": "formal",
"lang": "zh_CN",
"data": {
"time1": {
"value": "2021-09-10 19:00:00"
}
}
}
Response Example
{
"errcode": 0,
"errmsg": "ok",
}
6. Error Codes
The following is the error code list of this API, other error codes can refer to Common Error Codes; When encountering errors in calling the API, you can use the official API Diagnostic Tool to assist in locating and analyzing problems.
| Error Code | Error Description | Solution |
|---|---|---|
| -1 | system error | The system is busy. Please wait and try again later. |
| 40037 | invalid template_id | Invalid template_id. |
| 41030 | invalid page | Incorrect page path. Ensure the page exists in the current online version of Mini Program and is consistent with app.json. |
| 43101 | user refuse to accept the msg | The user declined the message. If the user had previously subscribed, this indicates that the user has unsubscribed. |
| 47003 | argument invalid! | Invalid template parameters. They may be empty or fail to meet the rules. The errmsg field will specify which field caused the error. |
7. Applicable Scope
The callable account types for this API are not yet clear, or are determined by the calling parameters in business. Please refer to the actual calling situation.