/v2/miniprogram/qrcode/create
POST /v2/miniprogram/qrcode/create
With this API call, a merchant or an ISV can create a promotion QR code to redirect users to a specific mini program. For example, users can scan the QR code to order meals in the mini program.
Structure
A message consists of a header and body. The following sections are focused on the body structure. For the header structure, see:
Request parameters
Field | Data type | Required | Description | Example |
appId | String | Yes | Indicates the unique ID assigned by Mini Program Platform to identify a mini program that users are redirected to when they scan the QR code.
Note: Obtain this field via the my.getAppIdSync JSAPI or Mini Program Platform. | "P000000000000001xxxx" |
appQrCodeType | String | No | Indicates the type of the created QR code. The valid value is:
Note: When the value of appQrCodeType is | "PROMO" |
appQrCodePage | String | No | Indicates the page path that redirects users to a specific page in the mini program, for example:
Note: When the value of appQrCodePage is | "page/component/component-pages/view" |
appQrCodeParams | String | No | When a user uses the super app or other apps to scan the QR code, this field will be passed to the mini program via
| "x=1&y=2" |
appQrCodeDesc | String | No | Indicates the description of the QR code.
| "My shop QR code" |
Response parameters
Field | Data type | Required | Description | Example |
result | Yes | Indicates the request result such as status and error codes. | copy
| |
appQrCode | String | Yes | Indicates the QR code value, which is the final URL to redirect users to a mini program when they scan the QR code.
| "https://miniprogram.alipay.com/mini-qr/28166612109YMP7RLw7zT2HU1k6AXzSOFfv4qu3xxxx" |
appQrCodePicValue | String | Yes | Indicates the QR code image in the appQrCodeResultPicType format.
| See Response Sample Code for an example. |
appQrCodeResultPicType | String | Yes | Indicates the format of the QR code image. Currently, only Base64 is supported.
| BASE64 |
Result process logic
In the response, the result.resultStatus field indicates the result of processing a request. The following table describes each result status:
Result status | Description |
S | The request to create a QR code is successful, which means the QR code value and image are generated and returned to the merchant. Note: For the QR code generated with the same appId, appQrCodePage, appQrCodePage, and appQrCodeParams and reach an The corresponding result.resultCode is |
U | The status of the request to create a QR code is unknown. The corresponding result.resultCode is |
F | The request to create a QR code is failed. The corresponding result.resultCode and result.resultMessage are various based on different situations. For details, see the following Error codes section. |
Error codes
Error codes are usually classified into the following categories:
- Common error codes are common for all mini program OpenAPIs in V2.
- API-specific error codes: The current OpenAPI does not have its dedicated error codes.
Samples
The data flow of creating a QR code is illustrated as below:
- The merchant server or the ISV server calls this API to request Mini Program Platform to create a QR code.
- Mini Program Platform processes the request and returns the generated QR code value and image to the merchant server or the ISV server.
Request
{
"appId":"P000000000000001xxxx",
"appQrCodeType":"PROMO",
"appQrCodePage":"page/component/component-pages/view",
"appQrCodeParams":"x=1&y=2",
"appQrCodeDesc":"My Shop QR code"
}
- The merchant requests to create a QR code (with description
My Shop QR code
) for the mini program (P000000000000001xxxx
). - The QR code links to the mini program page(
page/component/component-pages/view
) with parameters (x=1&y=2
).
Response
{
"appQrCode": "https://miniprogram.alipay.com/mini-qr/28166612109YMP7RLw7zT2HU1k6AXzSOFfv4qu3xxxx",
"appQrCodePicValue": "iVBORw0KGgoAAAANSUhEUgAAAawAAAGsCAIAAAAOqgT7AAAM6UlEQVR42u3aS3IDIRBEQd3/0vIVHGHT1QX51mNpxCfxgs9Xkh7uYwgkQVCSIChJEJQkCEoSBCUJgpIEQUmCoCRBUJIgKEkQlCQIShIEJQmCkgRBSYKgJEFQkiAoSRCUJAhKEgQlCYKSBEFJgqAkQVCSIChJEJQkCEoSBCUJgpIEQUmCoCRBUJIgKEkQlCQIShIEJQmCkgRBSYKgJBUi+NnX79/zj0+ODUh24sY+c2xAFr7niW/P7jgIQhCCEIQgBCEIQQhCEIIQhCAEIQhBCEIQghCEIAQhCEEIQhCCEIQgBO9HcOG3ZxFcyFB26LJbseVErN5xEIQgBCEIQQhCEIIQhCAEIQhBCEIQghCEIAQhCEEIQhCCEIQgBCEIQQg+iuAjC2Lh/buF50d22YwN8okvennHQRCCEIQgBCEIQQhCEIIQhCAEIQhBCEIQghCEIAQhCEEIQhCCEIQgBCEIwb4rbGO7LrtpT+yl6pHPnl4QhCAEIQhBCEIQghCEIAQhCEEIQhCCEIQgBCEIQQhCEIIQhCAEIQhBCEIQgvldN3YxbewAyB4qCw+AR3YcBCEIQQhCEIIQhCAEIQhBCEIQghCEIAQhC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IQgBCEIQQhCEIIQhCAEIQhBCEIQghCEIAQhCEEIQhCCEIQgBO9HMHtn6sTLZyFY6Mh9PzO7krPT4Z4gBCEIQQhCEIIQhCAEIQhBCEIQghCEIAQhCEEIQhCCEIQgBCEIQQhCEIJ9CI5t2rH3zA5IC5cLN20LWDu9gyAEIQhBCEIQghCEIAQhCEEIQhCCEIQgBCEIQQhCEIIQhCAEIQhBCEIQgtNgLVxPWXHGwFrosoMKghCEIAQhCEEIQhCCEIQgBCEIQQhCEIIQhCAEIQhBCEIQghCEIAQhCEEINn17luCWkya7bcZ+UXbVZQ+qoiAIQQhCEIIQhCAEIQhBCEIQghCEIAQhCEEIQhCCEIQgBCEIQQhCEIIQzDBUfWup+qpddo6y49ny2xcuhjGXIQhBCEIQghCEIAQhCEEIQhCCEIQgBCEIQQhCEIIQhCAEIQhBCEIQghBsRVCSIChJEJQkCEoSBCUJgpIEQUmCoCRBUJIgKEkQlCQIShIEJQmCkgRBSYKgJEFQkiAoSRCUJAhKEgQlCYKSBEFJgqAkQVCSIChJEJQEQUmCoCRBUJIgKEkQlCQIShIEJQmCkgRBSYKgJEFQkiAoSRCUJAhKEgQlCYKS1NUPQh3NYbu7TygAAAAASUVORK5CYII=",
"appQrCodeResultPicType": "BASE64",
"result": {
"resultCode": "SUCCESS",
"resultMessage": "success",
"resultStatus": "S"
}
}
- result.resultStatus is
S
, which shows the QR code is created successfully. - The redirecting URL of the QR code is appQrCode (
https://miniprogram.alipay.com/mini-qr/28166612109YMP7RLw7zT2HU1k6AXzSOFfv4qu3xxxx
). - The image of the QR code is in appQrCodeResultPicType (
BASE64
) format.