Compute Instances API

Manage virtual machines, deployments, and scaling policies. Create, configure, and monitor compute resources with our RESTful API.

Authentication

All requests to the Compute Instances API require authentication via API Key. Include your key in the Authorization header:

curl -X GET https://api.cloudnexus.io/v2/instances \
  -H "Authorization: Bearer cn_live_sk_9f8e7d6c5b4a3210" \
  -H "Content-Type: application/json"
⚠️
Security Notice

Never expose your live API keys in client-side code or public repositories. Use environment variables and rotate keys regularly.

Endpoints

The following endpoints are available for managing compute instances:

Method Endpoint Description
GET /v2/instances List all compute instances with pagination
POST /v2/instances Create a new compute instance
GET /v2/instances/{id} Retrieve details for a specific instance
PUT /v2/instances/{id} Update instance configuration or tags
DELETE /v2/instances/{id} Terminate an instance permanently

Create an Instance

Launch a new compute instance by sending a POST request to the instances endpoint. Specify region, plan, and networking configuration.

Request Body

application/json
{
  "region": "us-east-1",
  "plan": "standard-4x",
  "image": "ubuntu-22.04-lts",
  "network": {
    "subnet_id": "sub_8f7e6d5c4b",
    "assign_public_ip": true
  },
  "tags": {"env": "production", "app": "api-server"}
}

Response

201 Created
{
  "id": "inst_3x9y2z1a0b",
  "status": "provisioning",
  "region": "us-east-1",
  "plan": "standard-4x",
  "public_ip": "104.26.18.42",
  "created_at": "2025-01-15T08:32:14Z",
  "links": {
    "self": "https://api.cloudnexus.io/v2/instances/inst_3x9y2z1a0b",
    "console": "https://console.cloudnexus.io/instances/inst_3x9y2z1a0b"
  }
}

Rate Limits & Best Practices

The Compute API enforces rate limits to ensure platform stability:

💡
Pro Tip

Use the X-Request-ID header to track API calls in our monitoring dashboard. This significantly speeds up support resolution times.

Instance Webhooks

Subscribe to instance lifecycle events (provisioned, stopped, terminated, scaled) via webhooks. Configure your endpoint in the console or via the /v2/webhooks endpoint.

Supported events: instance.created, instance.ready, instance.stopped, instance.terminated, instance.scaled.

Auto-Recovery Enabled

Instances automatically restart on hardware failures. You'll receive a instance.recovered webhook when this occurs.

Was this page helpful?