Get Mini Program QR Code

View Markdown

Last edited on 2026-11-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: createQRCode

Get the Mini Program QR code. This is suitable for business scenarios requiring a small number of codes. The Mini Program QR codes generated via this API are permanently valid but subject to quantity limits. For details, see Get QR Code.

1. Call Method

HTTPS Call

POST https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?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

  • Call Method: wxacode.createQRCode

  • Input and output parameters are the same as HTTPS call. For call method, please refer to Cloud Call documentation.

Third-party Call

  • This API supports third-party platforms on behalf of Merchant call.

  • The permission set ID of this API is: 17

  • 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
pathstringYesThe page path of the Mini Program that will be entered after scanning the QR code. The maximum length is 128 characters and it cannot be empty. For Mini Games, you can pass only the query part to achieve parameter passing. For example, passing "?foo=bar" allows you to retrieve `{foo:"bar"}` in the `query` parameter of the `wx.getLaunchOptionsSync` API. `scancode_time` is a system-reserved parameter and cannot be configured.
widthnumberNoThe width of the QR code in pixels (px). Minimum is 280px, maximum is 1280px. The default value is 430.

3. Response Parameters

Response Body Response Payload

ParameterTypeDescription
bufferformdataImage Buffer
errcodestringError Code
errmsgstringError Message

4. Notes

  • If the call is successful, the binary content of the image is returned directly. If the request fails, data in JSON format is returned.
  • POST parameters must be converted to a JSON string; form submission is not supported.
  • The API can only generate QR codes for published Mini Program s. QR codes with parameters for development versions can be generated when previewing in the Developer Tools.
  • The total number of codes generated by both this API and wxacode.get is limited to 100,000. Please use it cautiously.

5. Code Example

5.1 HTTP Call Example (Success)

Request Example

{
  "path": "page/index/index",
  "width": 430
}

Response Example

Image Buffer

5.2 HTTP Call Example (Failure)

Request Example

{
  "path": "",
  "width": 430
}

Response Example

{
  "errcode": 40159,
  "errmsg": "invalid length for path  or thedata is not json string"
}

5.3 Cloud Call Example (Success)

Request Example

const cloud = require('wx-server-sdk')
cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV,
})
exports.main = async (event, context) => {
  try {
    const result = await cloud.openapi.wxacode.createQRCode({
        "path": 'page/index/index',
        "width": 430
      })
    return result
  } catch (err) {
    return err
  }
}

Response Example

Image Buffer

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 wait a moment and try again.
40159invalid length for path, or the data is not json string`path` cannot be empty, and its length must not exceed 128 bytes.
45029qrcode count out of limitThe total number of generated codes has reached the maximum limit.
85096page or path not allow include scancode_time field`scancode_time` is a system-reserved parameter and cannot be configured.
85413personal entity not verifiedPersonal Mini Program s must undergo entity verification before Mini Program QR codes can be generated and used.

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.