Creates a virtual private cloud (VPC).

Usage notes

When you call this operation, take note of the following rules:

  • You can specify only one CIDR block for each VPC.
  • After you create a VPC, you cannot change its CIDR block. However, you can add secondary IPv4 CIDR blocks to the VPC.
  • In each VPC, cloud services can use a maximum of 60,000 private IP addresses. You cannot increase the quota.
  • After you create a VPC, a vRouter and a route table are automatically created.
  • At most three user CIDR blocks can be added to a VPC. If a user CIDR block includes another user CIDR block, the one with the shorter subnet mask takes effect. For example, if 10.0.0.0/8 and 10.1.0.0/16 are specified, only 10.0.0.0/8 takes effect.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes CreateVpc

The operation that you want to perform. Set the value to CreateVpc.

RegionId String Yes cn-hangzhou

The region ID of the VPC.

You can call the DescribeRegions operation to query the most recent region list.

CidrBlock String No 172.16.0.0/12

The CIDR block of the VPC.

  • You can specify one of the following CIDR blocks or their subsets as the primary IPv4 CIDR block of the VPC: 192.168.0.0/16, 172.16.0.0/12, and 10.0.0.0/8. These CIDR blocks are standard private CIDR blocks as defined by Request for Comments (RFC) documents. The subnet mask must be 8 to 28 bits in length.
  • You can also use a custom CIDR block other than 100.64.0.0/10, 224.0.0.0/4, 127.0.0.0/8, 169.254.0.0/16, and their subnets as the primary IPv4 CIDR block of the VPC.
Ipv6CidrBlock String No 2408:XXXX:0:6a::/56

The IPv6 CIDR blocks of the VPC.

EnableIpv6 Boolean No false

Specifies whether to enable IPv6. Valid values:

  • false (default): disables IPv6
  • true: enables IPv6
VpcName String No abc

The name of the VPC.

The name must be 2 to 128 characters in length and can contain digits, periods (.), underscores (_), and hyphens (-). The name must start with a letter.

Description String No This is my first Vpc

The description of the VPC.

The description must be 2 to 256 characters in length. The description must start with a letter but cannot start with http:// or https://.

ResourceGroupId String No rg-acfmxazb4ph6aiy****

The ID of the resource group.

For more information about resource groups, see What is a resource group?.

DryRun Boolean No false

Specifies whether to check the request without performing the operation. Valid values:

  • true: checks the request without creating the VPC. The system checks the required parameters, request syntax, and limits. If the request fails the check, an error message is returned. If the request passes the check, the DryRunOperation error code is returned.
  • false (default): sends the API request. After the request passes the check, a 2xx HTTP status code is returned and the VPC is created.
UserCidr String No 192.168.0.0/12

The user CIDR block. Separate user CIDR blocks with commas (,). You can specify up to three user CIDR blocks.

For more information about user CIDR blocks, see the What is a user CIDR block? section in VPC FAQ.

ClientToken String No 123e4567-e89b-12d3-a456-426655440000

The client token that is used to ensure the idempotence of the request.

You can use the client to generate the value, but you must make sure that the value is unique among different requests. The token can contain only ASCII characters and cannot exceed 64 characters in length.

Note If you do not set this parameter, the system automatically uses RequestId as ClientToken. RequestId may be different for each API request.
Ipv6Isp String No BGP

The type of the IPv6 CIDR block of the VPC. Valid values:

  • BGP (default): an IPv6 CIDR block provided by Alibaba Cloud over Border Gateway Protocol (BGP)
  • ChinaMobile: an IPv6 CIDR block provided by China Mobile (single ISP)
  • ChinaUnicom: an IPv6 CIDR block provided by China Unicom (single ISP)
  • ChinaTelecom: an IPv6 CIDR block provided by China Telecom (single ISP)
Note If your Alibaba Cloud account is allowed to activate single-ISP bandwidth, you can set this parameter to ChinaTelecom, ChinaUnicom, or ChinaMobile.

Response parameters

Parameter Type Example Description
VpcId String vpc-bp15zckdt37pq72zv****

The ID of the VPC.

VRouterId String vrt-bp1lhl0taikrteen8****

