pydo.vpcnatgateways.create()

Generated on 1 Oct 2026 from pydo version v0.43.0

Usage

client.vpcnatgateways.create(
    body={
        "name": "my-vpc-nat-gateway",
        "type": "PUBLIC",
        "region": "tor1",
        ...,
    },
)
Returns JSONRaises HttpResponseError

Description

To create a new VPC NAT gateway, send a POST request to /v2/vpc_nat_gateways setting the required attributes.

The response body will contain a JSON object with a key called vpc_nat_gateway containing the standard attributes for the new VPC NAT gateway.

Parameters

name string required

Example: my-vpc-nat-gateway

The human-readable name of the VPC NAT gateway.

type string required

Example: PUBLIC

The type of the VPC NAT gateway.

region string required

The region in which the VPC NAT gateway is created.

One of: nyc1, nyc2, nyc3, ams2, ams3, sfo1, sfo2, sfo3, sgp1, lon1, fra1, tor1, blr1, syd1, atl1

size integer required

Example: 1

The size of the VPC NAT gateway.

vpcs array of objects required

An array of VPCs associated with the VPC NAT gateway.

Show child properties
vpc_uuid string required

Example: 0d3db13e-a604-4944-9827-7ec2642d32ac

The unique identifier of the VPC to which the NAT gateway is attached.

subnet_uuid string optional

Example: cbd79771-23eb-49be-b5ea-59cc56222622

The unique identifier of the VPC subnet to which the NAT gateway is attached.

default_gateway boolean optional

Example: True

The classification of the NAT gateway as the default egress route for the VPC traffic.

udp_timeout_seconds integer optional

Example: 30

The UDP timeout in seconds for the VPC NAT gateway.

icmp_timeout_seconds integer optional

Example: 30

The ICMP timeout in seconds for the VPC NAT gateway.

tcp_timeout_seconds integer optional

Example: 30

The TCP timeout in seconds for the VPC NAT gateway.

egresses object optional

An optional object specifying the public egress IP address to assign to the VPC NAT gateway. Provide this only to use a specific address. If omitted, DigitalOcean allocates a public IP address automatically.

Show child properties
public_gateways array of objects optional

An array containing a single public gateway object that sets the gateway's public egress IP address.

Show child properties
ip string optional

Example: 203.0.113.42

The public egress IP address to assign to the VPC NAT gateway, and the preferred field for setting it. Provide an unassigned Bring Your Own IP (BYOIP) address on your account in the same region to use your own IP address. This field is only applied when creating the gateway and cannot be changed afterward. The assigned address is returned as ipv4 in GET and list responses.

ipv4 string optional

Example: 203.0.113.42

An alternative to ip for setting the public egress IP address on create. Accepts the same value as ip, which takes precedence if both are provided. This field is only applied when creating the gateway and cannot be changed afterward.

Request Sample

Show Request Sample
import os
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

req = {
  "name": "test-vpc-nat-gateways",
  "type": "PUBLIC",
  "region": "tor1",
  "size": 1,
  "vpcs": [
    {
      "vpc_uuid": "0eb1752f-807b-4562-a077-8018e13ab1fb",
      "subnet_uuid": "cbd79771-23eb-49be-b5ea-59cc56222622",
      "default_gateway": True
    }
  ],
  "udp_timeout_seconds": 30,
  "icmp_timeout_seconds": 30,
  "tcp_timeout_seconds": 30,
  "project_id": "9cc10173-e9ea-4176-9dbc-a4cee4c4ff30"
}

resp = client.vpcnatgateways.create(body=req)

Response Example

Show Response Example
{
  "vpc_nat_gateway": {
    "id": "70e1b58d-cdec-4e95-b3ee-2d4d95feff51",
    "name": "test-vpc-nat-gateways",
    "type": "PUBLIC",
    "state": "ACTIVE",
    "region": "tor1",
    "size": 1,
    "vpcs": [
      {
        "vpc_uuid": "0eb1752f-807b-4562-a077-8018e13ab1fb",
        "subnet_uuid": "cbd79771-23eb-49be-b5ea-59cc56222622",
        "default_gateway": true
      }
    ],
    "egresses": {},
    "udp_timeout_seconds": 30,
    "icmp_timeout_seconds": 30,
    "tcp_timeout_seconds": 30,
    "created_at": "2025-08-12T18:43:14Z",
    "updated_at": "2025-08-12T18:43:14Z"
  }
}

More Information

See /v2/vpc_nat_gateways in the API reference for additional detail on responses, headers, parameters, and more.

We can't find any results for your search.

Try using different keywords or simplifying your search terms.