All Products
Search
Document Center

NAT Gateway:CreateNatIp

Last Updated:Jun 26, 2026

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

Operation description

CreateNatIp is an asynchronous operation. After you call this operation, the system returns a NAT IP address, but the NAT IP address is not yet created. The creation task is still running in the background. You can call ListNatIps to query the 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.

CreateNatIp 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 VPC NAT gateway instance to which the NAT IP address belongs.

You can call DescribeRegions to query 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 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 Chinese character. It cannot start with http:// or https://.

test

DryRun

boolean

No

Specifies whether to perform a dry run. Valid values:

  • true: performs a dry run. The system checks the AccessKey pair, the authorization of the Resource Access Management (RAM) user, and the required parameters. 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): sends a Normal request. If the request passes the dry run, a 2xx HTTP status code is returned and the NAT IP address is created.

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 token, but you must make sure that the token is unique among different requests. The ClientToken value can contain only ASCII characters.

Note

If you do not specify this parameter, the system uses the RequestId of the API request as the ClientToken. The RequestId may be different for each API request.

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

NatIpCidr

string

Yes

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

192.168.0.0/24

NatIp

string

No

The NAT IP address to create.

If you do not specify this parameter, the system randomly assigns an IP address from the NAT CIDR block.

192.168.0.34

RegionId

string

Yes

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

You can call DescribeRegions to query the region ID.

eu-central-1

Ipv4Prefix

string

No

The IP prefix CIDR block to create.

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

192.168.0.0/28

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 NAT IP address that is created.

NatIp

string

The NAT IP address that is created.

192.168.0.34

RequestId

string

The request ID.

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

NatIpId

string

The instance ID of the NAT IP address that is created.

vpcnatip-gw8y7q3cpk3fggs8****

Ipv4Prefix

string

The IPv4 prefix returned by the legacy operation. This parameter is deprecated.

""

NatIps

array<object>

The NAT IP address information returned after the NAT IP address is created. When you create a NAT IP address by using an IPv4 prefix, all NAT IP address information is returned. When you create a single NAT IP address, we recommend that you use this parameter to obtain the NAT IP address information.

object

The list of NAT IP addresses created when an IPv4 prefix is used.

NatIp

string

The NAT IP address in the list of NAT IP addresses created when an IPv4 prefix is used.

192.168.2.128

NatIpId

string

The NAT IP address ID in the list of NAT IP addresses created when an IPv4 prefix is used.

vpcnatip-xxxxxxxx

Ipv4Prefix

string

The IPv4 prefix in the list of NAT IP addresses created when an IPv4 prefix is used.

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.
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. The resource Ipv4Prefix does not exist.
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.