{
  "openapi": "3.1.0",
  "info": {
    "title": "Basecamp API",
    "version": "0.5.0",
    "description": "Resolve reproducible development environments from project-native inputs."
  },
  "servers": [
    {
      "url": "https://api.basecamp.sh"
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "summary": "Get service health and supported stacks",
        "responses": {
          "200": {
            "description": "Healthy service"
          }
        }
      }
    },
    "/v1/prepare": {
      "post": {
        "summary": "Resolve a development environment lock",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PrepareRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Resolved environment lock",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrepareResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid project input"
          },
          "404": {
            "description": "Unsupported stack"
          }
        }
      }
    },
    "/v1/layers/{kind}/{id}": {
      "get": {
        "summary": "Download a Basecamp CAS layer",
        "description": "Fallback path for layers whose source.type is basecamp.",
        "parameters": [
          {
            "name": "kind",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Layer bytes"
          }
        }
      }
    },
    "/v1/downloads/{version}/{asset}": {
      "get": {
        "summary": "Download a published Basecamp CLI asset",
        "parameters": [
          {
            "name": "version",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "asset",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Release asset"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "PrepareRequest": {
        "type": "object",
        "required": [
          "stack",
          "host",
          "inputs"
        ],
        "properties": {
          "stack": {
            "type": "string"
          },
          "runtime": {
            "type": "string"
          },
          "host": {
            "type": "string"
          },
          "target": {
            "type": "string"
          },
          "inputs": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "required": [
                "kind",
                "path",
                "digest"
              ],
              "properties": {
                "kind": {
                  "type": "string"
                },
                "path": {
                  "type": "string"
                },
                "digest": {
                  "type": "string",
                  "pattern": "^sha256:[a-f0-9]{64}$"
                }
              },
              "additionalProperties": false
            }
          }
        },
        "additionalProperties": false
      },
      "PrepareResponse": {
        "type": "object",
        "required": [
          "stack",
          "status",
          "environment_id"
        ],
        "properties": {
          "stack": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "environment_id": {
            "type": "string"
          },
          "needs_lock": {
            "type": "boolean"
          },
          "lock": {
            "$ref": "#/components/schemas/BasecampLock"
          }
        }
      },
      "BasecampLock": {
        "type": "object",
        "description": "See /schema/basecamp-lock.json for the canonical JSON Schema."
      }
    }
  }
}
