{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/oec-sh/json-schema/oec-sh-vmcreate-schema.json",
  "title": "VMCreate",
  "description": "Schema for creating a VM/Server.",
  "x-generated": "2026-11-19",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/oec-sh-api-openapi.json#/components/schemas/VMCreate",
  "properties": {
    "name": {
      "type": "string",
      "maxLength": 255,
      "minLength": 1,
      "title": "Name",
      "description": "Server/VM name"
    },
    "provider": {
      "$ref": "#/$defs/VMProvider",
      "description": "Cloud provider (CUSTOM for BYOS)",
      "default": "custom"
    },
    "region": {
      "type": "string",
      "title": "Region",
      "description": "Cloud region or location label",
      "default": "custom"
    },
    "organization_id": {
      "type": "string",
      "format": "uuid",
      "title": "Organization Id",
      "description": "Organization ID"
    },
    "is_shared": {
      "type": "boolean",
      "title": "Is Shared",
      "description": "Whether this is a portal-managed shared server (portal admin only)",
      "default": false
    },
    "owner_type": {
      "type": "string",
      "title": "Owner Type",
      "description": "Owner type: 'organization' (BYOS) or 'portal' (shared server)",
      "default": "organization"
    },
    "connection_method": {
      "type": "string",
      "title": "Connection Method",
      "description": "How platform connects to server: 'direct' (SSH) or 'cloudflare_tunnel'",
      "default": "direct"
    },
    "generate_ssh_key": {
      "type": "boolean",
      "title": "Generate Ssh Key",
      "description": "Generate a platform SSH key pair for this server (for tunnel-connected servers)",
      "default": false
    },
    "ipv4_address": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Ipv4 Address",
      "description": "Public IPv4 address (e.g., 192.168.1.100)"
    },
    "ipv6_address": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Ipv6 Address",
      "description": "Public IPv6 address (e.g., 2001:db8::1)"
    },
    "fqdn": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 255
        },
        {
          "type": "null"
        }
      ],
      "title": "Fqdn",
      "description": "Fully qualified domain name (e.g., server.example.com)"
    },
    "hostname": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 255
        },
        {
          "type": "null"
        }
      ],
      "title": "Hostname",
      "description": "Server hostname"
    },
    "private_ipv4": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Private Ipv4",
      "description": "Private IPv4 address for internal communication"
    },
    "private_ipv6": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Private Ipv6",
      "description": "Private IPv6 address for internal communication"
    },
    "connection_host_type": {
      "$ref": "#/$defs/ConnectionHostType",
      "description": "Which address to use for SSH connection",
      "default": "auto"
    },
    "ssh_port": {
      "type": "integer",
      "maximum": 65535.0,
      "minimum": 1.0,
      "title": "Ssh Port",
      "description": "SSH port",
      "default": 22
    },
    "ssh_username": {
      "type": "string",
      "maxLength": 50,
      "minLength": 1,
      "title": "Ssh Username",
      "description": "SSH username",
      "default": "root"
    },
    "ssh_auth_method": {
      "$ref": "#/$defs/SSHAuthMethod",
      "description": "SSH authentication method",
      "default": "ssh_key"
    },
    "ssh_password": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Ssh Password",
      "description": "SSH password (required if auth_method is PASSWORD)"
    },
    "ssh_private_key": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Ssh Private Key",
      "description": "SSH private key content (required if auth_method is SSH_KEY)"
    },
    "ssh_key_passphrase": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Ssh Key Passphrase",
      "description": "SSH key passphrase (optional, if key is encrypted)"
    },
    "server_ssh_key_id": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "title": "Server Ssh Key Id",
      "description": "Reference to a stored SSH key (alternative to ssh_private_key)"
    },
    "ssh_sudo_mode": {
      "$ref": "#/$defs/SSHSudoMode",
      "description": "Sudo mode for privileged commands: auto (detect from username), none (root), sudo (always use sudo)",
      "default": "auto"
    },
    "size": {
      "$ref": "#/$defs/VMSize",
      "description": "VM size (for cloud-provisioned)",
      "default": "custom"
    },
    "cpu_cores": {
      "type": "integer",
      "minimum": 1.0,
      "title": "Cpu Cores",
      "description": "Number of CPU cores",
      "default": 4
    },
    "memory_gb": {
      "type": "integer",
      "minimum": 1.0,
      "title": "Memory Gb",
      "description": "Memory in GB",
      "default": 8
    },
    "disk_gb": {
      "type": "integer",
      "minimum": 10.0,
      "title": "Disk Gb",
      "description": "Disk size in GB",
      "default": 160
    },
    "max_projects": {
      "type": "integer",
      "minimum": 0.0,
      "title": "Max Projects",
      "description": "Maximum environments on this server. 0 means unlimited (physical capacity is the only cap). Default is 0 for BYOS — the customer paid for the hardware, so we don't impose an artificial cap.",
      "default": 0
    },
    "tags": {
      "additionalProperties": {
        "type": "string"
      },
      "type": "object",
      "title": "Tags",
      "description": "Server tags/labels"
    },
    "ip_address": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Ip Address",
      "description": "Deprecated: Use ipv4_address instead"
    }
  },
  "type": "object",
  "required": [
    "name",
    "organization_id"
  ],
  "$defs": {
    "ConnectionHostType": {
      "type": "string",
      "enum": [
        "auto",
        "ipv4",
        "ipv6",
        "fqdn",
        "hostname"
      ],
      "title": "ConnectionHostType",
      "description": "Which address/hostname to use for SSH connection."
    },
    "SSHAuthMethod": {
      "type": "string",
      "enum": [
        "password",
        "ssh_key"
      ],
      "title": "SSHAuthMethod",
      "description": "SSH authentication methods."
    },
    "SSHSudoMode": {
      "type": "string",
      "enum": [
        "auto",
        "none",
        "sudo"
      ],
      "title": "SSHSudoMode",
      "description": "SSH sudo mode for privileged command execution.\n\nCloud providers like AWS/GCP/Azure use non-root users (ubuntu, ec2-user)\nthat require sudo for privileged operations like Docker commands."
    },
    "VMProvider": {
      "type": "string",
      "enum": [
        "aws",
        "azure",
        "gcp",
        "digitalocean",
        "vultr",
        "ovhcloud",
        "hetzner",
        "linode",
        "custom"
      ],
      "title": "VMProvider",
      "description": "Supported cloud providers for VMs."
    },
    "VMSize": {
      "type": "string",
      "enum": [
        "small",
        "medium",
        "large",
        "xlarge",
        "custom"
      ],
      "title": "VMSize",
      "description": "Standard VM sizes."
    }
  }
}