{
  "openapi": "3.1.0",
  "info": {
    "title": "Quernbox agent API",
    "version": "0.1.0"
  },
  "servers": [
    {
      "url": "https://agents.gentlenickel.shop"
    }
  ],
  "paths": {
    "/signup": {
      "post": {
        "operationId": "createSignup",
        "summary": "Get an API key",
        "description": "Issues a test API key. Nothing is charged.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "company": {
                    "type": "string"
                  },
                  "use_case": {
                    "type": "string",
                    "maxLength": 1000
                  }
                },
                "required": [
                  "email",
                  "company",
                  "use_case"
                ]
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "company": {
                    "type": "string"
                  },
                  "use_case": {
                    "type": "string",
                    "maxLength": 1000
                  }
                },
                "required": [
                  "email",
                  "company",
                  "use_case"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Test key issued",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "const": "received"
                    },
                    "api_key": {
                      "type": "string",
                      "pattern": "^qbx_test_[a-z0-9]+$"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Fields missing or invalid; send the request again with them",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "missing": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "invalid": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/templates": {
      "get": {
        "operationId": "list-templates",
        "summary": "List templates",
        "description": "Templates a sandbox can start from. No key needed.",
        "responses": {
          "200": {
            "description": "Dummy answer: plausible test data, nothing is fulfilled",
            "content": {
              "application/json": {
                "example": {
                  "templates": [
                    {
                      "name": "ubuntu-24.04",
                      "contents": "git, curl, build-essential"
                    },
                    {
                      "name": "python-3.12",
                      "contents": "Python 3.12, pip, uv, pytest"
                    },
                    {
                      "name": "node-22",
                      "contents": "Node.js 22, npm, pnpm"
                    },
                    {
                      "name": "go-1.23",
                      "contents": "Go 1.23"
                    },
                    {
                      "name": "rust-1.82",
                      "contents": "Rust 1.82, cargo"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Body or required fields missing",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "missing": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "invalid": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/sandboxes": {
      "post": {
        "operationId": "create-sandbox",
        "summary": "Create a sandbox",
        "description": "template (for example python-3.12) and size (small, medium or large) are required. Optional: timeout_seconds, network (default or none).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "template": {
                    "type": "string"
                  },
                  "size": {
                    "type": "string"
                  }
                },
                "required": [
                  "template",
                  "size"
                ]
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "201": {
            "description": "Dummy answer: plausible test data, nothing is fulfilled",
            "content": {
              "application/json": {
                "example": {
                  "id": "sbx_0123456789abcdef",
                  "status": "running",
                  "template": "template",
                  "size": "size",
                  "started_at": "2026-01-01T00:00:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "Body or required fields missing",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "missing": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "invalid": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "missing": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "invalid": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/sandboxes/{sandbox_id}": {
      "get": {
        "operationId": "get-sandbox",
        "summary": "Get a sandbox",
        "description": "Status, template, size and start time of one sandbox.",
        "parameters": [
          {
            "name": "sandbox_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Dummy answer: plausible test data, nothing is fulfilled",
            "content": {
              "application/json": {
                "example": {
                  "id": "sandbox_id",
                  "status": "running",
                  "template": "python-3.12",
                  "size": "small",
                  "checked_at": "2026-01-01T00:00:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "Body or required fields missing",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "missing": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "invalid": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "missing": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "invalid": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/sandboxes/{sandbox_id}/exec": {
      "post": {
        "operationId": "exec-command",
        "summary": "Run a command",
        "description": "command is run with /bin/sh -c in /workspace. Optional timeout_seconds, default 300. Returns exit_code, stdout and stderr.",
        "parameters": [
          {
            "name": "sandbox_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "command": {
                    "type": "string"
                  }
                },
                "required": [
                  "command"
                ]
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Dummy answer: plausible test data, nothing is fulfilled",
            "content": {
              "application/json": {
                "example": {
                  "sandbox_id": "sandbox_id",
                  "exit_code": 0,
                  "stdout": "",
                  "stderr": "",
                  "duration_ms": 412
                }
              }
            }
          },
          "400": {
            "description": "Body or required fields missing",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "missing": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "invalid": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "missing": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "invalid": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/sandboxes/{sandbox_id}/stop": {
      "post": {
        "operationId": "stop-sandbox",
        "summary": "Stop a sandbox",
        "description": "Stops the sandbox and ends billing for it. Stopping twice is not an error.",
        "parameters": [
          {
            "name": "sandbox_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {},
                "required": []
              }
            }
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Dummy answer: plausible test data, nothing is fulfilled",
            "content": {
              "application/json": {
                "example": {
                  "id": "sandbox_id",
                  "status": "stopped",
                  "stopped_at": "2026-01-01T00:00:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "Body or required fields missing",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "missing": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "invalid": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "missing": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "invalid": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "Test key from POST /signup (qbx_test_...)"
      }
    }
  }
}
