Networking API

Programmatically manage virtual networks, subnets, firewalls, and load balancers across all CloudNexus regions. All endpoints are stateless and support standard REST conventions.

Base URL: https://api.cloudnexus.com/v1/networking
All requests must be authenticated using a Bearer token in the Authorization header. Rate limits apply per API key. Default limit: 1,000 req/min. Exceeding limits returns 429 Too Many Requests. Use X-RateLimit-Reset header to determine cooldown.

Authentication

Include your API key in every request. Keys can be generated in the CloudNexus Console under Settings → API Keys.

Header Example
Authorization: Bearer cn_live_sk_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6

Endpoints Overview

Method Endpoint Description
GET /vpcs List all virtual private networks
POST /vpcs Create a new VPC in a specified region
GET /vpcs/:id/subnets List subnets within a VPC
POST /firewalls Provision a stateful firewall
PUT /firewalls/:id/rules Update ingress/egress rules
DEL /load-balancers/:id Decommission a load balancer

Request & Response Examples

cURL
Python
Node.js
Create VPC
curl -X POST https://api.cloudnexus.com/v1/networking/vpcs \
  -H "Authorization: Bearer cn_live_sk_..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "prod-us-east-vpc",
    "region": "us-east-1",
    "cidr_block": "10.0.0.0/16",
    "enable_dns_hostnames": true
  }'
201 Created
{
  "id": "vpc_9f8e7d6c5b4a",
  "name": "prod-us-east-vpc",
  "region": "us-east-1",
  "cidr_block": "10.0.0.0/16",
  "state": "provisioning",
  "created_at": "2025-01-15T08:23:41Z",
  "_links": {
    "subnets": "/v1/networking/vpcs/vpc_9f8e7d6c5b4a/subnets",
    "self": "/v1/networking/vpcs/vpc_9f8e7d6c5b4a"
  }
}
Python (requests)
import requests

headers = {
    "Authorization": "Bearer cn_live_sk_a1b2c3d4...",
    "Content-Type": "application/json"
}

payload = {
    "name": "prod-us-east-vpc",
    "region": "us-east-1",
    "cidr_block": "10.0.0.0/16",
    "enable_dns_hostnames": True
}

response = requests.post(
    "https://api.cloudnexus.com/v1/networking/vpcs",
    headers=headers,
    json=payload
)

print(response.status_code)  # 201
print(response.json())
Node.js (fetch)
const response = await fetch('https://api.cloudnexus.com/v1/networking/vpcs', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer cn_live_sk_a1b2c3d4...',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: 'prod-us-east-vpc',
    region: 'us-east-1',
    cidr_block: '10.0.0.0/16',
    enable_dns_hostnames: true
  })
});

console.log(response.status); // 201
const data = await response.json();
console.log(data.id); // vpc_9f8e7d6c5b4a

Firewall Rules

Firewalls are stateful by default. Rules are evaluated in ascending order by priority. Lower numbers take precedence. If no rule matches, traffic is denied by default.

⚠️ Security Note: Avoid using 0.0.0.0/0 for inbound SSH (22) or RDP (3389). Use IP whitelisting or VPN endpoints for administrative access.
Field Type Description
direction String ingress or egress
protocol String tcp, udp, icmp, or all
ports Array Port ranges: ["80", "443", "8080-8090"]
sources Array CIDR blocks or tags. Required for ingress.
action String allow or deny

Pagination

All list endpoints support cursor-based pagination. Use the limit query parameter to control response size (max 100). Navigate pages using the next_cursor field.

Pagination Response
{
  "data": [
    {"id": "vpc_1", "name": "dev-vpc"},
    {"id": "vpc_2", "name": "staging-vpc"}
  ],
  "meta": {
    "total": 14,
    "limit": 2,
    "next_cursor": "eyJpZCI6InZwY18yIn0="
  }
}

Common Error Codes

HTTP Status Error Code Meaning
400 INVALID_PARAMS Malformed request body or missing required fields
401 UNAUTHORIZED Missing or expired API key
403 FORBIDDEN Insufficient permissions for requested action
404 NOT_FOUND Resource ID does not exist or belongs to another account
429 RATE_LIMITED Too many requests. Retry after X-RateLimit-Reset
500 INTERNAL_ERROR Platform fault. Contact support with request ID
💡 Tip: Use the Idempotency-Key header for POST/PUT requests to safely retry operations without creating duplicate resources.

SDKs & Tools

Official libraries are available for Python, Node.js, Go, and Rust. All SDKs handle authentication, pagination, and retries automatically.

pip install cloudnexus npm i @cloudnexus/sdk go get cloudnexus.dev/v1 Postman Collection