Updated on 2025-10-22 GMT+08:00

Creating an Environment

Function

This API is used to create an environment.

URI

POST /v1/{project_id}/cae/environments

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. See Obtaining a Project ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

  • Obtain the token. For details, see "Obtaining a User Token" in Identity and Access Management API Reference (https://support.huaweicloud.com/intl/en-us/api-iam/iam_30_0001.html).

  • The value of X-Subject-Token in the response header is the token value.

X-Enterprise-Project-ID

No

String

Enterprise project ID.

  • When an environment is created, it will be bound with an enterprise project ID.

  • Enter 0 or up to 36 characters in UUID format with hyphens (-).

  • If this parameter is not specified or set to 0, resources in the default enterprise project are queried.

NOTE:
For details about how to obtain enterprise project IDs and enterprise project features, see Enterprise Management User Guide.
Table 3 Request body parameters

Parameter

Mandatory

Type

Description

api_version

Yes

String

API version. Fixed value: v1.

kind

Yes

String

API type. Fixed value: Environment.

metadata

Yes

metadata object

Request data.

Table 4 metadata

Parameter

Mandatory

Type

Description

annotations

No

CreateEnvRequestAnnotations object

name

Yes

String

Environment name.

Table 5 annotations

Parameter

Mandatory

Type

Description

{User defined key}

No

Map<String,String>

Additional parameters for creating an environment.

  • vpc_id: ID of the VPC bound to the created environment.

  • group_name: name of the SWR organization bound to the created environment.

  • type: environment type, which can only be exclusive.

  • subnet_id: ID of the VPC subnet bound to the created environment.

  • egress_subnet_id: ID of the VPC egress subnet bound to the created environment.

  • elb_id: ID of the ELB bound to the created environment.

Response Parameters

Status code: 200

Table 6 Response body parameters

Parameter

Type

Description

job_id

String

Job ID.

Example Requests

Create environment test, and bind it to a VPC and organization cae-test.

POST https://{endpoint}/v1/{project_id}/cae/environments

{
  "api_version" : "v1",
  "kind" : "Environment",
  "metadata" : {
    "annotations" : {
      "vpc_id" : "9b320498-6c39-4fe7-a758-79636dd68a82",
      "group_name" : "cae-test",
      "type" : "exclusive",
      "subnet_id" : "1c75734a-132c-459f-86e2-a3db86a66b86",
      "security_group_id" : "e6c5a41d-8f47-48bd-a21b-0a4b10766aef"
    },
    "name" : "test"
  }
}

Example Responses

Status code: 200

OK

{
  "job_id" : "xxx"
}

Status Codes

Status Code

Description

200

OK

Error Codes

See Error Codes.