{
  "openapi": "3.0.1",
  "info": {
    "title": "Sequentum Cloud API",
    "description": "API endpoints for Sequentum Cloud",
    "version": "v1"
  },
  "paths": {
    "/api/v1/agent/all": {
      "get": {
        "tags": [
          "ApiAgent"
        ],
        "summary": "Get all agents",
        "description": "Returns a list of agents accessible to the authenticated user within their organization.\n\nSupports optional pagination, filtering, and sorting. When pagination parameters are\nprovided, returns a paginated response with `totalRecordCount`. When no pagination\nparameters are provided, returns a simple array for backward compatibility.\n\n**Filtering**\n\n- `name` — filter by agent name (case-insensitive contains match)\n- `status` — filter by last run status (`RunStatus` enum):\n  - not provided: no filter\n  - `1` Running\n  - `4` Queuing\n  - `6` Failure\n  - `7` Failed\n  - `8` Stopped\n  - `9` Completed\n  - `10` Success\n\n  Agents that have never run report `status = null`.\n- `spaceId` — filter by space ID\n- `configType` — filter by config type\n\n**Sorting**\n\n- `sortColumn` — `name` | `lastActivity` | `created` | `updated` | `status` | `configType` (default: `name`)\n- `sortOrder` — `0` ascending (default) | `1` descending\n\n**Response format**\n\n- Without pagination params: array of agents (backward compatible)\n- With pagination params: `{ agents: [...], totalRecordCount: N }`",
        "parameters": [
          {
            "name": "pageIndex",
            "in": "query",
            "description": "Page number (1-based). If provided with recordsPerPage, enables pagination.",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "recordsPerPage",
            "in": "query",
            "description": "Number of records per page. If provided with pageIndex, enables pagination.",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "sortColumn",
            "in": "query",
            "description": "Column to sort by: name, lastActivity, created, updated, status, configType",
            "schema": {
              "type": "string",
              "default": "name"
            }
          },
          {
            "name": "sortOrder",
            "in": "query",
            "description": "Sort order: 0 = ascending (default), 1 = descending",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 0
            }
          },
          {
            "name": "name",
            "in": "query",
            "description": "Filter by agent name (contains match, case-insensitive)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Filter by last run status (RunStatus: 0=Invalid, 1=Running, 2=Exporting, 3=Starting, 4=Queuing, 5=Stopping, 6=Failure, 7=Failed, 8=Stopped, 9=Completed, 10=Success, 11=Skipped, 12=Waiting). Agents that never ran have null status.",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "spaceId",
            "in": "query",
            "description": "Filter by space ID",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "configType",
            "in": "query",
            "description": "Filter by config type",
            "schema": {
              "$ref": "#/components/schemas/ConfigType"
            }
          },
          {
            "name": "includeArchived",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "Returns the list of agents (array without pagination, object with pagination)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AgentApiModel"
                  }
                }
              }
            }
          },
          "400": {
            "description": "If the request is invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestError"
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/search": {
      "get": {
        "tags": [
          "ApiAgent"
        ],
        "summary": "Search for agents by name or description",
        "description": "Searches for agents by matching the query term against agent names and descriptions (case-insensitive).\n\nReturns agents accessible to the authenticated user within their organization. Results are\nlimited to prevent performance issues — use `maxRecords` to control the limit.",
        "parameters": [
          {
            "name": "query",
            "in": "query",
            "description": "The search term to match against agent names and descriptions",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "maxRecords",
            "in": "query",
            "description": "Maximum number of results to return. Defaults to 50, max 1000.",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "includeArchived",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "Returns the list of matching agents",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AgentApiModel"
                  }
                }
              }
            }
          },
          "400": {
            "description": "If the query is empty or invalid, or maxRecords is out of range",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestError"
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/{agentId}/runs": {
      "get": {
        "tags": [
          "ApiAgent"
        ],
        "summary": "Get all runs for agent",
        "description": "Returns a list of all runs and run history for an agent. Most recent records are returned first.",
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "description": "The id of the agent",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "maxRecords",
            "in": "query",
            "description": "The maximum number of records to return. If not specified, only the most recent 50 runs will be returned.",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AgentRunApiModel"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestError"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/{agentId}/run/{runId}/status": {
      "get": {
        "tags": [
          "ApiAgent"
        ],
        "summary": "Get the status of a specific run",
        "description": "Returns the current status and details of a specific run. Faster than the agent-runs\nlist endpoint when you only need to check a single run; checks both the active runs\ntable and the run history.",
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "description": "The ID of the agent/config",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "runId",
            "in": "path",
            "description": "The ID of the run to check",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "Returns the run status and details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentRunApiModel"
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "If the run or agent is not found, or user doesn't have access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/{agentId}/run/{runId}/files": {
      "get": {
        "tags": [
          "ApiAgent"
        ],
        "summary": "Get all files for agent run",
        "description": "Get a list of of the files that were created when an agent was run.",
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "description": "The ID of the agent/config",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "runId",
            "in": "path",
            "description": "The ID of the run",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AgentRunFileApiModel"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestError"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/{agentId}/run/{runId}/file/{fileId}/download": {
      "get": {
        "tags": [
          "ApiAgent"
        ],
        "summary": "Download run file",
        "description": "Download the contents of a file from when an agent was run.",
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "description": "The ID of the agent/config",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "runId",
            "in": "path",
            "description": "The ID of the run",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "fileId",
            "in": "path",
            "description": "The ID of the file to download",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "302": {
            "description": "Found"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestError"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/{agentId}": {
      "get": {
        "tags": [
          "ApiAgent"
        ],
        "summary": "Get a single agent",
        "description": "Returns a specific agent accessible to the authenticated user within their organization.",
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "description": "The ID of the agent to retrieve",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "Returns the requested agent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentApiModel"
                }
              }
            }
          },
          "400": {
            "description": "If the request is invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestError"
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "If the agent is not found or user doesn't have access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/{agentId}/input-parameters": {
      "get": {
        "tags": [
          "ApiAgent"
        ],
        "summary": "Get input parameters for an agent",
        "description": "Returns the list of input parameters the agent expects, including whether each parameter is encrypted.\n\nUse this endpoint to discover which parameters to pass when calling the start-run endpoint,\nand which parameters are sensitive (encrypted at rest). For encrypted parameters the default\nvalue is not returned, to avoid leaking secrets.",
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "description": "The ID of the agent",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "Returns the list of input parameters",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AgentInputParameterApiModel"
                  }
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "If the agent is not found or user doesn't have access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/{agentId}/start": {
      "post": {
        "tags": [
          "ApiAgent"
        ],
        "summary": "Start a new agent run",
        "description": "Initiates a new run of the specified agent with the provided configuration parameters.\n\nSample request:\n```json\n{\n    \"inputParameters\": {\n        \"param1\": \"value1\",\n        \"param2\": \"value2\"\n    },\n    \"parallelism\": 1,\n    \"parallelMaxConcurrency\": 2,\n    \"parallelExport\": true,\n    \"proxyPoolId\": 123,\n    \"isExclusive\": false,\n    \"isWaitOnFailure\": true,\n    \"logLevel\": \"Info\",\n    \"logMode\": \"Normal\"\n}\n```",
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "description": "The ID of the agent to run",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "description": "The configuration parameters for the run",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StartAgentApiRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/StartAgentApiRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/StartAgentApiRequest"
              }
            }
          }
        },
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "Returns the ID of the newly created run",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentRunApiModel"
                }
              }
            }
          },
          "400": {
            "description": "If the request is invalid or there was an error starting the agent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestError"
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid, or the user doesn't have permission to run the agent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "If the agent is not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/{agentId}/run/{runId}/stop": {
      "post": {
        "tags": [
          "ApiAgent"
        ],
        "summary": "Stop a running agent",
        "description": "Stops a specific running agent instance.",
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "description": "The ID of the agent that contains the run",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "runId",
            "in": "path",
            "description": "The ID of the run to stop",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "The agent was successfully stopped"
          },
          "400": {
            "description": "If the request is invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestError"
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "If the agent is not found or user doesn't have access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "500": {
            "description": "If an unexpected server error occurs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/{agentId}/run/{runId}/kill": {
      "post": {
        "tags": [
          "ApiAgent"
        ],
        "summary": "Kill a running agent",
        "description": "Forcefully kills a specific running agent instance. The kill operation behaves differently\nbased on the current state:\n\n- **First call** — initiates a graceful stop (equivalent to the stop-run endpoint).\n- **Second call** — if the run is still stopping, forces immediate termination of the server process.\n\nUse this endpoint when a normal stop is not responding or when you need to force-terminate a stuck Run.",
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "description": "The ID of the agent that contains the run",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "runId",
            "in": "path",
            "description": "The ID of the run to kill",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "The kill command was successfully sent"
          },
          "400": {
            "description": "If the request is invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestError"
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "If the agent is not found or user doesn't have access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "500": {
            "description": "If an unexpected server error occurs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/{agentId}/run/{runId}": {
      "delete": {
        "tags": [
          "ApiAgent"
        ],
        "summary": "Delete a run and all its associated data",
        "description": "Deletes a specific run and all its associated data, including files and storage.\nThis is primarily used for PII compliance when an agent extracts personally identifiable\ninformation. The run can be in either the active Runs table or the RunHistory table —\nboth are checked automatically.\n\nThe `removeMethod` parameter controls what is deleted:\n\n- **`RemoveEntireRun`** (default) — completely removes the run record and all associated files.\n- **`RemoveAllFiles`** — removes files but keeps the run record.\n- **`RemoveAllFilesAndAgentInput`** — removes files and clears agent input parameters.",
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "description": "The ID of the agent that contains the run",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "runId",
            "in": "path",
            "description": "The ID of the run to delete",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "removeMethod",
            "in": "query",
            "description": "The deletion method to use. Defaults to RemoveEntireRun.",
            "schema": {
              "$ref": "#/components/schemas/RemoveRunMethod"
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "204": {
            "description": "The run was successfully deleted"
          },
          "400": {
            "description": "If the request is invalid",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestError"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestError"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestError"
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "If the agent or run is not found, or user doesn't have access",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "500": {
            "description": "If an unexpected server error occurs or the run could not be deleted",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerError"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerError"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/{agentId}/version/{versionNumber}/restore": {
      "post": {
        "tags": [
          "ApiAgent"
        ],
        "summary": "Restore to a previous agent version",
        "description": "Restores a previous version of an agent configuration as the new version.\n\nSample request:\n```json\n{\n  \"content\":\"Comments about why this version is being restored\"\n}\n```",
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "description": "The ID of the agent",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "versionNumber",
            "in": "path",
            "description": "The version number to restore",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "description": "Comments to include with the restored version",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StringContent"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/StringContent"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/StringContent"
              }
            }
          }
        },
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "The version was successfully restored"
          },
          "400": {
            "description": "If the request is invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestError"
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid, or the user doesn't have permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "If the agent or version is not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/{agentId}/versions": {
      "get": {
        "tags": [
          "ApiAgent"
        ],
        "summary": "Get all versions of an agent",
        "description": "Returns a list of all versions of the specified agent. The active version is always the largest version number\n\nRequires authorization.",
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "description": "The ID of the agent",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "A collection of agent versions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AgentVersionModel"
                  }
                }
              }
            }
          },
          "400": {
            "description": "If the request is invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestError"
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid, or the user doesn't have permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "If the agent is not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/{agentId}/schedules": {
      "get": {
        "tags": [
          "ApiAgent"
        ],
        "summary": "Get all schedules for a specific agent",
        "description": "Returns a list of all scheduled tasks configured for the specified agent.",
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "description": "The ID of the agent",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "Returns the list of schedules",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AgentScheduleApiModel"
                  }
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "If the agent is not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "ApiAgent"
        ],
        "summary": "Create a new schedule for an agent",
        "description": "Creates a new scheduled task that will automatically run the agent based on the specified schedule.\n\n**Schedule Types:**\n- **CRON (3)**: Use cronExpression to define a recurring schedule\n- **RunOnce (1)**: Requires startTime (must be at least 1 minute in the future) - runs once at the specified date/time\n- **RunEvery (2)**: Uses runEveryCount and runEveryPeriod (0=minutes, 1=hours, 2=days, 3=weeks, 4=months). Optional startTime for first run (must be in the future if provided).\n\n**StartTime Validation:**\n- For **RunOnce**: Required. Must be at least 1 minute in the future (UTC).\n- For **RunEvery**: Optional. If provided, must be in the future (UTC). Determines when the first run occurs.\n- For **CRON**: Not used. Schedule is determined by cronExpression.\n\n**CRON Schedule Example:**\n```json\n{\n    \"name\": \"Daily Morning Run\",\n    \"scheduleType\": 3,\n    \"cronExpression\": \"0 9 * * 1,4\",\n    \"timezone\": \"America/New_York\",\n    \"isEnabled\": true\n}\n```\n\n**Run Once Example:**\n```json\n{\n    \"name\": \"One-time Run\",\n    \"scheduleType\": 1,\n    \"startTime\": \"2026-01-20T14:30:00Z\",\n    \"timezone\": \"America/New_York\",\n    \"isEnabled\": true\n}\n```\n\n**Run Every Example (every 30 minutes):**\n```json\n{\n    \"name\": \"Frequent Check\",\n    \"scheduleType\": 2,\n    \"runEveryCount\": 30,\n    \"runEveryPeriod\": 0,\n    \"startTime\": \"2026-01-17T10:00:00Z\",\n    \"timezone\": \"America/Denver\",\n    \"isEnabled\": true\n}\n```",
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "description": "The ID of the agent",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "description": "The schedule configuration",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateScheduleApiRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateScheduleApiRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/CreateScheduleApiRequest"
              }
            }
          }
        },
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "Returns the created schedule",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentScheduleApiModel"
                }
              }
            }
          },
          "400": {
            "description": "If the request is invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestError"
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "If the agent is not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/{agentId}/schedules/{scheduleId}": {
      "delete": {
        "tags": [
          "ApiAgent"
        ],
        "summary": "Delete a schedule",
        "description": "Permanently removes the specified schedule from the agent.",
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "description": "The ID of the agent",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "scheduleId",
            "in": "path",
            "description": "The ID of the schedule to delete",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "204": {
            "description": "Schedule deleted successfully"
          },
          "401": {
            "description": "If the API key is missing or invalid",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "If the agent or schedule is not found",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "ApiAgent"
        ],
        "summary": "Get a specific schedule by ID",
        "description": "Returns the details of a specific schedule for an agent.",
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "description": "The ID of the agent",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "scheduleId",
            "in": "path",
            "description": "The ID of the schedule",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "Returns the schedule details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentScheduleApiModel"
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "If the agent or schedule is not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "ApiAgent"
        ],
        "summary": "Update an existing schedule",
        "description": "Updates the configuration of an existing scheduled task.\n\n**Schedule Types:**\n- **CRON (3)**: Use cronExpression to define a recurring schedule\n- **RunOnce (1)**: Requires startTime (must be in the future) - runs once at the specified date/time\n- **RunEvery (2)**: Uses runEveryCount and runEveryPeriod. Optional startTime for first run.",
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "description": "The ID of the agent",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "scheduleId",
            "in": "path",
            "description": "The ID of the schedule to update",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "description": "The updated schedule configuration",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateScheduleApiRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateScheduleApiRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateScheduleApiRequest"
              }
            }
          }
        },
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "Returns the updated schedule",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentScheduleApiModel"
                }
              }
            }
          },
          "400": {
            "description": "If the request is invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestError"
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "If the agent or schedule is not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/{agentId}/schedules/{scheduleId}/enable": {
      "post": {
        "tags": [
          "ApiAgent"
        ],
        "summary": "Enable a schedule",
        "description": "Enables a previously disabled schedule so it will run according to its configuration.",
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "description": "The ID of the agent",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "scheduleId",
            "in": "path",
            "description": "The ID of the schedule to enable",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "Schedule enabled successfully"
          },
          "401": {
            "description": "If the API key is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "If the agent or schedule is not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/{agentId}/schedules/{scheduleId}/disable": {
      "post": {
        "tags": [
          "ApiAgent"
        ],
        "summary": "Disable a schedule",
        "description": "Disables a schedule so it will not run until it is enabled again.",
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "description": "The ID of the agent",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "scheduleId",
            "in": "path",
            "description": "The ID of the schedule to disable",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "Schedule disabled successfully"
          },
          "401": {
            "description": "If the API key is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "If the agent or schedule is not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/{agentId}/archive": {
      "post": {
        "tags": [
          "ApiAgent"
        ],
        "summary": "Archive an agent",
        "description": "Archives an agent, hiding it from default list views and disabling all schedules.\nArchived agents can still be accessed by ID and appear in list endpoints when\n`includeArchived=true`.",
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "description": "The ID of the agent to archive",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "Agent archived successfully"
          },
          "400": {
            "description": "If the agent is not found, is not an agent, or is already archived",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerError"
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid, or the user doesn't have permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/{agentId}/unarchive": {
      "post": {
        "tags": [
          "ApiAgent"
        ],
        "summary": "Unarchive an agent",
        "description": "Restores a previously archived agent so it appears in default list views again.\nSchedules remain disabled after unarchiving and must be re-enabled manually.",
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "description": "The ID of the agent to unarchive",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "Agent unarchived successfully"
          },
          "400": {
            "description": "If the agent is not found, is not an agent, or is not archived",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerError"
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid, or the user doesn't have permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent-builder/start": {
      "post": {
        "tags": [
          "ApiAgentBuilder"
        ],
        "summary": "Start a new agent building session",
        "description": "**Session Lifecycle**\n\n1. **POST /start** (this endpoint) — create a session from a prompt → returns `sessionId`.\n2. **GET /{sessionId}/status** — poll every few seconds until `status` is `\"completed\"`\n   (the AI finished building the agent successfully), `\"ready\"` (the AI finished its turn\n   but the agent may not have been saved yet), or `\"error\"`. On any terminal status the\n   response also contains `agentId` and `agentName`; **stop polling at that point**.\n   Subsequent calls may return the same terminal response or `404` — both mean the build\n   is done.\n3. **POST /{sessionId}/stop** *(optional)* — abort the session early if you no longer\n   want the build to continue. Returns `204 No Content`. Has no effect once the session\n   has already reached a terminal state.\n\n> **Note:** The session tears down automatically a short time after reaching a terminal\n> status — no explicit teardown call is required. The agent draft is saved in your\n> workspace as soon as the AI creates it (before the session ends). The draft persists\n> whether or not you call `/stop`; use the standard agents API to delete unwanted drafts.",
        "operationId": "AgentBuilder_StartSession",
        "requestBody": {
          "description": "The prompt and optional space to save to",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExternalStartAgentBuildRequest"
              }
            }
          }
        },
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequestsError"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalStartAgentBuildResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestError"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceUnavailableError"
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerError"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "cURL",
            "source": "curl https://dashboard.sequentum.com/api/v1/agent-builder/start \\\n  -H \"Authorization: ApiKey $SEQUENTUM_API_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"prompt\": \"Build an agent that extracts product names and prices from example.com.\",\n    \"spaceId\": 42\n  }'"
          },
          {
            "lang": "node",
            "label": "Node.js",
            "source": "const res = await fetch(\"https://dashboard.sequentum.com/api/v1/agent-builder/start\", {\n  method: \"POST\",\n  headers: {\n    \"Authorization\": `ApiKey ${process.env.SEQUENTUM_API_KEY}`,\n    \"Content-Type\": \"application/json\",\n  },\n  body: JSON.stringify({\n    prompt: \"Build an agent that extracts product names and prices from example.com.\",\n    spaceId: 42,\n  }),\n});\n\nconst { sessionId } = await res.json();\nconsole.log(`Started session ${sessionId}`);"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport requests\n\nresponse = requests.post(\n    \"https://dashboard.sequentum.com/api/v1/agent-builder/start\",\n    headers={\n        \"Authorization\": f\"ApiKey {os.environ['SEQUENTUM_API_KEY']}\",\n        \"Content-Type\": \"application/json\",\n    },\n    json={\n        \"prompt\": \"Build an agent that extracts product names and prices from example.com.\",\n        \"spaceId\": 42,\n    },\n)\nresponse.raise_for_status()\nsession_id = response.json()[\"sessionId\"]\nprint(f\"Started session {session_id}\")"
          }
        ]
      }
    },
    "/api/v1/agent-builder/{sessionId}/status": {
      "get": {
        "tags": [
          "ApiAgentBuilder"
        ],
        "summary": "Get current status for a session (lightweight polling endpoint)",
        "operationId": "AgentBuilder_GetSessionStatus",
        "parameters": [
          {
            "name": "sessionId",
            "in": "path",
            "description": "The session ID returned from /start",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalSessionStatusResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent-builder/{sessionId}/stop": {
      "post": {
        "tags": [
          "ApiAgentBuilder"
        ],
        "summary": "Stop and clean up a session, releasing all associated resources",
        "operationId": "AgentBuilder_StopSession",
        "parameters": [
          {
            "name": "sessionId",
            "in": "path",
            "description": "The session ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "204": {
            "description": "No Content"
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/analytics/runs/summary": {
      "get": {
        "tags": [
          "ApiAnalytics"
        ],
        "summary": "Get runs summary for a date range",
        "description": "Returns a summary of all runs (completed, failed, running, etc.) within the specified date range.\nUseful for answering questions like:\n- \"How many agents ran yesterday?\"\n- \"What agents failed last week?\"",
        "parameters": [
          {
            "name": "startDate",
            "in": "query",
            "description": "Start date for the range (ISO format, defaults to yesterday)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "End date for the range (ISO format, defaults to now)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Optional: Filter by specific status (Failed, Completed, etc.)",
            "schema": {
              "$ref": "#/components/schemas/RunStatus"
            }
          },
          {
            "name": "includeDetails",
            "in": "query",
            "description": "Whether to include details of failed runs (default: true)",
            "schema": {
              "type": "boolean",
              "default": true
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "Returns the runs summary",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RunsSummaryApiModel"
                }
              }
            }
          },
          "400": {
            "description": "If the date range is invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestError"
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/analytics/records/summary": {
      "get": {
        "tags": [
          "ApiAnalytics"
        ],
        "summary": "Get records summary for a date range",
        "description": "Returns a summary of records extracted and exported within the specified date range.\nUseful for answering questions like \"How many records did the agent download yesterday?\"",
        "parameters": [
          {
            "name": "startDate",
            "in": "query",
            "description": "Start date for the range (ISO format, defaults to yesterday)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "End date for the range (ISO format, defaults to now)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "agentId",
            "in": "query",
            "description": "Optional: Filter by specific agent ID",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "Returns the records summary",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordsSummaryApiModel"
                }
              }
            }
          },
          "400": {
            "description": "If the date range is invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestError"
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/analytics/schedules/upcoming": {
      "get": {
        "tags": [
          "ApiAnalytics"
        ],
        "summary": "Get all upcoming scheduled runs in a date range",
        "description": "Returns all scheduled runs that are configured to execute within the specified date range.\nUseful for answering questions like \"What agents are scheduled to run this week?\"",
        "parameters": [
          {
            "name": "startDate",
            "in": "query",
            "description": "Start date for the range (ISO format)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "End date for the range (ISO format)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "Returns the list of upcoming scheduled runs",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/UpcomingScheduleApiModel"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestError"
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/analytics/agents/{agentId}/runs/{runId}/diagnostics": {
      "get": {
        "tags": [
          "ApiAnalytics"
        ],
        "summary": "Get detailed diagnostics for a run",
        "description": "Returns detailed diagnostic information for a specific run, including error messages,\nstatistics, possible causes of failure, and suggested remediation actions.\nUseful for answering questions like \"Why did my agent fail?\"",
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "description": "The ID of the agent",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "runId",
            "in": "path",
            "description": "The ID of the run",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "Returns the run diagnostics",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RunDiagnosticsApiModel"
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "If the agent or run is not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/analytics/agents/{agentId}/latest-failure": {
      "get": {
        "tags": [
          "ApiAnalytics"
        ],
        "summary": "Get the most recent failed run for an agent",
        "description": "Returns diagnostics for the most recent failed run of the specified agent.\nUseful when asking \"Why did my agent fail?\" without specifying a run ID.",
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "description": "The ID of the agent",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "Returns the run diagnostics",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RunDiagnosticsApiModel"
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "If the agent is not found or has no failed runs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/billing/credits": {
      "get": {
        "tags": [
          "ApiBilling"
        ],
        "summary": "Get available credits balance",
        "description": "Returns the current available credits balance for the user's organization.\nUseful for answering questions like \"How many credits do I have left?\"\n\nNOTE: As of migration 100160, balance is computed from active grants (RemainingAmount-based)\nrather than the legacy running Balance ledger column. This is intentional; orgs that relied\non the old positive-balance row while having exhausted their grants will now see 0 instead.",
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "Returns the credits balance",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreditsBalanceApiModel"
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/billing/spending": {
      "get": {
        "tags": [
          "ApiBilling"
        ],
        "summary": "Get spending summary for a date range",
        "description": "Returns the total amount spent within the specified date range.\nUseful for answering questions like \"How much have I spent this week?\"",
        "parameters": [
          {
            "name": "startDate",
            "in": "query",
            "description": "Start date for the range (ISO format, defaults to start of current week)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "End date for the range (ISO format, defaults to now)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "Returns the spending summary",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SpendingSummaryApiModel"
                }
              }
            }
          },
          "400": {
            "description": "If the date range is invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestError"
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/billing/history": {
      "get": {
        "tags": [
          "ApiBilling"
        ],
        "summary": "Get credit transaction history",
        "description": "Returns the history of credit transactions (additions, deductions, etc.) for the organization.",
        "parameters": [
          {
            "name": "pageIndex",
            "in": "query",
            "description": "Page number (1-based, default: 1)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "recordsPerPage",
            "in": "query",
            "description": "Records per page (default: 50, max: 100)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 50
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "Returns the credit history",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreditHistoryApiModel"
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/billing/agents": {
      "get": {
        "tags": [
          "ApiBilling"
        ],
        "summary": "Get all agents with their costs for a date range",
        "description": "Returns a paginated list of agents with their total costs within the specified date range.\nOnly returns agents the authenticated user has access to.\n\n**Filtering**\n\n- `name` — filter by agent name (case-insensitive contains match)\n- `usageTypes` — filter by usage type (comma-separated: `Server Time`, `Export GB`, `Agent Inputs`, `Proxy Data`, `Export CPM`)\n\n**Sorting**\n\n- `sortColumn` — `name` | `cost` (default: `name`)\n- `sortOrder` — `0` ascending (default) | `1` descending",
        "parameters": [
          {
            "name": "startDate",
            "in": "query",
            "description": "Start date for the range (ISO format, required)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "End date for the range (ISO format, required)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "pageIndex",
            "in": "query",
            "description": "Page number (1-based, default: 1)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "recordsPerPage",
            "in": "query",
            "description": "Records per page (default: 50, max: 1000)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 50
            }
          },
          {
            "name": "sortColumn",
            "in": "query",
            "description": "Column to sort by: name, cost",
            "schema": {
              "type": "string",
              "default": "name"
            }
          },
          {
            "name": "sortOrder",
            "in": "query",
            "description": "Sort order: 0 = ascending (default), 1 = descending",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 0
            }
          },
          {
            "name": "name",
            "in": "query",
            "description": "Filter by agent name (contains match, case-insensitive)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "usageTypes",
            "in": "query",
            "description": "Filter by usage types (comma-separated)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "Returns the paginated list of agents with costs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentsUsageApiResponse"
                }
              }
            }
          },
          "400": {
            "description": "If the request is invalid (e.g., missing date range)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestError"
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/billing/agents/{agentId}": {
      "get": {
        "tags": [
          "ApiBilling"
        ],
        "summary": "Get cost breakdown for a specific agent over time",
        "description": "Returns the cost breakdown by usage type for a specific agent within the specified date range.\nUseful for visualizing agent costs over time in charts.",
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "description": "The agent ID",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "Start date for the range (ISO format, required)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "End date for the range (ISO format, required)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "timeUnit",
            "in": "query",
            "description": "Time unit for grouping data: day (default), month",
            "schema": {
              "type": "string",
              "default": "day"
            }
          },
          {
            "name": "usageTypes",
            "in": "query",
            "description": "Filter by usage types (comma-separated)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "Returns the cost breakdown",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentCostBreakdownApiModel"
                }
              }
            }
          },
          "400": {
            "description": "If the request is invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestError"
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "If the agent is not found or not accessible",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/billing/agents/{agentId}/runs": {
      "get": {
        "tags": [
          "ApiBilling"
        ],
        "summary": "Get individual run costs for a specific agent",
        "description": "Returns a paginated list of runs with their costs for a specific agent within the specified date range.\n\n**Filtering**\n\n- `usageTypes` — filter by usage type (comma-separated: `Server Time`, `Export GB`, `Agent Inputs`, `Proxy Data`, `Export CPM`)\n\n**Sorting**\n\n- `sortColumn` — `date` | `cost` | `duration` (default: `date`)\n- `sortOrder` — `0` ascending (default) | `1` descending",
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "description": "The agent ID",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "Start date for the range (ISO format, required)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "End date for the range (ISO format, required)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "pageIndex",
            "in": "query",
            "description": "Page number (1-based, default: 1)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "recordsPerPage",
            "in": "query",
            "description": "Records per page (default: 50, max: 1000)",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 50
            }
          },
          {
            "name": "sortColumn",
            "in": "query",
            "description": "Column to sort by: date, cost, duration",
            "schema": {
              "type": "string",
              "default": "date"
            }
          },
          {
            "name": "sortOrder",
            "in": "query",
            "description": "Sort order: 0 = ascending (default), 1 = descending",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 0
            }
          },
          {
            "name": "usageTypes",
            "in": "query",
            "description": "Filter by usage types (comma-separated)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "Returns the paginated list of runs with costs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentRunsApiResponse"
                }
              }
            }
          },
          "400": {
            "description": "If the request is invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestError"
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "If the agent is not found or not accessible",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/spaces": {
      "get": {
        "tags": [
          "ApiSpace"
        ],
        "summary": "Get all spaces accessible to the user",
        "description": "Returns a list of all spaces the authenticated user has access to within their organization.",
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "Returns the list of spaces",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SpaceApiModel"
                  }
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/spaces/{spaceId}": {
      "get": {
        "tags": [
          "ApiSpace"
        ],
        "summary": "Get a specific space by ID",
        "description": "Returns details of a specific space.",
        "parameters": [
          {
            "name": "spaceId",
            "in": "path",
            "description": "The ID of the space",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "Returns the space details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SpaceApiModel"
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "If the space is not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/spaces/{spaceId}/agents": {
      "get": {
        "tags": [
          "ApiSpace"
        ],
        "summary": "Get all agents in a space",
        "description": "Returns a list of all agents (configurations) within the specified space.",
        "parameters": [
          {
            "name": "spaceId",
            "in": "path",
            "description": "The ID of the space",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "Returns the list of agents",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SpaceAgentApiModel"
                  }
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "If the space is not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/spaces/{spaceId}/run-all": {
      "post": {
        "tags": [
          "ApiSpace"
        ],
        "summary": "Run all agents in a space",
        "description": "Starts every agent in the specified Space. Each agent is started independently;\nper-agent failures (for example, an agent that already has a Run in progress) are\nreported in the results without affecting the other agents.",
        "parameters": [
          {
            "name": "spaceId",
            "in": "path",
            "description": "The ID of the space",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "description": "Optional run parameters",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RunSpaceAgentsRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/RunSpaceAgentsRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/RunSpaceAgentsRequest"
              }
            }
          }
        },
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "Returns the results of starting each agent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RunSpaceAgentsResultApiModel"
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "If the space is not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/spaces/search": {
      "get": {
        "tags": [
          "ApiSpace"
        ],
        "summary": "Search for a space by name",
        "description": "Searches for a space by name within the user's organization.\nUseful for finding a space like \"Bot Blocking\" by name.",
        "parameters": [
          {
            "name": "name",
            "in": "query",
            "description": "The name of the space to search for",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "Returns the matching space",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SpaceApiModel"
                }
              }
            }
          },
          "401": {
            "description": "If the API key is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "If no space with that name is found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AgentApiModel": {
        "type": "object",
        "properties": {
          "agentTemplates": {
            "type": "string",
            "nullable": true
          },
          "configType": {
            "$ref": "#/components/schemas/ConfigType"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "documentation": {
            "type": "string",
            "nullable": true
          },
          "icon": {
            "type": "string",
            "nullable": true
          },
          "image": {
            "type": "string",
            "format": "byte",
            "nullable": true
          },
          "inputParameters": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "nullable": true
          },
          "id": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "isActive": {
            "type": "boolean",
            "readOnly": true
          },
          "lastActivity": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "proxyPoolId": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "spaceId": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "startUrl": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "userId": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "validationStatus": {
            "$ref": "#/components/schemas/ConfigValidationStatus"
          },
          "version": {
            "type": "integer",
            "format": "int32"
          },
          "created": {
            "type": "string",
            "format": "date-time"
          },
          "updated": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false
      },
      "AgentBuilderSessionStatus": {
        "enum": [
          "processing",
          "ready",
          "completed",
          "error",
          "cancelled"
        ],
        "type": "string",
        "description": "All observable status values for an agent builder session.\r\nSerialized as lowercase strings on the wire (processing, ready, completed, error, cancelled)."
      },
      "AgentCostBreakdownApiModel": {
        "type": "object",
        "properties": {
          "agentId": {
            "type": "integer",
            "description": "Agent ID",
            "format": "int32"
          },
          "agentName": {
            "type": "string",
            "description": "Agent name",
            "nullable": true
          },
          "labels": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Date labels for the chart (e.g., \"2024-01-01\", \"2024-01-02\")",
            "nullable": true
          },
          "usageTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UsageTypeDataApiModel"
            },
            "description": "Usage data grouped by type",
            "nullable": true
          },
          "totalCost": {
            "type": "number",
            "description": "Total cost across all usage types",
            "format": "double"
          },
          "startDate": {
            "type": "string",
            "description": "Start date of the range",
            "format": "date-time"
          },
          "endDate": {
            "type": "string",
            "description": "End date of the range",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "Cost breakdown for a specific agent over time"
      },
      "AgentInputParameterApiModel": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The parameter name to use when starting a run via the inputParameters field.",
            "nullable": true
          },
          "defaultValue": {
            "type": "string",
            "description": "The default value for this parameter, or null if the parameter is encrypted.\r\nEncrypted parameter values are never exposed through the API.",
            "nullable": true
          },
          "isEncrypted": {
            "type": "boolean",
            "description": "True if this parameter is stored encrypted at rest.\r\nWhen starting a run, callers can send plain text values for encrypted parameters\r\nand the server will encrypt them automatically."
          }
        },
        "additionalProperties": false,
        "description": "Describes an input parameter that an agent expects when starting a run."
      },
      "AgentRunApiModel": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "configId": {
            "type": "integer",
            "format": "int64"
          },
          "configName": {
            "type": "string",
            "nullable": true
          },
          "spaceId": {
            "type": "integer",
            "format": "int32"
          },
          "organizationId": {
            "type": "integer",
            "format": "int32"
          },
          "organizationName": {
            "type": "string",
            "nullable": true
          },
          "sequence": {
            "type": "integer",
            "format": "int64"
          },
          "parallelism": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "parallelMaxConcurrency": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "parallelExport": {
            "$ref": "#/components/schemas/ParallelExport"
          },
          "parallelSet": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "startTime": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "endTime": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "created": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/RunStatus"
          },
          "message": {
            "type": "string",
            "nullable": true
          },
          "configVersion": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "actionCount": {
            "type": "integer",
            "format": "int32"
          },
          "pageCount": {
            "type": "integer",
            "format": "int32"
          },
          "dynamicPageCount": {
            "type": "integer",
            "format": "int32"
          },
          "requestCount": {
            "type": "integer",
            "format": "int32"
          },
          "dataCount": {
            "type": "integer",
            "format": "int32"
          },
          "inputCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "errorCount": {
            "type": "integer",
            "format": "int32"
          },
          "exportCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "traffic": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          },
          "runTimeSec": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "serverName": {
            "type": "string",
            "nullable": true
          },
          "tableType": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "AgentRunCostApiModel": {
        "type": "object",
        "properties": {
          "runId": {
            "type": "integer",
            "description": "Run ID",
            "format": "int64"
          },
          "date": {
            "type": "string",
            "description": "Date of the run",
            "format": "date-time"
          },
          "startTime": {
            "type": "string",
            "description": "Start time of the run",
            "format": "date-time",
            "nullable": true
          },
          "endTime": {
            "type": "string",
            "description": "End time of the run",
            "format": "date-time",
            "nullable": true
          },
          "cost": {
            "type": "number",
            "description": "Cost for this run",
            "format": "double"
          },
          "billingType": {
            "type": "string",
            "description": "Billing type (e.g., \"Server Time\", \"Export GB\")",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Individual agent run with cost (for billing purposes)"
      },
      "AgentRunFileApiModel": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "regionId": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "fileType": {
            "$ref": "#/components/schemas/RunFileType"
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "fileSize": {
            "type": "integer",
            "format": "int64"
          },
          "created": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false
      },
      "AgentRunResultApiModel": {
        "type": "object",
        "properties": {
          "agentId": {
            "type": "integer",
            "format": "int32"
          },
          "agentName": {
            "type": "string",
            "nullable": true
          },
          "success": {
            "type": "boolean"
          },
          "runId": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          },
          "errorMessage": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Individual agent run result"
      },
      "AgentRunsApiResponse": {
        "type": "object",
        "properties": {
          "runs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AgentRunCostApiModel"
            },
            "description": "List of runs with their costs",
            "nullable": true
          },
          "totalRecordCount": {
            "type": "integer",
            "description": "Total number of runs matching the filter",
            "format": "int32"
          },
          "totalCost": {
            "type": "number",
            "description": "Total cost across the runs in the current page.\r\nNote: this is a page-level sum, not a grand total across all pages.",
            "format": "double"
          },
          "agentId": {
            "type": "integer",
            "description": "Agent ID",
            "format": "int32"
          },
          "agentName": {
            "type": "string",
            "description": "Agent name",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Paginated response for agent runs"
      },
      "AgentScheduleApiModel": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "configId": {
            "type": "integer",
            "format": "int32"
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "schedule": {
            "type": "string",
            "nullable": true
          },
          "localSchedule": {
            "type": "string",
            "nullable": true
          },
          "timezone": {
            "type": "string",
            "nullable": true
          },
          "nextRunTime": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "startTime": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "scheduleType": {
            "$ref": "#/components/schemas/ScheduleType"
          },
          "isEnabled": {
            "type": "boolean"
          },
          "runEveryCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "runEveryPeriod": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "inputParameters": {
            "type": "string",
            "nullable": true
          },
          "parallelism": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "parallelMaxConcurrency": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "parallelExport": {
            "$ref": "#/components/schemas/ParallelExport"
          },
          "proxyPoolId": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "serverGroupId": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "logLevel": {
            "$ref": "#/components/schemas/LogLevel"
          },
          "logMode": {
            "$ref": "#/components/schemas/LogMode"
          },
          "isExclusive": {
            "type": "boolean"
          },
          "isWaitOnFailure": {
            "type": "boolean"
          },
          "created": {
            "type": "string",
            "format": "date-time"
          },
          "updated": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "Represents a scheduled task for an agent in the External API"
      },
      "AgentUsageApiModel": {
        "type": "object",
        "properties": {
          "agentId": {
            "type": "integer",
            "description": "Agent ID",
            "format": "int32"
          },
          "agentName": {
            "type": "string",
            "description": "Agent name",
            "nullable": true
          },
          "cost": {
            "type": "number",
            "description": "Total cost for the agent in the date range",
            "format": "double"
          },
          "spaceId": {
            "type": "integer",
            "description": "Space ID the agent belongs to (null for personal space)",
            "format": "int32",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Individual agent usage summary"
      },
      "AgentVersionModel": {
        "type": "object",
        "properties": {
          "userName": {
            "type": "string",
            "nullable": true
          },
          "version": {
            "type": "integer",
            "format": "int32"
          },
          "created": {
            "type": "string",
            "format": "date-time"
          },
          "comments": {
            "type": "string",
            "nullable": true
          },
          "fileSize": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "AgentsUsageApiResponse": {
        "type": "object",
        "properties": {
          "agents": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AgentUsageApiModel"
            },
            "description": "List of agents with their costs",
            "nullable": true
          },
          "totalRecordCount": {
            "type": "integer",
            "description": "Total number of agents matching the filter",
            "format": "int32"
          },
          "totalCost": {
            "type": "number",
            "description": "Total cost across all agents in the date range",
            "format": "double"
          },
          "startDate": {
            "type": "string",
            "description": "Start date of the range",
            "format": "date-time"
          },
          "endDate": {
            "type": "string",
            "description": "End date of the range",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "Paginated response for agent usage list"
      },
      "BadRequestError": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "integer",
            "format": "int32"
          },
          "statusDescription": {
            "type": "string",
            "nullable": true
          },
          "message": {
            "type": "string",
            "nullable": true,
            "readOnly": true
          },
          "severity": {
            "$ref": "#/components/schemas/ErrorSeverity"
          },
          "errorCode": {
            "type": "string",
            "description": "Optional machine-readable error code. When present, clients should switch on this\r\nvalue rather than parsing Sequentum.Enterprise.Core.ControllerError.Message. Omitted from the response when null.",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ConfigType": {
        "enum": [
          1,
          2,
          3,
          4
        ],
        "type": "integer",
        "format": "int32"
      },
      "ConfigValidationStatus": {
        "enum": [
          1,
          2,
          3
        ],
        "type": "integer",
        "format": "int32"
      },
      "CreateScheduleApiRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Name of the schedule (required)",
            "nullable": true
          },
          "cronExpression": {
            "type": "string",
            "description": "Cron expression for the schedule (e.g., \"0 9 * * 1,4\" for Mon/Thu at 9am)",
            "nullable": true
          },
          "localSchedule": {
            "type": "string",
            "description": "Local schedule expression (human readable)",
            "nullable": true
          },
          "timezone": {
            "type": "string",
            "description": "Timezone for the schedule (e.g., \"America/New_York\")",
            "nullable": true
          },
          "startTime": {
            "type": "string",
            "description": "Start date/time for the schedule in UTC.\r\n- Required for RunOnce schedules (must be at least 1 minute in the future).\r\n- Optional for RunEvery schedules (if provided, must be in the future; determines when the first run occurs).\r\n- Not used for CRON schedules.",
            "format": "date-time",
            "nullable": true,
            "example": "2026-01-20T14:30:00Z"
          },
          "inputParameters": {
            "type": "string",
            "description": "JSON string of input parameters for scheduled runs",
            "nullable": true
          },
          "scheduleType": {
            "$ref": "#/components/schemas/ScheduleType"
          },
          "isEnabled": {
            "type": "boolean",
            "description": "Whether the schedule is enabled"
          },
          "runEveryCount": {
            "type": "integer",
            "description": "Run every N periods (used with RunEveryPeriod)",
            "format": "int32",
            "nullable": true
          },
          "runEveryPeriod": {
            "type": "integer",
            "description": "Period unit for RunEveryCount (1=minutes, 2=hours, 3=days, 4=weeks, 5=months)",
            "format": "int32",
            "nullable": true
          },
          "parallelism": {
            "type": "integer",
            "description": "Parallelism level for the scheduled run",
            "format": "int32",
            "nullable": true
          },
          "parallelMaxConcurrency": {
            "type": "integer",
            "description": "Max concurrency for parallel runs",
            "format": "int32",
            "nullable": true
          },
          "parallelExport": {
            "$ref": "#/components/schemas/ParallelExport"
          },
          "proxyPoolId": {
            "type": "integer",
            "description": "Proxy pool ID to use for scheduled runs",
            "format": "int32",
            "nullable": true
          },
          "serverGroupId": {
            "type": "integer",
            "description": "Server group ID for scheduled runs (optional).\r\nWhen specified, the schedule will run on servers in this group.",
            "format": "int32",
            "nullable": true
          },
          "logLevel": {
            "$ref": "#/components/schemas/LogLevel"
          },
          "logMode": {
            "$ref": "#/components/schemas/LogMode"
          },
          "isExclusive": {
            "type": "boolean",
            "description": "Whether to run exclusively (no concurrent runs)"
          },
          "isWaitOnFailure": {
            "type": "boolean",
            "description": "Whether to wait on failure before retrying"
          }
        },
        "additionalProperties": false,
        "description": "Request model for creating a new schedule"
      },
      "CreditHistoryApiModel": {
        "type": "object",
        "properties": {
          "transactions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CreditTransactionApiModel"
            },
            "nullable": true
          },
          "totalCount": {
            "type": "integer",
            "format": "int32"
          },
          "pageIndex": {
            "type": "integer",
            "format": "int32"
          },
          "recordsPerPage": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "Response model for credit history"
      },
      "CreditTransactionApiModel": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "transactionType": {
            "type": "string",
            "nullable": true
          },
          "amount": {
            "type": "number",
            "format": "double"
          },
          "balance": {
            "type": "number",
            "format": "double"
          },
          "created": {
            "type": "string",
            "format": "date-time"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "message": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Individual credit transaction record"
      },
      "CreditsBalanceApiModel": {
        "type": "object",
        "properties": {
          "availableCredits": {
            "type": "number",
            "description": "Current available credits balance",
            "format": "double"
          },
          "organizationId": {
            "type": "integer",
            "description": "Organization ID",
            "format": "int32"
          },
          "retrievedAt": {
            "type": "string",
            "description": "Timestamp when the balance was retrieved",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "Response model for credits balance"
      },
      "ErrorSeverity": {
        "enum": [
          0,
          1,
          2,
          3,
          4
        ],
        "type": "integer",
        "format": "int32"
      },
      "ExternalSessionStatusResponse": {
        "type": "object",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/AgentBuilderSessionStatus"
          },
          "agentId": {
            "type": "integer",
            "description": "ID of the agent draft. Populated once the agent draft has been created in your workspace.\r\nAlways present when `status` is `\"completed\"` or `\"ready\"`.",
            "format": "int32",
            "nullable": true
          },
          "agentName": {
            "type": "string",
            "description": "Name of the agent draft. Populated alongside `agentId`.\r\nAlways present when `status` is `\"completed\"` or `\"ready\"`.",
            "nullable": true
          },
          "error": {
            "type": "string",
            "description": "Error message when status is \"error\".",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Session status response for the external API."
      },
      "ExternalStartAgentBuildRequest": {
        "required": [
          "prompt"
        ],
        "type": "object",
        "properties": {
          "prompt": {
            "maxLength": 5000,
            "minLength": 10,
            "type": "string",
            "description": "Natural language prompt describing the automation to build.\r\nMust be between 10 and 5000 characters (trimmed).",
            "x-minTrimmedLength": 10
          },
          "spaceId": {
            "type": "integer",
            "description": "Optional space ID to save the agent to. Uses the default space if omitted.",
            "format": "int32",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request to start an agent building session via the external API."
      },
      "ExternalStartAgentBuildResponse": {
        "required": [
          "sessionId"
        ],
        "type": "object",
        "properties": {
          "sessionId": {
            "minLength": 1,
            "type": "string",
            "description": "Session ID to use for status polling and subsequent calls."
          }
        },
        "additionalProperties": false,
        "description": "Response when starting an agent build session via the external API."
      },
      "FailedRunSummaryApiModel": {
        "type": "object",
        "properties": {
          "runId": {
            "type": "integer",
            "format": "int64"
          },
          "agentId": {
            "type": "integer",
            "format": "int32"
          },
          "agentName": {
            "type": "string",
            "nullable": true
          },
          "startTime": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "endTime": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/RunStatus"
          },
          "errorMessage": {
            "type": "string",
            "nullable": true
          },
          "spaceId": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "spaceName": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Summary of a failed run"
      },
      "InternalServerError": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "integer",
            "format": "int32"
          },
          "statusDescription": {
            "type": "string",
            "nullable": true
          },
          "message": {
            "type": "string",
            "nullable": true,
            "readOnly": true
          },
          "severity": {
            "$ref": "#/components/schemas/ErrorSeverity"
          },
          "errorCode": {
            "type": "string",
            "description": "Optional machine-readable error code. When present, clients should switch on this\r\nvalue rather than parsing Sequentum.Enterprise.Core.ControllerError.Message. Omitted from the response when null.",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "LogLevel": {
        "enum": [
          "Fatal",
          "Error",
          "Warning",
          "Info"
        ],
        "type": "string"
      },
      "LogMode": {
        "enum": [
          "Text",
          "TextAndHtml"
        ],
        "type": "string"
      },
      "ParallelExport": {
        "enum": [
          "Combined",
          "Separated"
        ],
        "type": "string"
      },
      "ProblemDetails": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "nullable": true
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "detail": {
            "type": "string",
            "nullable": true
          },
          "instance": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": { }
      },
      "RecordsSummaryApiModel": {
        "type": "object",
        "properties": {
          "startDate": {
            "type": "string",
            "description": "Start date of the range",
            "format": "date-time"
          },
          "endDate": {
            "type": "string",
            "description": "End date of the range",
            "format": "date-time"
          },
          "totalRecordsExtracted": {
            "type": "integer",
            "description": "Total records extracted across all runs",
            "format": "int64"
          },
          "totalRecordsExported": {
            "type": "integer",
            "description": "Total records exported across all runs",
            "format": "int64"
          },
          "totalErrors": {
            "type": "integer",
            "description": "Total errors across all runs",
            "format": "int64"
          },
          "totalPageLoads": {
            "type": "integer",
            "description": "Total page loads across all runs",
            "format": "int64"
          },
          "runCount": {
            "type": "integer",
            "description": "Number of runs included in this summary",
            "format": "int32"
          },
          "agentId": {
            "type": "integer",
            "description": "Optional agent ID filter",
            "format": "int32",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response model for records summary"
      },
      "RemoveRunMethod": {
        "enum": [
          "RemoveAllFiles",
          "RemoveAllFilesAndAgentInput",
          "RemoveEntireRun"
        ],
        "type": "string"
      },
      "RunDiagnosticsApiModel": {
        "type": "object",
        "properties": {
          "runId": {
            "type": "integer",
            "format": "int64"
          },
          "agentId": {
            "type": "integer",
            "format": "int32"
          },
          "agentName": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/RunStatus"
          },
          "errorMessage": {
            "type": "string",
            "nullable": true
          },
          "startTime": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "endTime": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "runtimeSeconds": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "stats": {
            "$ref": "#/components/schemas/RunStatsApiModel"
          },
          "possibleCauses": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Possible failure reasons based on status and error message",
            "nullable": true
          },
          "suggestedActions": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Suggested actions to resolve the issue",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response model for run diagnostics (why a run failed)"
      },
      "RunFileType": {
        "enum": [
          1,
          2,
          3,
          4,
          5,
          6,
          7
        ],
        "type": "integer",
        "format": "int32"
      },
      "RunSpaceAgentsRequest": {
        "type": "object",
        "properties": {
          "inputParameters": {
            "type": "string",
            "description": "Optional JSON string of input parameters to pass to all agents",
            "nullable": true
          },
          "parallelism": {
            "type": "integer",
            "description": "Parallelism level for each agent run (default: 1)",
            "format": "int32",
            "nullable": true
          },
          "isExclusive": {
            "type": "boolean",
            "description": "Whether to run exclusively"
          }
        },
        "additionalProperties": false,
        "description": "Request model for running all agents in a space"
      },
      "RunSpaceAgentsResultApiModel": {
        "type": "object",
        "properties": {
          "spaceId": {
            "type": "integer",
            "format": "int32"
          },
          "spaceName": {
            "type": "string",
            "nullable": true
          },
          "totalAgents": {
            "type": "integer",
            "format": "int32"
          },
          "agentsStarted": {
            "type": "integer",
            "format": "int32"
          },
          "agentsFailed": {
            "type": "integer",
            "format": "int32"
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AgentRunResultApiModel"
            },
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Result of running all agents in a space"
      },
      "RunStatsApiModel": {
        "type": "object",
        "properties": {
          "dataCount": {
            "type": "integer",
            "format": "int32"
          },
          "inputCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "errorCount": {
            "type": "integer",
            "format": "int32"
          },
          "pageCount": {
            "type": "integer",
            "format": "int32"
          },
          "exportCount": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "traffic": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Run statistics"
      },
      "RunStatus": {
        "enum": [
          0,
          1,
          2,
          3,
          4,
          5,
          6,
          7,
          8,
          9,
          10,
          11,
          12
        ],
        "type": "integer",
        "format": "int32"
      },
      "RunsSummaryApiModel": {
        "type": "object",
        "properties": {
          "startDate": {
            "type": "string",
            "description": "Start date of the range",
            "format": "date-time"
          },
          "endDate": {
            "type": "string",
            "description": "End date of the range",
            "format": "date-time"
          },
          "totalRuns": {
            "type": "integer",
            "description": "Total number of runs in the date range",
            "format": "int32"
          },
          "completedRuns": {
            "type": "integer",
            "description": "Number of completed runs",
            "format": "int32"
          },
          "failedRuns": {
            "type": "integer",
            "description": "Number of failed runs",
            "format": "int32"
          },
          "completedWithErrorsRuns": {
            "type": "integer",
            "description": "Number of runs completed with errors",
            "format": "int32"
          },
          "runningRuns": {
            "type": "integer",
            "description": "Number of currently running runs",
            "format": "int32"
          },
          "queuedRuns": {
            "type": "integer",
            "description": "Number of queued runs",
            "format": "int32"
          },
          "stoppedRuns": {
            "type": "integer",
            "description": "Number of stopped runs",
            "format": "int32"
          },
          "failedRunDetails": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FailedRunSummaryApiModel"
            },
            "description": "Details of failed runs (if requested)",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response model for runs summary"
      },
      "ScheduleType": {
        "enum": [
          0,
          1,
          2,
          3
        ],
        "type": "integer",
        "format": "int32"
      },
      "ServiceUnavailableError": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "integer",
            "format": "int32"
          },
          "statusDescription": {
            "type": "string",
            "nullable": true
          },
          "message": {
            "type": "string",
            "nullable": true,
            "readOnly": true
          },
          "severity": {
            "$ref": "#/components/schemas/ErrorSeverity"
          },
          "errorCode": {
            "type": "string",
            "description": "Optional machine-readable error code. When present, clients should switch on this\r\nvalue rather than parsing Sequentum.Enterprise.Core.ControllerError.Message. Omitted from the response when null.",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "SpaceAgentApiModel": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32"
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "configType": {
            "$ref": "#/components/schemas/ConfigType"
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "validationStatus": {
            "$ref": "#/components/schemas/ConfigValidationStatus"
          },
          "lastActivity": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Agent summary for space listing"
      },
      "SpaceApiModel": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32"
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "organizationId": {
            "type": "integer",
            "format": "int32"
          },
          "created": {
            "type": "string",
            "format": "date-time"
          },
          "updated": {
            "type": "string",
            "format": "date-time"
          },
          "isDefaultAccess": {
            "type": "boolean"
          }
        },
        "additionalProperties": false,
        "description": "Response model for a space in the External API"
      },
      "SpendingSummaryApiModel": {
        "type": "object",
        "properties": {
          "totalSpent": {
            "type": "number",
            "description": "Total amount spent in the date range",
            "format": "double"
          },
          "startDate": {
            "type": "string",
            "description": "Start date of the range",
            "format": "date-time"
          },
          "endDate": {
            "type": "string",
            "description": "End date of the range",
            "format": "date-time"
          },
          "organizationId": {
            "type": "integer",
            "description": "Organization ID",
            "format": "int32"
          },
          "currentBalance": {
            "type": "number",
            "description": "Current available credits balance",
            "format": "double"
          }
        },
        "additionalProperties": false,
        "description": "Response model for spending summary"
      },
      "StartAgentApiRequest": {
        "type": "object",
        "properties": {
          "parallelism": {
            "type": "integer",
            "format": "int32"
          },
          "parallelMaxConcurrency": {
            "type": "integer",
            "format": "int32"
          },
          "parallelExport": {
            "$ref": "#/components/schemas/ParallelExport"
          },
          "proxyPoolId": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "inputParameters": {
            "type": "string",
            "nullable": true
          },
          "timeout": {
            "type": "integer",
            "format": "int32"
          },
          "isExclusive": {
            "type": "boolean"
          },
          "isWaitOnFailure": {
            "type": "boolean"
          },
          "isRunSynchronously": {
            "type": "boolean"
          },
          "logLevel": {
            "$ref": "#/components/schemas/LogLevel"
          },
          "logMode": {
            "$ref": "#/components/schemas/LogMode"
          }
        },
        "additionalProperties": false
      },
      "StringContent": {
        "type": "object",
        "properties": {
          "content": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "TooManyRequestsError": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "integer",
            "format": "int32"
          },
          "statusDescription": {
            "type": "string",
            "nullable": true
          },
          "message": {
            "type": "string",
            "nullable": true,
            "readOnly": true
          },
          "severity": {
            "$ref": "#/components/schemas/ErrorSeverity"
          },
          "errorCode": {
            "type": "string",
            "description": "Optional machine-readable error code. When present, clients should switch on this\r\nvalue rather than parsing Sequentum.Enterprise.Core.ControllerError.Message. Omitted from the response when null.",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "UpcomingScheduleApiModel": {
        "type": "object",
        "properties": {
          "scheduleId": {
            "type": "integer",
            "format": "int64"
          },
          "agentId": {
            "type": "integer",
            "format": "int32"
          },
          "agentName": {
            "type": "string",
            "nullable": true
          },
          "scheduleName": {
            "type": "string",
            "nullable": true
          },
          "nextRunTime": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "timezone": {
            "type": "string",
            "nullable": true
          },
          "isEnabled": {
            "type": "boolean"
          }
        },
        "additionalProperties": false,
        "description": "Response model for upcoming scheduled runs"
      },
      "UpdateScheduleApiRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Name of the schedule (required)",
            "nullable": true
          },
          "cronExpression": {
            "type": "string",
            "description": "Cron expression for the schedule (e.g., \"0 9 * * 1,4\" for Mon/Thu at 9am)",
            "nullable": true
          },
          "localSchedule": {
            "type": "string",
            "description": "Local schedule expression (human readable)",
            "nullable": true
          },
          "timezone": {
            "type": "string",
            "description": "Timezone for the schedule (e.g., \"America/New_York\")",
            "nullable": true
          },
          "startTime": {
            "type": "string",
            "description": "Start date/time for the schedule in UTC.\r\n- Required for RunOnce schedules (must be at least 1 minute in the future).\r\n- Optional for RunEvery schedules (if provided, must be in the future; determines when the first run occurs).\r\n- Not used for CRON schedules.",
            "format": "date-time",
            "nullable": true,
            "example": "2026-01-20T14:30:00Z"
          },
          "inputParameters": {
            "type": "string",
            "description": "JSON string of input parameters for scheduled runs",
            "nullable": true
          },
          "scheduleType": {
            "$ref": "#/components/schemas/ScheduleType"
          },
          "isEnabled": {
            "type": "boolean",
            "description": "Whether the schedule is enabled"
          },
          "runEveryCount": {
            "type": "integer",
            "description": "Run every N periods (used with RunEveryPeriod)",
            "format": "int32",
            "nullable": true
          },
          "runEveryPeriod": {
            "type": "integer",
            "description": "Period unit for RunEveryCount (1=minutes, 2=hours, 3=days, 4=weeks, 5=months)",
            "format": "int32",
            "nullable": true
          },
          "parallelism": {
            "type": "integer",
            "description": "Parallelism level for the scheduled run",
            "format": "int32",
            "nullable": true
          },
          "parallelMaxConcurrency": {
            "type": "integer",
            "description": "Max concurrency for parallel runs",
            "format": "int32",
            "nullable": true
          },
          "parallelExport": {
            "$ref": "#/components/schemas/ParallelExport"
          },
          "proxyPoolId": {
            "type": "integer",
            "description": "Proxy pool ID to use for scheduled runs",
            "format": "int32",
            "nullable": true
          },
          "serverGroupId": {
            "type": "integer",
            "description": "Server group ID for scheduled runs (optional).\r\nWhen specified, the schedule will run on servers in this group.",
            "format": "int32",
            "nullable": true
          },
          "logLevel": {
            "$ref": "#/components/schemas/LogLevel"
          },
          "logMode": {
            "$ref": "#/components/schemas/LogMode"
          },
          "isExclusive": {
            "type": "boolean",
            "description": "Whether to run exclusively (no concurrent runs)"
          },
          "isWaitOnFailure": {
            "type": "boolean",
            "description": "Whether to wait on failure before retrying"
          }
        },
        "additionalProperties": false,
        "description": "Request model for updating an existing schedule"
      },
      "UsageTypeDataApiModel": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "description": "Usage type name (e.g., \"Server Time\", \"Export GB\", \"Agent Inputs\", \"Proxy Data\", \"Export CPM\")",
            "nullable": true
          },
          "data": {
            "type": "array",
            "items": {
              "type": "number",
              "format": "double"
            },
            "description": "Cost data points corresponding to the date labels",
            "nullable": true
          },
          "totalCost": {
            "type": "number",
            "description": "Total cost for this usage type",
            "format": "double"
          }
        },
        "additionalProperties": false,
        "description": "Usage data for a specific usage type (e.g., Server Time, Export GB)"
      }
    },
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "description": "API Key authorization header. Example: \"Authorization: ApiKey {your-api-key}\"",
        "name": "Authorization",
        "in": "header"
      },
      "Bearer": {
        "type": "http",
        "description": "OAuth 2.0 Bearer token. Example: \"Authorization: Bearer {access-token}\"",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    }
  },
  "security": [
    {
      "ApiKey": [ ],
      "Bearer": [ ]
    }
  ]
}