Updated on 2026-04-10 GMT+08:00

Creating an Environment

Function

This API is used to create an environment.

Authorization Information

Each account has all of the permissions required to call all APIs, but IAM users must have the required permissions specifically assigned.

URI

POST /v3/{project_id}/cas/environments

Table 1 Path parameter

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Tenant's project ID. See Obtaining a Project ID.

Constraints

N/A

Range

N/A

Default Value

N/A

Request

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

Content-Type

Yes

String

Definition

Message body type (or format).

Constraints

N/A

Range

application/json;charset=utf8

Default Value

N/A

X-Auth-Token

Yes

String

Definition

API calling can be authenticated using a token or AK/SK. If you use a token, this parameter is mandatory and must be set to the token. For details about how to obtain the token, see Authentication.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

config_mode

No

String

Definition

Parameter configuration mode.

Range

  • ui

Default Value

N/A

name

Yes

String

Definition

Environment name.

Range

The value contains 2 to 64 characters consisting of letters, digits, hyphens (-), or underscores (_). It starts with a letter and ends with a letter or digit. Letters are case sensitive.

Default Value

N/A

deploy_mode

No

String

Definition

Environment type.

Range

  • virtualmachine
  • container: Kubernetes
  • mixed: VM and Kubernetes

To use a custom server in the created environment, select virtualmachine or mixed.

Default Value

N/A

type

No

String

Definition

Whether the Kubernetes environment is of the HA type.

Range

  • normal: non-HA environment.
  • high: HA environment.

Default Value

N/A

resource_create_mode

No

String

Definition

Resource configuration mode.

Range

  • none: resource management.
  • iac: resource creation.

To use a custom server in the created environment, select none.

Default Value

N/A

resources

No

Array of objects

Definition

Resource list. See Table 4.

description

No

String

Definition

Environment description.

Range

The value can contain up to 128 characters.

Default Value

N/A

enterprise_project_id

No

String

Definition

Enterprise project ID.

If this parameter is not set, the default enterprise project is default and the ID is 0.

Constraints

An enterprise project can be configured only after the enterprise project function is enabled.

Range

N/A

Default Value

N/A

vpc_id

Yes

String

Definition

VPC ID.

To obtain this value, use either of the following methods:

  • Method 1: Log in to VPC console and view the VPC ID in the VPC details.
  • Method 2: Use the VPC API. For details, see Querying VPCs.

Range

N/A

Default Value

N/A

labels

No

Array of objects

Definition

Label. You can use TMS to filter resources by labels. See Table 6.

Constraints

Each environment can have a maximum of 20 labels.

environment_azs

No

Array of objects

Definition

List of AZs.

Constraints

When type is set to high, you need to set two AZs.

Table 4 resources

Parameter

Mandatory

Type

Description

id

Yes

String

Definition

Resource ID. (To ensure that the API can be called properly, enter the correct resource ID.)

Range

N/A

Default Value

N/A

name

No

String

Definition

Resource name.

Range

N/A

Default Value

N/A

type

Yes

String

Definition

Resource type.

Range

  • vpc
  • eip
  • elb
  • cce
  • ecs
  • as
  • cse: ServiceComb engine
  • nacos: registry/configuration center
  • dcs
  • rds
  • subnet
  • acl
  • customServer
  • gaussdb
  • dms_rocketmq
  • css_es: Elasticsearch
  • custom_k8s: custom Kubernetes cluster

Default Value

N/A

parameters

No

Map<String, String>

Definition

Resource parameters. See Table 5.

Table 5 parameters

Parameter

Mandatory

Type

Description

kube_config

No

String

Definition

Kubernetes connection configuration file.

This parameter is required when the resource type is custom_k8s.

Range

N/A

Default Value

N/A

Table 6 labels

Parameter

Mandatory

Type

Description

key

Yes

String

Definition

Label name.

Labels are used to identify cloud resources. When you have multiple cloud resources of the same type, you can use labels to classify them based on usage, owner, or environment.

Range

The value contains 1 to 36 characters, including digits, letters, underscores (_), or hyphens (-).

Default Value

N/A

value

Yes

String

Definition

Label value.

Range

The value contains 1 to 43 characters, including digits, letters, underscores (_), periods (.), or hyphens (-).

Default Value

N/A

Response

Table 7 Response parameters

Parameter

Type

Description

id

String

Definition

Environment ID.

Range

N/A

name

String

Definition

Environment name.

Range

N/A

description

String

Definition

Environment description.

Range

N/A

project_id

String

Definition

Project ID.

Range

N/A

enterprise_project_id

String

Definition

Enterprise project ID.

Range

N/A

deploy_mode

String

Definition

Environment type.

Range

  • virtualmachine
  • container: Kubernetes
  • mixed: VM and Kubernetes.

vpc_id

String

Definition

VPC ID.

Range

N/A

creator

String

Definition

Environment creator.

Range

N/A

create_time

Integer

Definition

Environment creation time.

Range

N/A

update_time

Integer

Definition

Environment update time.

Range

N/A

labels

Array of objects

Definition

Label. You can use TMS to query resources by labels. See Table 8.

type

String

Definition

Whether the Kubernetes environment is of the HA type.

Range

  • normal: non-HA environment.
  • high: HA environment.

resource_create_mode

String

Definition

Resource configuration mode.

Range

  • none: resource management.

config_mode

String

Definition

Configuration mode.

Range

  • ui

env_status

String

Definition

Non-real-time environment resource status.

Range

  • REFRESHING
  • UNKNOWN
  • NORMAL
  • PARTIALLY_NORMAL
Table 8 labels

Parameter

Type

Description

key

String

Definition

Label name.

Range

N/A

value

String

Definition

Label value.

Range

N/A

Example Request

Create a VM environment env-test. The ID of the VPC where the environment is located is 0c72428b-cd6c-4283-a560-210d3edb49f7.

{
    "name": "env-test",
    "description": "",
    "enterprise_project_id": "0",
    "vpc_id": "0c72428b-cd6c-4283-a560-210d3edb49f7",
    "labels": [
        {
            "key": "aaaaa",
            "value": "a5"
        }
    ],
    "deploy_mode": "virtualmachine"
}

Example Response

{
    "id": "c93a5313-d141-4b9f-97ce-b4ce2b3988bd",
    "name": "test",
    "description": "",
    "project_id": "13ae26238d724e54947af3e0fcbef9c3",
    "enterprise_project_id": "0",
    "vpc_id": "0c72428b-cd6c-4283-a560-210d3edb49f7",
    "creator": "ss-test",
    "create_time": 1681384236023,
    "update_time": 1681384236023,
    "deploy_mode": "virtualmachine",
    "labels": []
}

Status Code

Status Code

Description

200

OK

400

Bad Request

404

Not Found

500

Internal Server Error

Error Code

See ServiceStage Error Codes.