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
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 Resourcesis 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.
| Operation | Access level | Resource type | Condition key | Associated operation |
|---|---|---|---|---|
| fc:CreateSession | create | *All Resources * |
| none |
Request syntax
POST /2023-03-30/functions/{functionName}/sessions HTTP/1.1
Request parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| functionName | string | No | The name of the function. | my-func |
| qualifier | string | No | Specifies the version or alias to which the sesion belongs. | aliasName1 |
| body | CreateSessionInput | No | Creates session configurations. |
Response parameters
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 time | Summary of changes | Operation |
|---|---|---|
| 2025-10-29 | The internal configuration of the API is changed, but the call is not affected | View Change Details |