The ID of the vRouter that is automatically created by the system after the VPC is created.

RequestId String 0ED8D006-F706-4D23-88ED-E11ED28DCAC0

The ID of the request.

RouteTableId String vtb-bp145q7glnuzdv****

The ID of the route table that is automatically created by the system after the VPC is created.

ResourceGroupId String rg-acfmxazb4ph6aiy****

The ID of the resource group.

Examples

Sample requests

http(s)://[Endpoint]/?Action=CreateVpc
&ResourceOwnerId=1111
&RegionId=cn-hangzhou
&CidrBlock=172.16.0.0/12
&Ipv6CidrBlock=2408:XXXX:0:6a::/56
&EnableIpv6=false
&VpcName=abc
&Description=This is my first Vpc
&ResourceGroupId=rg-acfmxazb4ph6aiy****
&DryRun=false
&UserCidr=192.168.0.0/12
&ClientToken=123e4567-e89b-12d3-a456-426655440000
&Ipv6Isp=BGP
&Common request parameters

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<CreateVpcResponse>
    <VpcId>vpc-bp15zckdt37pq72zv****</VpcId>
    <VRouterId>vrt-bp1lhl0taikrteen8****</VRouterId>
    <RequestId>0ED8D006-F706-4D23-88ED-E11ED28DCAC0</RequestId>
    <RouteTableId>vtb-bp145q7glnuzdv****</RouteTableId>
    <ResourceGroupId>rg-acfmxazb4ph6aiy****</ResourceGroupId>
</CreateVpcResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "VpcId" : "vpc-bp15zckdt37pq72zv****",
  "VRouterId" : "vrt-bp1lhl0taikrteen8****",
  "RequestId" : "0ED8D006-F706-4D23-88ED-E11ED28DCAC0",
  "RouteTableId" : "vtb-bp145q7glnuzdv****",
  "ResourceGroupId" : "rg-acfmxazb4ph6aiy****"
}

Error codes

HttpCode Error code Error message Description
400 InvalidParameter Specified CIDR block is not valid The error message returned because the specified CIDR block is invalid.
400 ResourceNotAvailable Resource you requested is not available in this region or zone. The error message returned because you cannot create a vSwitch in the current region or zone.
400 InvalidVpcName.Malformed Specified VPC name is not valid. The error message returned because the format of the VPC name is invalid. Enter a valid VPC name and try again.
400 InvalidVpcDiscription.Malformed Specified VPC description is not valid. The error message returned because the format of the VPC description is invalid.
400 QuotaExceeded.Vpc VPC quota exceeded. The error message returned because the number of VPCs that belong to the Alibaba Cloud account has reached the upper limit. Submit a ticket to request a quota increase.
400 ResourceNotAvailable.Vpc Resource you requested is not available in this region or zone. The error message returned because the requested resource is unavailable in this region or zone.
400 InvalidParameter Specified UserCidr invalid format. The error message returned because the format of the user CIDR block is invalid.
400 InvalidParameter Specified UserCidr Subnet mask is not valid . The error message returned because the subnet mask of the user CIDR block is invalid.
400 InvalidUserCidr.Quota Specified UserCidr number is greater than 3. The error message returned because the number of user CIDR blocks that you specify has reached the upper limit.
400 InvalidUserCidr.Malformed Specified UserCidr overlapping in of 100.64.0.0/10. The error message returned because the user CIDR block that you specify overlaps with 100.64.0.0/10.
400 InvalidResourceGroupId The specified ResourceGroupId does not exist. The error message returned because the specified resource group ID is invalid.
400 OperationUnsupported.ResourceGroupId ResourceGroup is not supported in this region. The error message returned because the resource group feature is disabled.
500 InternalError The request processing has failed due to some unknown error. The error message returned because an unknown error occurred.
403 Forbbiden User not authorized to operate on the specified resource. The error message returned because you are unauthorized to perform this operation on the specified resource. Apply for the required permissions and try again.
404 InvalidRegionId.NotFound Specified value of "regionId" is not supported. The error message returned because RegionId is set to an invalid value. Check whether the service is available in the specified region.

For a list of error codes, visit the API Error Center.