All Products
Search
Document Center

Function Compute:PublishLayerVersion

Last Updated:Aug 20, 2025

You can call this operation to publish a layer version.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. You can use OpenAPI Explorer to search for API operations, call API operations, and dynamically generate SDK sample codes.

Request headers

This operation uses only common request headers. For more information, see Common parameters.

Request syntax

POST /layers/{layerName}/versions/ HTTP/1.1

Request parameters

ParameterTypePositionRequiredExampleDescription
layerNameStringPathYesLayer-name

The name of the layer.

ObjectBodyNo

The description of the layer.

codeCodeBodyNo

The code of the function. The code must be packaged into a ZIP file.

descriptionStringBodyNoLayer-description

The description of the layer.

compatibleRuntimeArray of StringBodyNonodejs12

The runtime environment supported by the layer. Valid values: nodejs12, nodejs10, nodejs8, nodejs6, python3, and python2.7.

Response parameters

ParameterTypeExampleDescription
ETagStringe19d5cd5af0378da05f63f891c7467af

This value is used to ensure that the modified layer is consistent with the layer to be modified.

Layer

The layer structure returned.

Examples

Sample requests

POST /2016-08-15/layers/Layer-name/versions HTTP/1.1
Common request parameters

{
  "code" : {
    "ossBucketName" : "test-bucket",
    "ossObjectName" : "test-object",
    "zipFile" : "samplecode"
  },
  "description" : "Layer-description",
  "compatibleRuntime" : [ "nodejs12" ]
}

Sample success responses

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "layerName" : "Layer-name",
  "version" : 1,
  "description" : "Layer-description",
  "code" : {
    "repositoryType" : "OSS",
    "location" : "https://xyz.oss-cnxxx.aliyuncs.com/xxx/xxx/xxx"
  },
  "codeSize" : 421,
  "codeChecksum" : "2825179536350****",
  "createTime" : "2020-11-11T11:08:00Z",
  "acl" : 0,
  "compatibleRuntime" : [ "python3" ],
  "arn" : "02f81d283888f5ec63442a88fe82b260#Layer-name#1"
}

Error codes

For a list of error codes, visit the API Error Center.