All Products
Search
Document Center

Virtual Private Cloud:CreateIpv4Gateway

Last Updated:Aug 28, 2026

Creates an IPv4 gateway.

Operation description

  • CreateIpv4Gateway is an asynchronous operation. After a request is sent, the system returns a request ID and runs the task in the background. You can call GetIpv4GatewayAttribute to query the status of an IPv4 gateway:

    • If the IPv4 gateway is in the Creating state, it is being created.

    • If the IPv4 gateway is in the Created state, it is created.

  • You cannot repeatedly call CreateIpv4Gateway to create IPv4 gateways in a virtual private cloud (VPC) within a specific period of time.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

No authorization for this operation. If you encounter issues with this operation, contact technical support.

Request parameters

Parameter

Type

Required

Description

Example

Ipv4GatewayName

string

No

The name of the IPv4 gateway.

The name must be 1 to 128 characters in length, and cannot start with http:// or https://.

ipv4

Ipv4GatewayDescription

string

No

The description of the IPv4 gateway.

The description must be 1 to 256 characters in length and cannot start with http:// or https://.

test

VpcId

string

Yes

The ID of the VPC where you want to create the IPv4 gateway.

You can create only one IPv4 gateway in a VPC.

vpc-5tss06uvoyps5xoya****

DryRun

boolean

No

Specifies whether to perform a dry run. Valid values:

  • true: performs a dry run. The system checks the required parameters, request syntax, and limits. If the request fails the dry run, an error message is returned. If the request passes the dry run, the DryRunOperation error code is returned.

  • false (default): performs a dry run and sends the request. If the request passes the dry run, a 2xx HTTP status code is returned and the operation is performed.

false

ClientToken

string

No

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

You can use the client to generate the token value, but you must ensure that it is unique across requests. ClientToken can contain only ASCII characters.

Note

If you do not specify this parameter, the system automatically uses the RequestId value as the ClientToken. The RequestId of each API request is unique.

123e4567-e89b-12d3-a456-426655440000

RegionId

string

Yes

The ID of the region where you want to create the IPv4 gateway.

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

ap-southeast-6

ResourceGroupId

string

No

The ID of the resource group.

rg-acfmxazb4ph6aiy****

Tag

array<object>

No

The tags of the resource.

object

No

Key

string

No

The tag key. You can specify up to 20 tag keys. The tag key cannot be an empty string.

The tag key can be up to 128 characters in length. It cannot start with aliyun or acs:, and cannot contain http:// or https://.

FinanceDept

Value

string

No

The tag value. You can specify up to 20 tag values. The tag value can be an empty string.

The tag value can be up to 128 characters in length and cannot contain http:// or https://. It cannot start with aliyun or acs:.

FinanceJoshua

RegionId

string

Yes

The ID of the region where you want to create the IPv4 gateway.

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

ap-southeast-6

Response elements

Element

Type

Description

Example

object

Ipv4GatewayId

string

The ID of the IPv4 gateway.

ipv4gw-5tsnc6s4ogsedtp3k****

ResourceGroupId

string

The ID of the resource group.

rg-acfmxazb4ph6aiy****

RequestId

string

The ID of the request.

F282742B-1BBB-5F63-A3AF-E92EC575A1A6

Examples

Success response

JSON format

{
  "Ipv4GatewayId": "ipv4gw-5tsnc6s4ogsedtp3k****",
  "ResourceGroupId": "rg-acfmxazb4ph6aiy****",
  "RequestId": "F282742B-1BBB-5F63-A3AF-E92EC575A1A6"
}

Error codes

HTTP status code

Error code

Error message

Description

400 OperationDenied.ExistDirectEip The operation is not allowed because of existing direct eip. You are not allowed to create an IPv4 gateway because an EIP in cut-through mode exists.
400 UnsupportedRegion The feature of ipv4Gateway is not supported in the region. IPv4 gateways are not supported in this region.
400 Forbidden.OperateShareResource You cannot operate shared resources. Shared resources do not support this operation.
400 OperationDenied.SubnetRouteV1Exist The operation is not allowed because of existing subnetRouteV1. The subnet routes in the VPC do not meet the requirements.
400 OperationDenied.NormalNatExist The operation is not allowed because of existing normalNat. Standard NAT gateways are deployed in the specified VPC.
400 OperationDenied.VpcExistIpv4Gateway An IPv4 gateway already exists in the VPC. You are not allowed to create an IPv4 gateway in the VPC because an IPv4 gateway already exists in the VPC.
400 UnsupportedFeature.Ipv4Gateway The feature of ipv4Gateway is not supported for [%s]. The system failed to create the IPv4 gateway because IPv4 gateways are not supported.
400 OperationDenied.VpnExist The operation is not allowed because of existing vpn. You are not allowed to create an IPv4 gateway because a VPN gateway already exists in the VPC.
400 OperationDenied.DirectEipExist The operation is not allowed because of existing directEip. EIPs are associated with the VPC in cut-through mode or enhanced NAT gateways are deployed in the VPC.
400 OperationFailed.GetNfvServiceList The operation is failed because of get nfv serviceList failed. Failed to obtain the nfc service list.
400 IncorrectStatus.Vpc The status of %s [%s] is incorrect. The instance is in an invalid state.
400 OperationFailed.VpcNotExist The operation is failed because of vpc is not found. The operation failed because the VPC is not found.
400 IllegalParam.ResourceGroupId Invalid ResourceGroupld value. The specified resource group is invalid or does not exist.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.