Reset Login State

View Markdown

Last edited on 2026-03-16

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

ParameterTypeRequiredDescription
access_tokenstringYesAPI call credential, you can use access_token, authorizer_access_token

Request Body Request Payload

ParameterTypeRequiredDescription
openidstringYesUnique user identifier
signaturestringYesUser login state signature, which is the result of signing an empty string with session_key. That is, signature = hmac_sha256(session_key, "")
sig_methodstringYesHashing method for the user login state signature. Currently, only hmac_sha256 is supported.

3. Response Parameters

Response Body Response Payload

ParameterTypeDescription
errcodenumberError code
errmsgstringError message
openidstringUnique user identifier
session_keystringUser login state after reset

4. Notes

  1. 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.
  2. 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.
  3. The rate limit for a single Mini Program appid is 60,000 requests per minute.
  4. 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 CodeError DescriptionSolution
-1system errorSystem is busy. Developers should wait a moment and try again.
40097invalid argsParameter error
45011api minute-quota reach limit  mustslower  retry next minuteAPI calls are too frequent. Please try again later.
87007session_key is not existd or expired
87008invalid sig_method
87009invalid signatureInvalid signature

7. Applicable Scope

API callable status for different account types:
Mini ProgramMini Game
✔ ✔
  • ✔:This account type can call this API。
  • Other account types not explicitly declared cannot call this API unless otherwise specified.