POST
/
cloud
/
v1
/
subnets
/
{project_id}
/
{region_id}
Python
from gcore import Gcore

client = Gcore(
    api_key="My API Key",
)
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": [
    "d478ae29-dedc-4869-82f0-96104425f565"
  ]
}

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

Examples:

1

region_id
integer
required

Region ID

Examples:

1

Body

application/json
cidr
string<ipvanynetwork>
required

CIDR

Examples:

"192.168.10.0/24"

name
string
required

Subnet name

Examples:

"my subnet"

network_id
string<uuid4>
required

Network ID

Examples:

"ee2402d0-f0cd-4503-9b75-69be1d11c5f1"

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.

Examples:

true

dns_nameservers
string<ipvanyaddress>[] | null

List IP addresses of DNS servers to advertise via DHCP.

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

True if DHCP should be enabled

Examples:

true

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).

Examples:

"192.168.10.1"

host_routes
RouteInSerializer · object[] | null

List of custom static routes to advertise via DHCP.

Examples:
[
{
"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.

Examples:

"00000000-0000-4000-8000-000000000000"

tags
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. 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.

Examples:
["d478ae29-dedc-4869-82f0-96104425f565"]