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: ResetUserSessionKey
Reset the session_key for the specified login state. To maintain the privacy of the session_key, the API does not accept the session_key in plain text; instead, it verifies the login state signature.
1. Call Method
HTTPS Call
GET https://api.weixin.qq.com/wxa/resetusersessionkey?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: 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 |
|---|---|---|---|
| openid | string | Yes | Unique user identifier |
| signature | string | Yes | User login state signature, which is the result of signing an empty string with session_key. That is, signature = hmac_sha256(session_key, "") |
| sig_method | string | Yes | Hashing method for the user login state signature. Currently, only hmac_sha256 is supported. |
3. Response Parameters
Response Body Response Payload
| Parameter | Type | Description |
|---|---|---|
| errcode | number | Error code |
| errmsg | string | Error message |
| openid | string | Unique user identifier |
| session_key | string | User login state after reset |
4. Notes
- After resetting the user's session_key, the original session_key becomes invalid. Please pay attention to the timing of the API call to avoid affecting the user's experience in Mini Program.
- The session_key after reset inherits the expiration time of the original session_key. The reset operation cannot extend the session_key's validity period.
- The rate limit for a single Mini Program appid is 60,000 requests per minute.
- Frequent resetting of the same user's login state is not allowed.
5. Code Example
Request Example
GET https://api.weixin.qq.com/wxa/resetusersessionkey?access_token=ACCESS_TOKEN&openid=OPENID&signature=SIGNATURE&sig_method=hmac_sha256
Response Example
{
"errcode": 0,
"errmsg": "ok",
"openid": "xxxxxxx",
"session_key": "xxxxxxxx"
}
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 should wait a moment and try again. |
| 40097 | invalid args | Parameter error |
| 45011 | api minute-quota reach limit mustslower retry next minute | API calls are too frequent. Please try again later. |
| 87007 | session_key is not existd or expired | |
| 87008 | invalid sig_method | |
| 87009 | invalid signature | Invalid signature |
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.