{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/pennycompute-com/json-schema/pennycompute-com-instance-schema.json",
  "title": "Instance",
  "x-generated": "2026-11-23",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/pennycompute-com-openapi.json#/components/schemas/Instance",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "name": {
      "type": "string"
    },
    "state": {
      "type": "string",
      "enum": [
        "starting",
        "running",
        "stopped",
        "crashed",
        "lost"
      ],
      "description": "starting: placed, not yet answering. running: answering. stopped: ended on purpose; see end_reason. crashed: the container exited. lost: its machine went away."
    },
    "end_reason": {
      "type": "string",
      "enum": [
        "idle",
        "destroyed",
        "lifetime",
        "exited",
        "disk"
      ],
      "description": "Why it ended. stopped: idle, destroyed or lifetime. crashed: exited (the process ended) or disk (it outgrew disk_gb)."
    },
    "exit_code": {
      "type": "integer",
      "description": "The exit code of a crashed container, when known."
    },
    "address": {
      "type": "string",
      "format": "uri",
      "description": "Send HTTP here with the header Authorization: Bearer <token>. Any method and path; bodies are streamed both ways; one request may stay open 15 minutes. WebSocket upgrades are not carried. Have your container send Content-Length on a reply whose completeness matters, or check the size or framing of what you receive: when an instance ends or its machine goes away in the middle of a reply, a reply without Content-Length ends at the caller as a complete 200 with fewer bytes, and one with Content-Length fails as a broken transfer. Keep connections open in your server (the default in Node, Go and uvicorn): a server that closes its connection after every reply can lose the end of a reply larger than about a megabyte. An answer from PennyCompute rather than from your container carries the header pennycompute-instance with the instance state and a JSON error: 401 invalid_token, 410 instance_gone once the instance has ended, 503 instance_starting when the port has not opened within 30 seconds of the request arriving (a request sent while the instance is starting is held and forwarded when it is ready), 502 instance_unreachable when the container refuses the connection."
    },
    "max_request_body_bytes": {
      "type": "integer",
      "description": "The largest single request body this instance can receive. Replies are not limited."
    },
    "token": {
      "type": "string",
      "description": "Bearer token for the instance address. Returned by a start only."
    },
    "image": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$",
      "description": "The image digest, as printed by the push to your registry."
    },
    "label": {
      "type": "string"
    },
    "vcpu": {
      "type": "number",
      "minimum": 0.25,
      "maximum": 16,
      "multipleOf": 0.25,
      "description": "Cores reserved and billed, in quarters. The container sees the next whole number of cores."
    },
    "memory_mib": {
      "type": "integer",
      "minimum": 256,
      "maximum": 65536
    },
    "disk_gb": {
      "type": "integer",
      "minimum": 1,
      "maximum": 100,
      "default": 8
    },
    "port": {
      "type": "integer"
    },
    "idle_stop_seconds": {
      "type": "integer"
    },
    "max_lifetime_seconds": {
      "type": "integer"
    },
    "rate_nanos_per_second": {
      "type": "integer",
      "description": "The price of this instance in billionths of a US dollar per running second: 16000 per vCPU, 2000 per GiB of memory, 50 per GB of disk."
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "started_at": {
      "type": "string",
      "format": "date-time"
    },
    "ended_at": {
      "type": "string",
      "format": "date-time"
    },
    "running_seconds": {
      "type": "integer",
      "description": "Whole seconds from answering to stopping, so far."
    },
    "charge_micros": {
      "type": "string",
      "pattern": "^[0-9]+$",
      "description": "The charge so far, in millionths of a US dollar."
    }
  },
  "required": [
    "id",
    "name",
    "state",
    "charge_micros"
  ]
}