Help Center/ Enterprise Switch/ API Reference/ Enterprise Switch/ Creating an Enterprise Switch
Updated on 2025-12-04 GMT+08:00

Creating an Enterprise Switch

Function

This API is used to create an enterprise switch. This is an asynchronous API. After the request for creating an enterprise switch is delivered, the job ID and instance ID are returned. You need to call the API for querying the job status to query the job execution status.

Authorization Information

Each account has all the permissions required to call all APIs, but IAM users must be assigned the following required identity policy-based permissions. For details about the required permissions, see Permissions Policies and Supported Actions.

Action

Access Level

Resource Type (*: required)

Condition Key

Alias

Dependencies

esw:instance:create

Write

-

-

-

-

URI

POST /v3/{project_id}/l2cg/instances

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

  • Definition: ID of the project to which the enterprise switch belongs.

  • Constraints: N/A

  • Range: N/A

  • Default value: N/A

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

instance

Yes

CreatePostpaidInstanceOption object

  • Definition: Request body for creating an instance.

  • Constraints: N/A

  • Range: N/A

  • Default value: N/A

Table 3 CreatePostpaidInstanceOption

Parameter

Mandatory

Type

Description

availability_zones

Yes

AvailabilityZones object

  • Definition: AZ where the enterprise switch node is located.

  • Constraints: N/A

  • Range: AZs in the current region.

  • Default value: N/A

charge_infos

Yes

PostPaidChargeInfos object

  • Definition: Billing information.

  • Constraints: N/A

  • Range: N/A

  • Default value: N/A

flavor_ref

Yes

String

  • Definition: Enterprise switch flavors.

  • Constraints: N/A

  • Range: For details, see the response of the flavor list API.

  • Default value: N/A

ha_mode

Yes

String

  • Definition: HA mode of the enterprise switch.

  • Constraints: Currently, only ha is supported.

  • Range: ha

  • Default value: N/A

name

Yes

String

  • Definition: Name of the enterprise switch.

  • Constraints:

    • The value can contain 1 to 64 characters.

    • The value can contain letters, digits, underscores (_), hyphens (-), and periods (.).

  • Range: N/A

  • Default value: N/A

tunnel_info

Yes

TunnelInfoOption object

  • Definition: Local tunnel information.

  • Constraints: N/A

  • Range: N/A

  • Default value: N/A

description

No

String

  • Definition: Description of the enterprise switch.

  • Constraints:

    • The value can contain 0 to 255 characters.

    • Angle brackets (<>) are not allowed.

  • Range: N/A

  • Default value: N/A

Table 4 AvailabilityZones

Parameter

Mandatory

Type

Description

primary

Yes

String

  • Definition: AZ where the default active node of the enterprise switch is located.

  • Constraints: The value can contain 1 to 128 characters.

  • Range: ID of the AZ in the current region.

  • Default value: N/A

standby

Yes

String

  • Definition: AZ where the default standby node of the enterprise switch is located.

  • Constraints: The value can contain 1 to 128 characters.

  • Range: ID of the AZ in the current region.

  • Default value: N/A

Table 5 PostPaidChargeInfos

Parameter

Mandatory

Type

Description

charge_mode

Yes

String

  • Definition: Billing mode.

  • Constraints: N/A

  • Range: postPaid, indicates the pay-per-use billing mode.

  • Default value: N/A

Table 6 TunnelInfoOption

Parameter

Mandatory

Type

Description

vpc_id

Yes

String

  • Definition: ID of the VPC where the enterprise switch is created.

  • Constraints:

    • You need to use the IDs of the VPCs that you can manage.

    • The value is in the UUID format with hyphens (-).

  • Range: N/A

  • Default value: N/A

virsubnet_id

Yes

String

  • Definition: ID of the tunnel subnet where the enterprise switch is located.

  • Constraints:

    • You need to use the IDs of the subnets that you can manage. The ID is the network ID in the subnet details.

    • The value is in the UUID format with hyphens (-).

  • Range: N/A

  • Default value: N/A

tunnel_ip

No

String

  • Definition: Tunnel IP address of the enterprise switch.

  • Constraints: The value cannot conflict with an existing subnet IP address.

  • Range: A standard IPv4 address, for example, 192.168.1.1.

  • Default value: N/A

Response Parameters

Status code: 201

Table 7 Response body parameters

Parameter

Type

Description

request_id

String

  • Definition: Unique request ID.

  • Constraints: The value is in the UUID format.

  • Range: N/A

  • Default value: N/A

instance

Instance object

  • Definition: Response body for creating an instance.

  • Constraints: N/A

  • Range: N/A

  • Default value: N/A

job_id

String

  • Definition: Unique job ID.

  • Constraints: The value is in the UUID format with hyphens (-).

  • Range: N/A

  • Default value: N/A

Table 8 Instance

Parameter

Type

Description

id

String

  • Definition: Unique ID of the enterprise switch.

  • Constraints: The value is in the UUID format with hyphens (-).

  • Range: N/A

  • Default value: N/A

name

String

  • Definition: Name of the enterprise switch.

  • Constraints:

    • The value can contain 1 to 64 characters.

    • The value can contain letters, digits, underscores (_), hyphens (-), and periods (.).

  • Range: N/A

  • Default value: N/A

project_id

String

  • Definition: ID of the project to which the enterprise switch belongs.

  • Constraints: N/A

  • Range: N/A

  • Default value: N/A

region

String

  • Definition: ID of the region where the enterprise switch is created.

  • Constraints: N/A

  • Range: N/A

  • Default value: N/A

flavor_ref

String

  • Definition: Enterprise switch flavors.

  • Constraints: N/A

  • Range: For details, see the response of the flavor list API.

  • Default value: N/A

ha_mode

