Skip to main content
POST
/
cloud
/
v1
/
subnets
/
{project_id}
/
{region_id}
Python
import os
from gcore import Gcore

client = Gcore(
    api_key=os.environ.get("GCORE_API_KEY"),  # This is the default and can be omitted
)
task_id_list = client.cloud.networks.subnets.create(
    project_id=1,
    region_id=1,
    cidr="192.168.10.0/24",
    name="my subnet",
    network_id="ee2402d0-f0cd-4503-9b75-69be1d11c5f1",
)
print(task_id_list.tasks)
{
  "tasks": [
    "<string>"
  ]
}

Authorizations

Authorization
string
header
required

API key for authentication. Make sure to include the word apikey, followed by a single space and then your token. Example: apikey 1234$abcdef

Path Parameters

project_id
integer
required

Project ID

region_id
integer
required

Region ID

Body

application/json
cidr
string<ipvanynetwork>
required

CIDR

name
string
required

Subnet name

network_id
string<uuid4>
required

Network ID

connect_to_network_router
boolean
default:true

True if the network's router should get a gateway in this subnet. Must be explicitly 'false' when gateway_ip is null.

dns_nameservers
string<ipvanyaddress>[] | null

List IP addresses of DNS servers to advertise via DHCP.

Example:
["8.8.4.4", "1.1.1.1"]
enable_dhcp
boolean
default:true

True if DHCP should be enabled

gateway_ip
string<ipvanyaddress> | null

Default GW IPv4 address to advertise in DHCP routes in this subnet. Omit this field to let the cloud backend allocate it automatically. Set to null if no gateway must be advertised by this subnet's DHCP (useful when attaching instances to multiple subnets in order to prevent default route conflicts).

Example:

"192.168.10.1"

host_routes
RouteInSerializer · object[] | null

List of custom static routes to advertise via DHCP.

Example:
[
{
"destination": "10.0.3.0/24",
"nexthop": "10.0.0.13"
}
]
ip_version
enum<integer>

IP version

Available options:
4,
6
router_id_to_connect
string<uuid4> | null

ID of the router to connect to. Requires connect_to_network_router set to true. If not specified, attempts to find a router created during network creation.

Example:

"00000000-0000-4000-8000-000000000000"

tags
CreateTagsSerializer · object

Key-value tags to associate with the resource. A tag is a key-value pair that can be associated with a resource, enabling efficient filtering and grouping for better organization and management. Both tag keys and values have a maximum length of 255 characters. Some tags are read-only and cannot be modified by the user. Tags are also integrated with cost reports, allowing cost data to be filtered based on tag keys or values.

Response

200 - application/json

OK

tasks
string[]
required

List of task IDs representing asynchronous operations. Use these IDs to monitor operation progress:

  • GET /v1/tasks/{task_id} - Check individual task status and details Poll task status until completion (FINISHED/ERROR) before proceeding with dependent operations.