{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/withruntime-com/json-schema/withruntime-com-sandbox-schema.json",
  "title": "Sandbox",
  "description": "A machine.",
  "x-generated": "2026-11-28",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/withruntime-com-openapi.json#/components/schemas/Sandbox",
  "type": "object",
  "properties": {
    "vcpu": {
      "type": "integer",
      "description": "Its vCPUs; its product's default when omitted.",
      "minimum": 1
    },
    "memoryGB": {
      "type": "number",
      "description": "Its memory in GB (1 GB is 1,024 MiB); a fraction is taken to the MiB (`1.5`). Its product's default when omitted.",
      "minimum": 1
    },
    "diskGB": {
      "type": "number",
      "description": "Its disk in GB (1 GB is 1,024 MiB), to the MiB. When omitted, its product's default or its image's size, whichever is larger.",
      "minimum": 1
    },
    "image": {
      "type": "string",
      "description": "The image it boots, by name (its newest version), `name:version` or ID; Runtime's default image when omitted."
    },
    "secrets": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "The secrets it may get, by name, at most 64: only those of them whose scope admits it; [] none; every one whose scope admits it when omitted. A name with no secret yet takes effect once that secret is created. Fixed for its life: a fork or a copy of a snapshot keeps it.",
      "maxItems": 64
    },
    "start": {
      "$ref": "#/$defs/MachineStart"
    },
    "user": {
      "type": "string",
      "enum": [
        "runtime",
        "root"
      ],
      "description": "Who every command, process, terminal and code run in it runs as when the call names no `user`: `runtime` (uid 1000, with passwordless sudo) or `root`. Its image's when omitted, else `runtime`."
    },
    "id": {
      "type": "string",
      "description": "Its ID."
    },
    "object": {
      "type": "string",
      "enum": [
        "sandbox",
        "function",
        "app",
        "site",
        "ci",
        "browser",
        "desktop",
        "notebook",
        "workspace",
        "container",
        "build",
        "agent.session"
      ],
      "description": "Its product's kind: `sandbox` for a sandbox, `app` for an app, and so on."
    },
    "name": {
      "type": "string",
      "description": "Its name, unique in its project."
    },
    "state": {
      "type": "string",
      "enum": [
        "starting",
        "running",
        "paused",
        "deleted",
        "error"
      ],
      "description": "Where it is."
    },
    "labels": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      },
      "description": "Its labels."
    },
    "createdAt": {
      "type": "string",
      "format": "date-time",
      "description": "When it was created."
    },
    "deletedAt": {
      "type": "string",
      "format": "date-time",
      "description": "When it was deleted: a delete's answer alone."
    },
    "revision": {
      "type": "integer",
      "description": "Its revision, changed by every change to it: what an update's If-Match names."
    },
    "idlePauseSeconds": {
      "type": "integer",
      "description": "Seconds with nothing happening before it pauses; 0 never.",
      "default": 300
    },
    "maxCost": {
      "type": "string",
      "format": "decimal",
      "pattern": "^(0|[1-9][0-9]{0,11})(\\.[0-9]{1,9})?$",
      "description": "The most it may cost in all, in US dollars; none when it has no such cap."
    },
    "autoWake": {
      "type": "boolean",
      "description": "Whether a call that reaches it paused resumes it; false: only its own resume does, and such a call answers 409 sandbox_paused.",
      "default": true
    },
    "exitCode": {
      "type": "integer",
      "description": "Its run's exit code, once its run ended; none for one a signal or its timeout ended."
    },
    "endedAt": {
      "type": "string",
      "format": "date-time",
      "description": "When its run ended."
    },
    "pausedAt": {
      "type": "string",
      "format": "date-time",
      "description": "When its pause began (or its run ended), while it is paused."
    },
    "ready": {
      "$ref": "#/$defs/MachineReady"
    },
    "deleteAt": {
      "type": "string",
      "format": "date-time",
      "description": "When Runtime deletes it (`deleteAfterSeconds`), finally: it can't be undone, as its delete can't; none: kept until deleted."
    },
    "deleteProtection": {
      "type": "boolean",
      "description": "Whether its delete is refused (409 `delete_protected`) until an update turns this off."
    }
  },
  "required": [
    "id",
    "object",
    "state",
    "labels"
  ],
  "$defs": {
    "MachineReady": {
      "type": "object",
      "description": "How a create's wait for its start's ready check (`start.readyPort`, `start.readyCommand`) went.",
      "properties": {
        "state": {
          "type": "string",
          "enum": [
            "ready",
            "timeout",
            "not_running"
          ],
          "description": "`ready` (the check passed), `timeout` (not within `readyTimeoutSeconds`), or `not_running` (it never ran)."
        },
        "waitedMs": {
          "type": "integer",
          "description": "How long it waited, in milliseconds."
        }
      },
      "required": [
        "state",
        "waitedMs"
      ]
    },
    "MachineStart": {
      "type": "object",
      "description": "A command a machine starts at every fresh boot.",
      "properties": {
        "cmd": {
          "oneOf": [
            {
              "type": "string",
              "minLength": 1,
              "description": "Run by bash -lc."
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              },
              "minItems": 1,
              "description": "The program and its arguments, run without a shell."
            }
          ],
          "description": "The command: text, run by `bash -lc`, or the program and its arguments as a list, run without a shell."
        },
        "cwd": {
          "type": "string",
          "description": "The directory it runs in; the user's home when omitted."
        },
        "env": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          },
          "description": "Environment variables to add."
        },
        "readyPort": {
          "type": "integer",
          "description": "A port it listens on once ready: a create answers once something listens there.",
          "minimum": 1,
          "maximum": 65535
        },
        "readyCommand": {
          "type": "string",
          "description": "A shell command that exits 0 once it is ready, run by `/bin/sh -c` in `cwd` until it does: a create answers once it has."
        },
        "readyTimeoutSeconds": {
          "type": "integer",
          "description": "How long a create waits for `readyPort` or `readyCommand`, 1 to 300 seconds: 60 when omitted.",
          "minimum": 1,
          "maximum": 300
        }
      },
      "required": [
        "cmd"
      ]
    }
  }
}