Create subnet
Updated at:2025-10-16
Description
Create a subnet in your VPC.
- To create a subnet within the secondary network segment of a VPC, the parameter vpcSecondaryCidr must be specified
Request structure
Plain Text
1 POST /v{version}/subnet?clientToken={clientToken} HTTP/1.1
2 Host: bcc.bj.baidubce.com
3 Authorization: authorization string
4 {
5 "zoneName": "cn-bj-a",
6 "subnetType": "BCC",
7 "name": "subnet",
8 "description": "",
9 "enableIpv6": true,
10 "cidr": "172.17.1.0/24",
11 "vpcId": "vpc-IyrqYIQ7",
12 "vpcSecondaryCidr":"172.17.0.0/16",
13 "tags":[
14 {
15 "tagKey": "tagKey",
16 "tagValue": "tagValue"
17 }
18 ]
19 }
Request headers
There are no special headers required beyond the common headers.
Request parameters
| Parameter name | Types | Whether required | Parameter location | Description |
|---|---|---|---|---|
| version | String | Yes | URL parameter | For API version No., the current value is 1 |
| clientToken | String | No | Query | Idempotence Token, which is an ASCII string with a length not exceeding 64 bits, see details in [ClientToken Idempotence Support](VPC/API Reference/General Description.md#Idempotence). |
| name | String | Yes | Request Body parameters | Subnet name, which cannot be set as "default", must not exceed 65 characters, and may consist of numbers, letters, and underscores |
| enableIpv6 | Boolean | No | RequestBody | Whether to enable the IPv6 segment, with true for “enable” and false for “disable” (default) |
| zoneName | String | Yes | Request Body parameters | Available zone name, refer to [Query Availability Zone List](BCC/API Reference/Region and Availability Zone Related Interfaces/Query list of availability zones.md) for query method |
| cidr | String | Yes | Request Body parameters | Subnet CIDR, which must fall within the VPC segment range |
| vpcId | String | Yes | Request Body parameters | ID of VPC to which the subnet belongs |
| vpcSecondaryCidr | String | No | Request Body parameters | CIDR of the secondary network segment of the VPC to which the subnet belongs |
| subnetType | String | No | Request Body parameters | Subnet type: "BCC", "BCC_NAT", "BBC" |
| description | String | No | Request Body parameters | Description, not exceeding 200 characters |
| tags | List<[TagModel](VPC/API Reference/Appendix.md#TagModel)> | No | Request Body parameters | List of tag key-value pairs to be created |
Response headers
No special headers beyond common headers
Response parameters
| Parameter name | Types | Description |
|---|---|---|
| subnetId | String | ID of subnet created |
Request example
Plain Text
1 POST /v1/subnet?clientToken=cecad37a-5a1e-4135-a1bc-b1a105d12dec HTTP/1.1
2 Host: bcc.bj.baidubce.com
3 Content-Type: application/json;charset=UTF-8
4 Authorization: bce-auth-v1/f81d3b34e48048fbb2634dc7882d7e21/2015-08-11T04:17:29Z/3600/host/74c506f68c65e26c633bfa104c863fffac5190fdec1ec24b7c03eb5d67d2e1de
5 {
6 "zoneName": "cn-bj-a",
7 "subnetType": "BCC",
8 "name": "subnet",
9 "description": "this is a subnet",
10 "enableIpv6": true,
11 "cidr": "192.168.0.0/20",
12 "vpcId": "vpc-IyrqYIQ7",
13 "tags":[
14 {
15 "tagKey": "tagKey",
16 "tagValue": "tagValue"
17 }
18 ]
19 }
Response example
Plain Text
1 HTTP/1.1 200 OK
2 x-bce-request-id: 1214cca7-4ad5-451d-9215-71cb844c0a50
3 Date: Thu, 16 Mar 2017 06:29:48 GMT
4 Content-Type: application/json;charset=UTF-8
5 Server: BWS
6{
7 "subnetId":"sbn-1A09ef6b"
8}
