/v2/miniprogram/decorate/upload

POST /v2/miniprogram/decorate/upload

The ISV or the merchant calls this API to upload the mini program configuration onto Mini Program Platform.

Structure

A message consists of a header and body. The following sections are focused on the body structure. For the header structure, see:

Request header

Field

Data type

Required

Description

Example

Agent-Token

String

No

An agent token that is issued by the merchant to authorize its ISV for API calls. Specify this parameter if an ISV calls the API in behalf of a merchant.

Request parameters

Field

Data type

Required

Description

Example

appId

String

Yes

The unique ID that is assigned by Mini Program Platform to identify an mini program.

templateId

String

Yes

The template ID.

templateVersion

String

Yes

The template version. For example, if the template has multiple versions, specify this parameter as the version to be uploaded.

templateConfig

String 

Yes

The template configuration information.

See Request for details.

extendInfo

String

No

Indicates the extended information about this API.

  • Maximum length: 4096 characters
  • Characters not allowed: special characters such as @ # ?
  • Can be Null

{

    "memo": "memo"

}

Response parameters

Field

Data type

Required

Description

Example

result

Result

Yes

Indicates the request result such as status and error codes.

{

  "resultCode": "SUCCESS",

  "resultStatus": "S",

  "resultMessage": "success"

}

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 authorization request is successful.

The corresponding result.resultCode is SUCCESS and the result.resultMessage is SUCCESS.

U

The status of the authorization request is unknown.  

The corresponding result.resultCode is UNKNOWN_EXCEPTION and result.resultMessage is "An API calling is failed, which is caused by unknown reasons.".

For details, see the Common error codes section.

F

The authorization request 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 are listed in the following table.

Error code

Result status

Error message

Further action

INVALID_ISV_ACCESS_TOKEN

F

The access token is invalid.

Ensure the value of Agent-Token is correct and call the API again. If Agent-Token expires, the ISV needs to be authorized again and obtain a refreshed value of Agent-Token.

APP_NOT_EXIST

F

The mini program does not exist.

Ensure the value of appId is correct and call the API again.

TEMPLATE_NOT_EXIST

F

The template does not exist.

Ensure the value of templateId is correct and call the API again.

TEMPLATE_VERSION_NOT_ONLINE

F

The template version is not online.

Ensure the value of templateversion is correct and call the API again.

TEMPLATE_VERSION_NOT_EXIST

F

The template version does not exist.

Ensure the value of templateversion is correct and call the API again.

Samples

The data flow to obtain an access token is illustrated as below:

image

Request

copy
{
  "appId": "2102900012341234",
  "templateId": "2102900012341111",
  "templateVersion": "1.0.1",
  "templateConfig": "{\"currentFont\":{\"fontName\":\"AlibabaSans\",\"fontNameId\":\"AlibabaSans\",\"fontFace\":[{\"fontFamily\":\"AlibabaSans-Bold\",\"url\":\"https://cdn.marmot-cloud.com/storage/2022/11/29/cd8c22a3-a7ef-4c0a-a3e5-26f0518548b8.ttf\"}]},\"styleType\":\"LightTheme\",\"colorCustom\":{\"colorCustomName\":\"system default\",\"colorCustomNameId\":\"systemDefault\",\"colorCustomStyle\":{\"brandColor\":\"#FF8800\",\"promotionColor\":\"#FF6F80\"},\"styleInfo\":{\"--color-brand-primary\":\"#FF8800\",\"--color-brand-secondary\":\"#ffc299\"}}}",
  "uploadTime":"2019-11-27T12:01:01+08:00"
  "extendInfo": "{\"memo\":\"a\",\"memo\":\"a\"}"
}

In the request sample above, the value of the templateConfig parameter is specified by the ISV who provides the mini program template. For example:

copy
{
 "currentFont": {
    "fontName": "AlibabaSans",
    "fontNameId": "AlibabaSans",
    "fontFace": [{
   "fontFamily": "AlibabaSans-Bold",
   "url": "https://cdn.marmot-cloud.com/storage/2022/11/29/cd8c22a3-a7ef-4c0a-a3e5-26f0518548b8.ttf"
    }]
 },
 "styleType": "LightTheme",
 "colorCustom": {
    "colorCustomName": "system default",
    "colorCustomNameId": "systemDefault",
    "colorCustomStyle": {
   "brandColor": "#FF8800",
   "promotionColor": "#FF6F80"
    },
    "styleInfo": {
   "--color-brand-primary": "#FF8800",
   "--color-brand-secondary": "#ffc299"
    }
 }
}

Response

copy
{
 "result": {
    "resultCode": "SUCCESS",
    "resultStatus": "S",
    "resultMessage": "success"
 }
}
  • result.resultStatus is S, which shows the request to obtain an access token is successful.