Obtaining Stable API Call Credentials

View llm.txt

Last edited on 2026-07-04

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: getStableAccessToken

This interface is used to retrieve a globally unique backend API call credential (Access Token). The token is valid for 7,200 seconds. However, this interface is separate from getAccessToken and more stable. It is recommended to use this interface instead. Developers should store it properly. For usage guidelines, please refer to this document.

There are two call modes:

  1. Normal mode: Repeated calls to this interface within the validity period of the access_token will not update the access_token. This mode is used in most scenarios.
  2. Forced refresh mode: This will invalidate the previously obtained access_token and return a new one.

1. Call Method

HTTPS Call

POST https://api.weixin.qq.com/cgi-bin/stable_token

Cloud Call

  • This API does not support cloud call.

Third-party Call

  • This API does not support third-party platform calls.

2. Request Parameters

Query Parameters Query String Parameters

None

Request Body Request Payload

ParameterTypeRequiredDescription
grant_typestringYesEnter client_credential
appidstringYesThe unique credential for the account, namely AppID. Click here to view how to obtain an AppID.
secretstringYesThe unique credential key, namely AppSecret. Click here to view how to obtain an AppSecret.
force_refreshbooleanNoThe default value is false. 1. When force_refresh = false, it is in normal call mode, and repeated calls to this interface within the validity period of the `access_token` will not update the `access_token`. 2. When force_refresh = true, it is in forced refresh mode, which will invalidate the previously obtained `access_token` and return a new one.

3. Response Parameters

Response Body Response Payload

ParameterTypeDescription
access_tokenstringThe obtained credentials
expires_innumberCredential validity period, in seconds. Currently, it is within 7,200 seconds.

4. Notes

  1. The call credentials obtained through getAccessToken are completely separate and do not affect each other.
  2. This interface only supports POST requests.
  3. The call frequency limit for this interface is 10,000 times per minute, with a daily limit of 500,000 times.
  4. The access_token must have at least 512 characters in storage space.
  5. The forced refresh mode is limited to 20 times per day, with a 30-second interval required.
  6. In normal mode, the platform will update the access_token 5 minutes in advance.

5. Code Example

5.1 Obtain Token without Forced Refresh (Do not pass force_refresh; the default value is false)

Request Example

POST https://api.weixin.qq.com/cgi-bin/stable_token
{
    "grant_type": "client_credential",
    "appid": "APPID",
    "secret": "APPSECRET"
}

Response Example

{
    "access_token":"ACCESS_TOKEN",
    "expires_in":7200
}

5.2 Obtain Token without Forced Refresh (Set force_refresh to false):

Request Example

{
    "grant_type": "client_credential",
    "appid": "APPID",
    "secret": "APPSECRET",
    "force_refresh": false
} 

Response Example

{
    "access_token":"ACCESS_TOKEN",
    "expires_in":345 // If it is still valid, the previous token will be returned along with the remaining validity time
} 

5.3 Use the forced refresh mode with caution. A minimum interval of 30 seconds is required for consecutive uses.

Request Example

POST https://api.weixin.qq.com/cgi-bin/stable_token
{
    "grant_type": "client_credential",
    "appid": "APPID",
    "secret": "APPSECRET",
    "force_refresh": true
} 

Response Example

{
    "access_token":"ACCESS_TOKEN",
    "expires_in":7200
} 

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 errorThe system is busy. Please try again later.
0okok
40002invalid grant_typeInvalid credential type
40013invalid appidInvalid AppID. Please check the correctness of the AppID, avoiding special characters and paying attention to case sensitivity.
40125invalid appsecretInvalid appsecret. Please check the correctness of the appsecret.
40164invalid ip  not in whitelistAdd the IP address to the IP whitelist list.
41002appid missingMissing appid parameter
41004appsecret missingMissing secret parameter
43002require POST methodA POST request is required.
45009reach max api daily quota limitThe call exceeds the daily frequency limit. You can call the clear_quota interface to restore the call quota.
45011api minute-quota reach limit  mustslower  retry next minuteThe API is called too frequently. Please try again later.
89503This call requires administrator confirmation. Please wait patiently.
89506The call request from this IP has been rejected by the public account administrator. Please try again after 24 hours. It is recommended to communicate with the administrator before making the call.
89507The call request from this IP has been rejected by the public account administrator. Please try again after 1 hour. It is recommended to communicate with the administrator before making the call.

7. Applicable Scope

API callable status for different account types:
Mini ProgramOfficial AccountService AccountMini GameWeChat ShopAlliance AgencyInfluencerShop SupplierMobile AppWebsite AppChannels WindowMulti-platform App
✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
  • ✔:This account type can call this API。
  • Other account types not explicitly declared cannot call this API unless otherwise specified.