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: checkEncryptedData
Verify whether the encrypted information was generated by WeChat (currently supports only encrypted phone number data). Only encrypted data generated within the last 3 days can be verified.
1. Call Method
HTTPS Call
POST https://api.weixin.qq.com/wxa/business/checkencryptedmsg?access_token=ACCESS_TOKEN
Encryption Support: This API supports secondary encryption and signature for service communication, which can effectively prevent data tampering and leakage. View Details
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: 18
-
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 |
|---|---|---|---|
| encrypted_msg_hash | string | Yes | The SHA-256 hash of the encrypted data, encoded as a Hex (Base16) string. |
3. Response Parameters
Response Body Response Payload
| Parameter | Type | Description |
|---|---|---|
| errcode | number | Error code |
| errmsg | string | Error message |
| vaild | boolean | Indicates whether the data is valid. |
| create_time | number | Timestamp of when the encrypted data was generated. |
4. Notes
No special notes for this API
5. Code Example
Request Example
{
"encrypted_msg_hash": "657edd868c9715a9bebe42b833269a557a48498785397a796f1568c29a200b2c"
}
Response Example
{
"errcode": 0,
"errmsg": "ok",
"vaild": true,
"create_time": 1629121902
}
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 | System is busy. Developers, please try again later. |
| 1 | data not exit | The encrypted data does not exist. This may be because the data generation time exceeds the retention limit (3 days), the key does not exist, or the data does not match the AppID. |
| 40097 | invalid args | Parameter error. |
| 44002 | empty post data | The POST data packet is empty. The body parameter for POST requests cannot be empty. |
| 47001 | data format error | Failed to parse JSON/XML content; parameters are missing in the POST data. Check and correct the data, then retry. |
7. Applicable Scope
| Mini Program | Mini Game |
|---|---|
| ✔ | ✔ |
- ✔:This account type can call this API。
- Other account types not explicitly declared cannot call this API unless otherwise specified.