Docs

Search documentation

Console
Browse examples

Create a private network

Create an IPv4 network and subnet for virtual machines in a Tachora project.

This example creates a network and a subnet in the same region. You can use the resulting subnet ID when you launch a VM.

Project and region

Set TACHORA_API_KEY and TACHORA_PROJECT_ID as described in the quickstart. Use a Member project key for this example.

Choose an enabled region from List regions. The examples use us-ohio-1 and private CIDRs 10.0.0.0/16 for the network and 10.0.1.0/24 for the subnet. Choose ranges that fit your network plan.

Create the network

Run this in your shell. Keep the same idempotency key and body if you retry the request.

NETWORK_CREATE_KEY=$(uuidgen)

curl --fail-with-body --silent --show-error \
  "https://api.tachora.ai/v1/projects/${TACHORA_PROJECT_ID}/networks" \
  -H "Authorization: Bearer ${TACHORA_API_KEY}" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: ${NETWORK_CREATE_KEY}" \
  --data '{"name":"example-network","region":"us-ohio-1","cidr":"10.0.0.0/16"}'

The create network response is 201 Created. Set TACHORA_NETWORK_ID to the response’s id.

Create the subnet

The subnet must fit inside the network CIDR and be disjoint from its other subnets.

SUBNET_CREATE_KEY=$(uuidgen)

curl --fail-with-body --silent --show-error \
  "https://api.tachora.ai/v1/networks/${TACHORA_NETWORK_ID}/subnets" \
  -H "Authorization: Bearer ${TACHORA_API_KEY}" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: ${SUBNET_CREATE_KEY}" \
  --data '{"name":"example-subnet","cidr":"10.0.1.0/24"}'

The create subnet response is 201 Created. Set TACHORA_SUBNET_ID to the response’s id. Tachora uses the first usable address as the gateway when you omit gateway_ip.

Use or remove the subnet

Use TACHORA_SUBNET_ID to launch a CPU VM. To clean up the resources you created here, delete the subnet after any VMs are removed, then delete the network.