All Products
Search
Document Center

NAT Gateway:CreateNatIp

Last Updated:Oct 26, 2026

Creates a NAT IP address for a VPC NAT gateway instance.

Operation description

The CreateNatIp operation is asynchronous. The system returns a NAT IP address before the creation process is complete, and the backend task continues to run. You can call the ListNatIps operation to query the creation status of the NAT IP address:

  • If the NAT IP address is in the Creating state, the NAT IP address is being created. In this state, you can only perform query operations.

  • If the NAT IP address is in the Available state, the NAT IP address is created.

The CreateNatIp operation does not support concurrent creation of NAT IP addresses within the same NAT gateway.

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

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

vpc:CreateNatIp

create

*NatGateway

acs:vpc:{#regionId}:{#accountId}:natgateway/{#NatGatewayId}

None None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The region ID of the NAT gateway instance to which the NAT IP address belongs.

You can call the DescribeRegions operation to obtain the region ID.

eu-central-1

NatGatewayId

string

Yes

The instance ID of the VPC NAT gateway to which the NAT IP address belongs.

ngw-gw8v16wgvtq26vh59****

NatIpName

string

No

The name of the NAT IP address.

The name must be 2 to 128 characters in length, and must start with a letter or a Chinese character. It can contain digits, periods (.), underscores (_), and hyphens (-). It cannot start with http:// or https://.

newnatip

NatIpDescription

string

No

The description of the NAT IP address.

The description must be 2 to 256 characters in length, and must start with a letter or a Chinese character. It cannot start with http:// or https://.

test

DryRun

boolean

No

Specifies whether to perform a dry run on the request. Valid values:

  • true: The system performs a dry run on the request without creating the NAT IP address. The system checks whether your AccessKey pair is valid, whether the Resource Access Management (RAM) user has the required authorization, and whether the required parameters are specified. If the request fails the dry run, the system returns an error. If the request passes the dry run, the system returns the DryRunOperation error code.

  • false (default): The system sends a normal request. If the request passes the dry run, the system returns a 2xx HTTP status code and creates the NAT IP address.

false

ClientToken

string

No

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

You can use the client to generate the value, and you must ensure that the value is unique among different requests. The client token can contain only ASCII characters.

Note

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

5A2CFF0E-5718-45B5-9D4D-70B3FF3898

NatIpCidr

string

Yes

The CIDR block from which the NAT IP address is created.

192.168.0.0/24

NatIp

string

No

The NAT IP address to be created.

If you do not specify an IP address, the system randomly allocates an IP address from your NAT CIDR block.

192.168.0.34

RegionId

string

Yes

The IP prefix CIDR block to be created.

The IP prefix CIDR block must fall within the reserved CIDR block of the vSwitch where the NAT gateway resides, and the reserved CIDR block must not be occupied. The mask of the IP prefix must be /28.

192.168.0.0/28

Ipv4Prefix

string

No

The number of IP prefixes to be automatically allocated.

The IP prefixes are randomly allocated from the unassigned reserved CIDR block of the vSwitch where the NAT gateway resides. Valid values: 1 to 10.

1

Ipv4PrefixCount

integer

No

The number of IP prefixes to automatically assign.

The IP prefixes are randomly assigned from unallocated reserved CIDR blocks of the vSwitch where the NAT gateway resides. Valid values: 1 to 10.

1

Response elements

Element

Type

Description

Example

object

The created NAT IP address.

NatIp

string

The created NAT IP address.

192.168.0.34

RequestId

string

The request ID.

E9AD97A0-5338-43F8-8A80-5E274CCBA11B

NatIpId

string

The instance ID of the created NAT IP address.

vpcnatip-gw8y7q3cpk3fggs8****

Ipv4Prefix

string

[Deprecated] The Ipv4Prefix returned by the legacy operation. This parameter is deprecated.

""

NatIps

array<object>

The NatIp parameter returned after a NAT IP address is created. If you use an IPv4 prefix to create NAT IP addresses, all NAT IP address information is returned. We recommend that you use this parameter to obtain NAT IP address information even when you create a single NAT IP address.

object

The NatIpList returned when an IPv4 prefix is created.

NatIp

string

The NAT IP address in the NatIpList returned when an IPv4 prefix is created.

192.168.2.128

NatIpId

string

The NatIpId in the NatIpList returned when an IPv4 prefix is created.

vpcnatip-xxxxxxxx

Ipv4Prefix

string

The Ipv4Prefix in the NatIpList returned when an IPv4 prefix is created.

192.168.1.128/28

Examples

Success response

JSON format

{
  "NatIp": "192.168.0.34",
  "RequestId": "E9AD97A0-5338-43F8-8A80-5E274CCBA11B",
  "NatIpId": "vpcnatip-gw8y7q3cpk3fggs8****",
  "Ipv4Prefix": "\"\"",
  "NatIps": [
    {
      "NatIp": "192.168.2.128",
      "NatIpId": "vpcnatip-xxxxxxxx",
      "Ipv4Prefix": "192.168.1.128/28"
    }
  ]
}

Error codes

HTTP status code

Error code

Error message

Description

400 Mismatch.NatIpAndNatIpCidr The %s and %s are mismatched. The specified %s and %s do not match.
400 ResourceNotFound.NatGateway The specified resource of %s is not found.
400 ResourceNotFound.NatIpCidr The specified resource of %s is not found. The specified %s resource does not exist.
400 IncorrectStatus.NatGateway %The status of %s [%s] is incorrect. The NAT gateway is in an invalid state.
400 QuotaExceeded.NatIp The quota of %s is exceeded, usage %s/%s. NatIp and Ipv4Prefix quota use overflow.
400 ResourceNotEnough.SwitchAvailableIps The available private Ip number is not enough in your subnet. The number of private IP addresses in the subnet is insufficient.
400 ResourceNotEnough.NatIp The specified resource of NatIp is not enough. Insufficient IP addresses in the specified CIDR block.
400 ResourceAlreadyExist.NatIp The specified resource of NatIp has already exist. Configured NatIp already exists
400 Mismatch.Ipv4PrefixAndNatIpCidr The %s and %s are mismatched. The Ipv4Prefix and NatIpCidr are mismatched.
400 Mismatch.Ipv4PrefixAndCidrReservations The %s and %s are mismatched. The reserved network segments of the Ipv4Prefix and VSwitch do not match.
400 ResourceAlreadyAssociated.Ipv4Prefix %s is already associated. Ipv4Prefix have been allocated.
400 ResourceNotEnough.Ipv4Prefix The resource of %s is not enough. Insufficient Ipv4Prefix resources.
400 ResourceNotFound.Ipv4Prefix The resource of s% is not found.
400 ResourceAlreadyAssociated.NatIp The resource of %s was already associated. NatIp resources have been allocated.
400 ResourceNotFound.NatIp The specified resource of %s is not found. The specified NatIp parameter is not found.
400 IllegalParam.Ipv4Prefix The param of %s is illegal, must be /28 network segment. The parameter Ipv4Prefix is invalid and must be/28 network segment.
400 ResourceAlreadyExist.Ipv4Prefix The specified resource of %s is already exist. This Ipv4Prefix has already been created. Do not re-create it.
400 QuotaExceeded.Ipv4Prefix The quota of %s is exceeded, usage %s/%s. Ipv4Prefix quota usage overflow.
400 OperationFailed.InstanceNotSupport natgateway not support ipv4prefix. The gateway does not support Ipv4Prefix.
404 InvalidRegionId.NotFound The specified RegionId does not exist in our records.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.