String

  • Definition: HA mode of the enterprise switch.

  • Constraints: Currently, only ha is supported.

  • Range: ha

  • Default value: N/A

status

String

  • Definition: Status of the enterprise switch.

  • Constraints: N/A

  • Range:

    • active: The enterprise switch is running.

    • failed: Failed to create the enterprise switch.

    • abnormal: The enterprise switch is abnormal.

    • build: The enterprise switch is being created.

    • frozen: The enterprise switch is frozen.

  • Default value: N/A

created_at

String

  • Definition: Time when the enterprise switch was created.

  • Constraints: The value is a UTC time in the format of yyyy-MM-ddTHH:mm:ss.

  • Range: N/A

  • Default value: N/A

updated_at

String

  • Definition: Time when the enterprise switch was updated.

  • Constraints: The value is a UTC time in the format of yyyy-MM-ddTHH:mm:ss.

  • Range: N/A

  • Default value: N/A

description

String

  • Definition: Description of the enterprise switch.

  • Constraints:

    • The value can contain 0 to 255 characters.

    • Angle brackets (<>) are not allowed.

  • Range: N/A

  • Default value: N/A

tunnel_info

TunnelInfoResult object

  • Definition: Local tunnel information.

  • Constraints: N/A

  • Range: N/A

  • Default value: N/A

charge_infos

PostPaidChargeInfos object

  • Definition: Billing information.

  • Constraints: N/A

  • Range: N/A

  • Default value: N/A

availability_zones

AvailabilityZones object

  • Definition: AZ where the enterprise switch node is located.

  • Constraints: N/A

  • Range: AZs in the current region.

  • Default value: N/A

Table 9 TunnelInfoResult

Parameter

Type

Description

vpc_id

String

  • Definition: ID of the VPC where the enterprise switch is created.

  • Constraints:

    • You need to use the IDs of the VPCs that you can manage.

    • The value is in the UUID format with hyphens (-).

  • Range: N/A

  • Default value: N/A

virsubnet_id

String

  • Definition: ID of the tunnel subnet where the enterprise switch is located.

  • Constraints:

    • You need to use the IDs of the subnets that you can manage. The ID is the network ID in the subnet details.

    • The value is in the UUID format with hyphens (-).

  • Range: N/A

  • Default value: N/A

tunnel_ip

String

  • Definition: Local tunnel IP address of the enterprise switch.

  • Constraints: The value cannot conflict with an existing subnet IP address.

  • Range: A standard IPv4 address, for example, 192.168.1.1.

  • Default value: N/A

tunnel_port

Integer

  • Definition: Tunnel port of the enterprise switch.

  • Constraints: N/A

  • Range: 4789

  • Default value: N/A

tunnel_type

String

  • Definition: The tunnel protocol type of the enterprise switch.

  • Constraints: N/A

  • Range: vxlan

  • Default value: N/A

Table 10 PostPaidChargeInfos

Parameter

Type

Description

charge_mode

String

  • Definition: Billing mode.

  • Constraints: N/A

  • Range: postPaid, indicates the pay-per-use billing mode.

  • Default value: N/A

Table 11 AvailabilityZones

Parameter

Type

Description

primary

String

  • Definition: AZ where the default active node of the enterprise switch is located.

  • Constraints: The value can contain 1 to 128 characters.

  • Range: ID of the AZ in the current region.

  • Default value: N/A

standby

String

  • Definition: AZ where the default standby node of the enterprise switch is located.

  • Constraints: The value can contain 1 to 128 characters.

  • Range: ID of the AZ in the current region.

  • Default value: N/A

Example Requests

POST https://{endpoint}/v3/b2782e6708b8475c993e6064bc456bf8/l2cg/instances

{
  "instance" : {
    "availability_zones" : {
      "primary" : "az1",
      "standby" : "az2"
    },
    "charge_infos" : {
      "charge_mode" : "postPaid"
    },
    "flavor_ref" : "l2cg.small.ha",
    "ha_mode" : "ha",
    "name" : "esw-88d4",
    "tunnel_info" : {
      "vpc_id" : "6ae030de-f630-476e-8284-7bcfbd94929d",
      "virsubnet_id" : "6c32956f-eb3a-4521-8b83-d5a2d5f9b978"
    },
    "description" : ""
  }
}

Example Responses

Status code: 201

The POST operation is successful. For more status codes, see Status Codes.

{
  "request_id" : "2f1bdab599c96eb0b47a5e99ba9574bb",
  "job_id" : "9bd12abc-17ba-4e40-9484-f4e97ee7ff59",
  "instance" : {
    "name" : "esw-88d4",
    "id" : "87fea8df-3e0d-473a-a1bd-e6a76157f4ce",
    "region" : "cn-north-213",
    "status" : "build",
    "description" : null,
    "created_at" : "2025-07-28T03:45:05Z",
    "updated_at" : "2025-07-28T03:45:05Z",
    "project_id" : "dd9e484e058b48e18b820948dcbd480e",
    "flavor_ref" : "l2cg.small.ha",
    "ha_mode" : "ha",
    "availability_zones" : {
      "standby" : "az1",
      "primary" : "az2"
    },
    "charge_infos" : {
      "charge_mode" : "postPaid"
    },
    "tunnel_info" : {
      "vpc_id" : "6ae030de-f630-476e-8284-7bcfbd94929d",
      "virsubnet_id" : "6c32956f-eb3a-4521-8b83-d5a2d5f9b978",
      "tunnel_ip" : "192.168.7.95",
      "tunnel_port" : 4789,
      "tunnel_type" : "vxlan"
    }
  }
}

Status Codes

Status Code

Description

201

The POST operation is successful. For more status codes, see Status Codes.

Error Codes

See Error Codes.