Use this API to redirect the user to the authorization page. After the user completes the authorization, the app will return the authorization code which can be used to obtain the access token for the agreement payment.


Please make sure you use the Appx with 1.24.6 or higher versions in order to use this API.

Below is a diagram that illustrates how the interaction works:


The merchant Mini Program server can call authorization consult API in step 2 to get the sign content with an authorization URL. Then the Mini Program will call the my.signContract JSAPI to invoke the authorization process. After the user completes the authorization, the Mini Program sends JSAPI result to its server so that the server can call apply token API to get accessToken.

Sample code

  signStr: '',
  success: (res) => {
    content: JSON.stringify(res),
  fail: (res) => {
    content: JSON.stringify(res),




signStrStringYesThis parameter is the authorization string returned by the app to further the authorization process.
successFunctionNoCallback function upon call success.
failFunctionNoCallback function upon call failure.
completeFunctionNoCallback function upon call completion (to be executed upon either call success or failure).

Success Callback Function

authStateString The authorization status. It is generated in Mini Program server and sent to app server. The maximum length is 256. Refer here for details.
authCodeStringThe authorization code assigned by app which can be used to obtain the access token for the agreement payment. The maximum length is 32.

An example of a successfully returned message is as follows:


Fail Callback Function

errorStringThe error code for the failure.
errMessageStringThe error message.

Error Code

When error happens, the fail callback function will be executed. The error code can refer to the following table.

Error CodeDescription
6001User cancels the sign process.
6002The sign fails because of network error.
7001The result of the sign is unknown, it may be successful.
7002The sign fails.