{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/withruntime-com/json-schema/withruntime-com-sandbox-create-schema.json",
  "title": "SandboxCreate",
  "description": "A machine to create.",
  "x-generated": "2026-11-28",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/withruntime-com-openapi.json#/components/schemas/SandboxCreate",
  "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`."
    },
    "volumes": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/VolumeMount"
      },
      "description": "Volumes it attaches and mounts at its create, at most one; detached when it is deleted, to attach to another."
    },
    "run": {
      "$ref": "#/$defs/SandboxRun"
    },
    "name": {
      "type": "string",
      "description": "Its name, unique in its project."
    },
    "labels": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      },
      "description": "Labels to find it by."
    },
    "getOrCreate": {
      "type": "boolean",
      "description": "With a name: the machine of that name when there is one, else a new one."
    },
    "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 (`\"5.00\"`): once it has cost that it pauses, and starts again only once its maxCost is raised (`update`); what a key's per-request and spend caps count. When omitted under a key with a per-request or spend cap, the most that key's caps leave."
    },
    "idlePauseSeconds": {
      "type": "integer",
      "description": "Seconds with nothing happening before it pauses, 60 to 86400; 0 never; its product's default when omitted (300 for a sandbox). A fork keeps its source's, except 0: a copy never pauses only when its fork asks.",
      "minimum": 0,
      "maximum": 86400
    },
    "from": {
      "type": "string",
      "description": "What it starts as, by ID or name: a snapshot (a copy of it running, at its sizes, in its project, with its secrets) or an image (as `image` takes it). A name is a snapshot's when the project has one of that name, else an image's. Not with `image`. Running copies of a sandbox are `fork`'s."
    },
    "snapshot": {
      "type": "string",
      "description": "Deprecated: SDK 1.0.x's name for `from` with a snapshot, read as `from` ([`snapshot_is_from`]). Not with `from`."
    },
    "network": {
      "$ref": "#/$defs/NetworkRules"
    },
    "env": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      },
      "description": "Environment variables for every command and process in it and its start, at most 32 and 32768 bytes of names and values; values are never answered. A copy keeps them."
    },
    "autoWake": {
      "type": "boolean",
      "description": "Whether a call that reaches it paused (an exec, a file, a terminal, a preview's visitor) resumes it; true when omitted. false: such a call answers 409 sandbox_paused and it stays paused until its own `:resume`. A fork's copies keep it."
    },
    "deleteAfterSeconds": {
      "type": "integer",
      "description": "Seconds until Runtime deletes it, as its delete does: final at once, its memory and disk gone and no longer billed; it can't be undone. 0 or omitted: kept until deleted. Its owner renews it with update; a copy, snapshot or image made from it sets its own.",
      "minimum": 0,
      "maximum": 315360000
    },
    "deleteProtection": {
      "type": "boolean",
      "description": "Whether its delete is refused (409 `delete_protected`) until an update turns this off; false when omitted. Not with `deleteAfterSeconds`. While true, its time limit pauses it instead of deleting it; only its organization's close deletes it. A copy, snapshot or image made from it sets its own."
    }
  },
  "$defs": {
    "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"
      ]
    },
    "NetworkRules": {
      "type": "object",
      "description": "Where a machine may connect out, past the walls every machine has.",
      "properties": {
        "allowOutbound": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The only places it may reach, each a host, `*.` and a name for every name under it, an address or a CIDR (`[` and `]` around an IPv6 address), every port when it names none; `:port` for that port alone, on a host name for a port beyond 80 and 443, which go together. `*` is every public host. Every public host when omitted; nothing when empty."
        },
        "denyOutbound": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Places it may never reach, written as in allowOutbound with no port: a deny wins over every allow."
        }
      }
    },
    "SandboxRun": {
      "type": "object",
      "description": "A command a machine runs once it starts: when it ends, the machine stops.",
      "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."
        },
        "timeoutSeconds": {
          "type": "number",
          "description": "Seconds it may run before it is stopped (`1.5` for 1,500 ms); no limit when omitted or 0.",
          "minimum": 0
        }
      },
      "required": [
        "cmd"
      ]
    },
    "VolumeMount": {
      "type": "object",
      "description": "A volume a machine attaches at its create, mounted read-write in it, one machine at a time; detached when the machine is deleted.",
      "properties": {
        "volume": {
          "type": "string",
          "description": "The volume, by name or ID, in the machine's project."
        },
        "path": {
          "type": "string",
          "description": "Where it is mounted, such as `/data`: an absolute path, not under `/proc`, `/sys`, `/dev`, `/etc`, `/usr`, `/bin`, `/sbin`, `/lib` or `/boot`."
        }
      },
      "required": [
        "volume",
        "path"
      ]
    }
  }
}