API: Instances

REST API endpoints for managing compute instances.

API: Instances

Endpoints

MethodPathDescription
POST/v1/instancesCreate a new instance
GET/v1/instancesList all instances
GET/v1/instances/{id}Get instance details
DELETE/v1/instances/{id}Delete an instance
## Create Instance
POST /v1/instances

Request Body

{
  "metadata": {
    "name": "web-server-01",
    "labels": {
      "env": "production",
      "team": "platform"
    }
  },
  "spec": {
    "type": "cx31",
    "image": "ubuntu-22.04",
    "vcpus": 2,
    "memory_mb": 4096,
    "disk_gb": 80,
    "vpc_id": "vpc-abc123",
    "subnet_id": "subnet-def456",
    "security_groups": ["sg-web", "sg-ssh"],
    "ssh_key_ids": ["key-001"],
    "user_data": "IyEvYmluL2Jhc2gKYXB0IHVwZGF0ZQ=="
  }
}

Response (201 Created)

{
  "id": "inst-a1b2c3",
  "metadata": {
    "name": "web-server-01",
    "labels": {"env": "production", "team": "platform"},
    "created_at": "2025-01-15T10:30:00Z"
  },
  "spec": {
    "type": "cx31",
    "image": "ubuntu-22.04",
    "vcpus": 2,
    "memory_mb": 4096,
    "disk_gb": 80,
    "vpc_id": "vpc-abc123",
    "subnet_id": "subnet-def456",
    "security_groups": ["sg-web", "sg-ssh"],
    "ssh_key_ids": ["key-001"],
    "user_data": "IyEvYmluL2Jhc2gKYXB0IHVwZGF0ZQ=="
  },
  "status": {
    "state": "provisioning",
    "host_id": "",
    "private_ip": "",
    "public_ip": ""
  },
  "operation_id": "op-xyz789"
}

InstanceSpec Fields

FieldTypeRequiredDescription
typestringYesServer type identifier
imagestringYesOS image identifier
vcpusintNoNumber of virtual CPUs
memory_mbintNoMemory in megabytes
disk_gbintNoRoot disk size in gigabytes
vpc_idstringNoVPC to attach the instance to
subnet_idstringNoSubnet within the VPC
security_groupsstring[]NoList of security group IDs
ssh_key_idsstring[]NoList of SSH key IDs
user_datastringNoBase64-encoded cloud-init script
## InstanceStatus Fields
FieldTypeDescription
statestringCurrent state: provisioning, running, stopping, stopped, terminated
host_idstringPhysical host identifier
private_ipstringPrivate IP address within the VPC
public_ipstringPublic IP address (if assigned)
## List Instances
GET /v1/instances

Response (200 OK)

{
  "items": [
    {
      "id": "inst-a1b2c3",
      "metadata": {"name": "web-server-01"},
      "spec": {"type": "cx31", "image": "ubuntu-22.04"},
      "status": {"state": "running", "private_ip": "10.0.1.15", "public_ip": "203.0.113.42"}
    }
  ]
}

Delete Instance

DELETE /v1/instances/inst-a1b2c3

Returns 202 with an operation ID for tracking the async deletion.