{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/briq-cloud/json-schema/briq-cloud-run-body-schema.json",
  "title": "RunBody",
  "x-generated": "2026-11-03",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/briq-cloud-v1-openapi.json#/components/schemas/RunBody",
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "spec": {
          "$ref": "#/$defs/BriqSpec"
        },
        "stack": {
          "type": "string"
        },
        "expose": {
          "type": "string",
          "enum": [
            "public",
            "private"
          ],
          "description": "Publish it as it is created: \"private\" for only whoever has the URL (it carries a secret), \"public\" for anyone. Left out, nothing is published. The URL comes back as outputs.URL. The port is spec.expose, or the only one in spec.ports"
        },
        "wait": {
          "type": "boolean",
          "default": true,
          "description": "Answer once the briqs are ready (healthcheck passed, or process started)"
        },
        "waitTimeoutMs": {
          "type": "integer",
          "maximum": 300000,
          "default": 120000,
          "description": "How long to wait; a briq still creating then is on its way"
        }
      },
      "required": [
        "spec"
      ]
    },
    {
      "type": "object",
      "properties": {
        "image": {
          "type": "string",
          "minLength": 3,
          "maxLength": 255,
          "pattern": "^[a-z0-9][a-z0-9._\\/-]*(?::[\\w.-]+)?(?:@sha256:[a-f0-9]{64})?$",
          "description": "Another tag (postgres:17) or a compatible image (pgvector/pgvector:pg16). Default: the recipe's"
        },
        "env": {
          "type": "object",
          "additionalProperties": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 32768
              },
              {
                "type": "object",
                "properties": {
                  "secret": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 128,
                    "pattern": "^[A-Za-z_][A-Za-z0-9_.-]*$"
                  },
                  "value": {
                    "type": "string",
                    "maxLength": 32768
                  },
                  "scope": {
                    "type": "string",
                    "enum": [
                      "boot",
                      "team"
                    ]
                  },
                  "hosts": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 253,
                      "pattern": "^(\\*\\.)?[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$"
                    },
                    "minItems": 1,
                    "maxItems": 20
                  },
                  "locations": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "header",
                        "body"
                      ]
                    },
                    "minItems": 1
                  }
                },
                "required": [
                  "secret"
                ],
                "additionalProperties": false
              }
            ]
          },
          "description": "Added to the recipe's env, or replacing one of its values: a string, or { secret: NAME, value } for a credential"
        },
        "cmd": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 8192
            },
            {
              "type": "array",
              "items": {
                "type": "string",
                "maxLength": 8192
              },
              "maxItems": 64
            }
          ],
          "description": "The command: a string run with sh -c (\"npm start\"), or the argv. A language recipe's start command"
        },
        "size": {
          "type": "string",
          "enum": [
            "nano",
            "small",
            "medium",
            "large"
          ]
        },
        "volume": {
          "type": "object",
          "properties": {
            "gb": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500
            }
          },
          "required": [
            "gb"
          ],
          "description": "The volume: { gb }"
        },
        "files": {
          "type": "object",
          "additionalProperties": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "properties": {
                  "base64": {
                    "type": "string"
                  }
                },
                "required": [
                  "base64"
                ]
              }
            ]
          },
          "description": "Files, path → text or { base64 }: an app's code for a language recipe"
        },
        "ports": {
          "type": "array",
          "items": {
            "type": "integer",
            "minimum": 1,
            "maximum": 65535
          },
          "description": "A language recipe: the port the app listens on, [8080] by default"
        },
        "checkout": {
          "type": "object",
          "properties": {
            "repo": {
              "type": "string"
            },
            "ref": {
              "type": "string"
            },
            "path": {
              "type": "string"
            },
            "token": {
              "type": "object",
              "properties": {
                "secret": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 128,
                  "pattern": "^[A-Za-z_][A-Za-z0-9_.-]*$"
                },
                "value": {
                  "type": "string"
                }
              },
              "required": [
                "secret"
              ]
            }
          },
          "required": [
            "repo"
          ],
          "description": "A language or static recipe: the code from a repo, as actions/checkout. { repo: \"github.com/owner/app\", ref?, path?, token? }"
        },
        "steps": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "run": {
                "type": "string"
              }
            },
            "required": [
              "run"
            ]
          },
          "description": "A language recipe: shell commands run before the app starts, as GitHub Actions steps. [{ run: \"npm ci\" }, { run: \"npm run build\" }]"
        },
        "routes": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          },
          "description": "The nginx recipe: path prefix → \"briq:port\", e.g. { \"/api/\": \"backend:8080\" }"
        },
        "recipe": {
          "type": "string",
          "description": "A recipe (GET /v1/recipes). Beside it, the fields of the service it makes, as a GitHub Actions service: image, env, cmd, size, volume, files; a language recipe also takes checkout, steps and ports. GET /v1/recipes/{name} lists what each takes and its defaults"
        },
        "name": {
          "type": "string"
        },
        "stack": {
          "type": "string"
        },
        "expose": {
          "type": "string",
          "enum": [
            "public",
            "private"
          ],
          "description": "Publish the recipe's front door as it is created: \"private\" for only whoever has the URL (it carries a secret), \"public\" for anyone. Left out, nothing is published. The URL comes back as outputs.URL. A recipe with no front door (a database) refuses it"
        },
        "sleep": {
          "type": "string",
          "pattern": "^(?:never|[1-9][0-9]{0,4}[mhd])$",
          "description": "When the briq goes to sleep: after this long without use (agent calls, visits to its stack's URLs). A string: \"30m\", \"3h\", \"7d\" or \"never\", never a number. A sleeping briq keeps its disk, costs nothing for compute, and the next use wakes it. \"never\" keeps it always on (Pro plan and above). One window for every briq the recipe makes; left out, the environment's default"
        },
        "wait": {
          "type": "boolean",
          "default": true,
          "description": "Answer once the briqs are ready (healthcheck passed, or process started)"
        },
        "waitTimeoutMs": {
          "type": "integer",
          "maximum": 300000,
          "default": 120000,
          "description": "How long to wait; a briq still creating then is on its way"
        }
      },
      "required": [
        "recipe"
      ]
    }
  ],
  "$defs": {
    "BriqSpec": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 32,
          "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
        },
        "image": {
          "type": "string",
          "minLength": 3,
          "maxLength": 255,
          "pattern": "^[a-z0-9][a-z0-9._\\/-]*(?::[\\w.-]+)?(?:@sha256:[a-f0-9]{64})?$"
        },
        "cmd": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 8192
            },
            {
              "type": "array",
              "items": {
                "type": "string",
                "maxLength": 8192
              },
              "maxItems": 64
            }
          ],
          "description": "The command: a string, run with sh -c (\"npm start\"), or the argv. Default: the image's"
        },
        "entrypoint": {
          "type": "array",
          "items": {
            "type": "string",
            "maxLength": 8192
          },
          "maxItems": 64
        },
        "env": {
          "type": "object",
          "additionalProperties": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 32768
              },
              {
                "type": "object",
                "properties": {
                  "secret": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 128,
                    "pattern": "^[A-Za-z_][A-Za-z0-9_.-]*$"
                  },
                  "value": {
                    "type": "string",
                    "maxLength": 32768
                  },
                  "scope": {
                    "type": "string",
                    "enum": [
                      "boot",
                      "team"
                    ]
                  },
                  "hosts": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 253,
                      "pattern": "^(\\*\\.)?[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$"
                    },
                    "minItems": 1,
                    "maxItems": 20
                  },
                  "locations": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "header",
                        "body"
                      ]
                    },
                    "minItems": 1
                  }
                },
                "required": [
                  "secret"
                ],
                "additionalProperties": false
              }
            ]
          },
          "default": {},
          "description": "A string; { secret: NAME } for a value briq generates; { secret: NAME, value } for a credential you have, stored encrypted and never returned. Plain values are shown in status. {{briq:NAME}} in a plain value becomes the address of briq NAME in the stack; {{self:host}}, the hostname of its own URL when it is published as it is created (localhost without one)"
        },
        "ports": {
          "type": "array",
          "items": {
            "type": "integer",
            "minimum": 1,
            "maximum": 65535
          },
          "maxItems": 32,
          "default": [],
          "description": "The ports the image listens on"
        },
        "size": {
          "type": "string",
          "enum": [
            "nano",
            "small",
            "medium",
            "large"
          ],
          "default": "small"
        },
        "volume": {
          "type": "object",
          "properties": {
            "mount": {
              "type": "string",
              "maxLength": 255
            },
            "gb": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 2
            },
            "copy": {
              "type": "string",
              "enum": [
                "never"
              ],
              "description": "\"never\": no fork of the briq and no backup of the volume, for one that holds sign-ins"
            }
          },
          "required": [
            "mount"
          ]
        },
        "files": {
          "type": "object",
          "additionalProperties": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "properties": {
                  "base64": {
                    "type": "string"
                  }
                },
                "required": [
                  "base64"
                ]
              }
            ]
          },
          "description": "Boot files, absolute path → text or { base64 }: written before the process starts and again whenever it starts over. At most 64 files and 256 KB in all"
        },
        "healthcheck": {
          "type": "object",
          "properties": {
            "cmd": {
              "type": "array",
              "items": {
                "type": "string",
                "maxLength": 8192
              },
              "minItems": 1,
              "maxItems": 64
            },
            "intervalMs": {
              "type": "integer",
              "minimum": 500,
              "default": 2000
            },
            "timeoutMs": {
              "type": "integer",
              "minimum": 1000,
              "maximum": 300000,
              "default": 60000
            }
          },
          "required": [
            "cmd"
          ]
        },
        "sleep": {
          "type": "string",
          "pattern": "^(?:never|[1-9][0-9]{0,4}[mhd])$",
          "description": "When the briq goes to sleep: after this long without use (agent calls, visits to its stack's URLs). A string: \"30m\", \"3h\", \"7d\" or \"never\", never a number. A sleeping briq keeps its disk, costs nothing for compute, and the next use wakes it. \"never\" keeps it always on (Pro plan and above)"
        },
        "expose": {
          "type": "integer",
          "minimum": 1,
          "maximum": 65535,
          "description": "The port a public URL delivers to, when the briq has several: its front door. Declaring it publishes nothing"
        }
      },
      "required": [
        "name",
        "image"
      ]
    }
  }
}