Updated on 2025-12-04 GMT+08:00

Creating a Layer 2 Connection

Function

This API is used to create a Layer 2 connection for an enterprise switch.

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:connection:create

Write

-

-

-

-

URI

POST /v3/{project_id}/l2cg/instances/{instance_id}/connections

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

instance_id

Yes

String

  • Definition: Unique ID of an enterprise switch.

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

  • Range: N/A

  • Default value: N/A

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

connection

Yes

CreateConnectionOption object

  • Definition: Request body for creating a Layer 2 connection.

  • Constraints: N/A

  • Range: N/A

  • Default value: N/A

Table 3 CreateConnectionOption

Parameter

Mandatory

Type

Description

fixed_ips

No

Array of strings

  • Definition: Active and standby interface IP addresses used by the enterprise switch in the local Layer 2 subnet.

  • Constraints: The value is a string list. You can configure two strings in the standard IPv4 format. The IP address must be in the CIDR block of the Layer 2 subnet.

  • Range: N/A

  • Default value: N/A

name

Yes

String

  • Definition: Layer 2 connection name.

  • 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

remote_infos

Yes

Array of RemoteInfosOption objects

  • Definition: Remote tunnel information.

  • Constraints: N/A

  • Range: N/A

  • Default value: N/A

virsubnet_id

Yes

String

  • Definition: ID of the Layer 2 subnet associated with the Layer 2 connection.

  • 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

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

Table 4 RemoteInfosOption

Parameter

Mandatory

Type

Description

segmentation_id

Yes

Integer

  • Definition: The tunnel ID of the Layer 2 connection, also the VXLAN network identifier (VNI).

  • Constraints: The value must be the same as the VNI configured for the remote VXLAN.

  • Range: 1 to 16777216

  • Default value: N/A

tunnel_ip

Yes

String

  • Definition: The remote tunnel IP address of the enterprise switch.

  • Constraints: The value must be the same as the VTEP IP address configured for the remote VXLAN.

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

  • Default value: N/A

tunnel_port

No

Integer

  • Definition: The remote tunnel port of the Layer 2 connection.

  • Constraints: N/A

  • Range: 4789

  • Default value: N/A

Response Parameters

Status code: 201

Table 5 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

connection

Connection object

  • Definition: Response body for creating a Layer 2 connection.

  • Constraints: N/A

  • Range: N/A

  • Default value: N/A

Table 6 Connection

Parameter

Type

Description

fixed_ips

Array of strings

  • Definition: Active and standby interface IP addresses used by the enterprise switch in the local Layer 2 subnet.

  • Constraints: The value is a string list. You can configure two strings in the standard IPv4 format. The IP address must be in the CIDR block of the Layer 2 subnet.

  • Range: N/A

  • Default value: N/A

id

String

  • Definition: ID of a Layer 2 connection.

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

  • Range: N/A

  • Default value: N/A

instance_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: Layer 2 connection name.

  • 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

remote_infos

Array of RemoteInfosResult objects

  • Definition: Remote tunnel information.

  • Constraints: N/A

  • Range: N/A

  • Default value: N/A

status

String

  • Definition: Status of the Layer 2 connection.

  • Constraints: N/A

  • Range:

    • pending: The Layer 2 connection is being created.

    • connected: The Layer 2 connection is connected.

    • disconnect: The Layer 2 connection is disconnected.

    • failed: Failed to create the Layer 2 connection.

    • abnormal: The Layer 2 connection is abnormal.

  • Default value: N/A

virsubnet_id

String

  • Definition: ID of the Layer 2 subnet associated with the Layer 2 connection.

  • 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

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

created_at

String

  • Definition: Time when the Layer 2 connection 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 Layer 2 connection 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

Table 7 RemoteInfosResult

Parameter

Type

Description

segmentation_id

Integer

  • Definition: The tunnel ID of the Layer 2 connection, also the VXLAN network identifier (VNI).

  • Constraints: The value must be the same as the VNI configured for the remote VXLAN.

  • Range: 1 to 16777216

  • Default value: N/A

tunnel_ip

String

  • Definition: The remote 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: The remote tunnel port of the Layer 2 connection.

  • 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

Example Requests

POST https://{endpoint}/v3/dd9e484e058b48e18b820948dcbd480e/l2cg/instances/87fea8df-3e0d-473a-a1bd-e6a76157f4ce/connections

{
  "connection" : {
    "virsubnet_id" : "2c649856-0d44-400c-8194-f6d67603e0eb",
    "fixed_ips" : [ "192.168.0.11", "192.168.0.12" ],
    "name" : "l2conn-7a0c",
    "remote_infos" : [ {
      "tunnel_port" : 4789,
      "segmentation_id" : 7127,
      "tunnel_ip" : "192.168.111.111"
    } ],
    "vpc_id" : "6ae030de-f630-476e-8284-7bcfbd94929d"
  }
}

Example Responses

Status code: 201

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

{
  "request_id" : "318ad7fa0bae74f2b0a22b44d6740309",
  "connection" : {
    "name" : "l2conn-7a0c",
    "id" : "555fe9b7-62fe-48c6-a73d-a62413f110f1",
    "status" : "pending",
    "created_at" : "2025-07-28T08:39:59Z",
    "updated_at" : "2025-07-28T08:39:59Z",
    "project_id" : "dd9e484e058b48e18b820948dcbd480e",
    "instance_id" : "87fea8df-3e0d-473a-a1bd-e6a76157f4ce",
    "vpc_id" : "6ae030de-f630-476e-8284-7bcfbd94929d",
    "virsubnet_id" : "2c649856-0d44-400c-8194-f6d67603e0eb",
    "fixed_ips" : [ "192.168.0.11", "192.168.0.12" ],
    "remote_infos" : [ {
      "segmentation_id" : 7127,
      "tunnel_ip" : "192.168.111.111",
      "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.