All Products
Search
Document Center

Function Compute:CreateSession

最終更新日:Dec 19, 2025

The CreateSession operation creates an explicit session resource. The system automatically generates a unique session ID, pre-allocates a function instance, and associates it with the session. You can specify values for TTL and idle timeout. This method applies to the HEADER_FIELD and GENERATED_COOKIE affinity types. It handles session preload and configuration initialization. After you call the InvokeFunction API, the session information can be included in the InvokeFunction request to enable request routing.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • For mandatory resource types, indicate with a prefix of * .
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
fc:CreateSessioncreate
*All Resources
*
    none
none

Request syntax

POST /2023-03-30/functions/{functionName}/sessions HTTP/1.1

Request parameters

ParameterTypeRequiredDescriptionExample
functionNamestringNo

The name of the function.

my-func
qualifierstringNo

Specifies the version or alias to which the sesion belongs.

aliasName1
bodyCreateSessionInputNo

Creates session configurations.

Response parameters

ParameterTypeDescriptionExample
Session

The session resources.

Examples

Sample success responses

JSONformat

{
  "sessionId": "81f70ae156904eb9b7d43e12f511fe58",
  "functionName": "functionName1",
  "sessionAffinityType": "HEADER_FIELD",
  "sessionTTLInSeconds": 21600,
  "sessionIdleTimeoutInSeconds": 1800,
  "createdTime": "2025-04-01T08:15:27Z",
  "lastModifiedTime": "2025-04-01T18:15:27Z",
  "sessionStatus": "Active",
  "containerId": "c-68999e02-16a1955c-d2a03d1ccs",
  "qualifier": "AliasName1",
  "nasConfig": {
    "groupId": 100,
    "mountPoints": [
      {
        "enableTLS": true,
        "mountDir": "/home/test",
        "serverAddr": "***-uni85.cn-hangzhou.nas.com:/"
      }
    ],
    "userId": 100
  }
}

Error codes

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2025-10-29The internal configuration of the API is changed, but the call is not affectedView Change Details