{
  "openapi": "3.0.3",
  "info": {
    "title": "Zagger Headless API",
    "version": "1",
    "description": "External servers call a Zagger instance. Customer data requires a Headless bearer access token. This document contains no credentials. Do not send this token to Supabase /rest/v1. Use /casc/v1/headless/v1/rest."
  },
  "servers": [
    {
      "url": "/casc/v1/headless/v1"
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Headless access token from POST /token. Not a Supabase service-role key and not the app session JWT."
      }
    }
  },
  "paths": {
    "/token": {
      "post": {
        "summary": "Exchange client_id, client_secret, and sub_user for a bearer access token.",
        "security": [],
        "responses": {
          "200": {
            "description": "Token response. Store the secret only on the calling server."
          },
          "401": {
            "description": "Invalid integration credentials."
          }
        }
      }
    },
    "/token/refresh": {
      "post": {
        "summary": "Rotate a refresh token.",
        "security": [],
        "responses": {
          "200": {
            "description": "New access token."
          },
          "401": {
            "description": "Invalid refresh token."
          }
        }
      }
    },
    "/chat/send": {
      "post": {
        "summary": "Send a chat message on the token project.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success. Body is tenant data and is never served without a valid bearer token."
          },
          "401": {
            "description": "Missing or invalid Authorization: Bearer token."
          },
          "403": {
            "description": "Token is missing a required scope (chat)."
          }
        }
      }
    },
    "/chat/requests/{requestId}/wait": {
      "get": {
        "summary": "Wait for a chat result.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success. Body is tenant data and is never served without a valid bearer token."
          },
          "401": {
            "description": "Missing or invalid Authorization: Bearer token."
          },
          "403": {
            "description": "Token is missing a required scope (chat)."
          }
        }
      }
    },
    "/chat/requests/{requestId}/result": {
      "get": {
        "summary": "Read a finished chat result.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success. Body is tenant data and is never served without a valid bearer token."
          },
          "401": {
            "description": "Missing or invalid Authorization: Bearer token."
          },
          "403": {
            "description": "Token is missing a required scope (chat)."
          }
        }
      }
    },
    "/research/jobs/{jobId}": {
      "get": {
        "summary": "Read one research job owned by the integration user.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success. Body is tenant data and is never served without a valid bearer token."
          },
          "401": {
            "description": "Missing or invalid Authorization: Bearer token."
          },
          "403": {
            "description": "Token is missing a required scope (chat)."
          }
        }
      }
    },
    "/research/jobs/{jobId}/report": {
      "get": {
        "summary": "Read a research report.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success. Body is tenant data and is never served without a valid bearer token."
          },
          "401": {
            "description": "Missing or invalid Authorization: Bearer token."
          },
          "403": {
            "description": "Token is missing a required scope (chat)."
          }
        }
      }
    },
    "/ingest/planes": {
      "get": {
        "summary": "List ingestion planes for the bound project.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success. Body is tenant data and is never served without a valid bearer token."
          },
          "401": {
            "description": "Missing or invalid Authorization: Bearer token."
          },
          "403": {
            "description": "Token is missing a required scope (ingest)."
          }
        }
      }
    },
    "/rest": {
      "get": {
        "summary": "List PostgREST resources on the bound horizon. Not Supabase /rest/v1.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success. Body is tenant data and is never served without a valid bearer token."
          },
          "401": {
            "description": "Missing or invalid Authorization: Bearer token."
          },
          "403": {
            "description": "Token is missing a required scope (data:read)."
          }
        }
      }
    },
    "/rest/{resource}": {
      "get": {
        "summary": "Read horizon rows for one resource.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success. Body is tenant data and is never served without a valid bearer token."
          },
          "401": {
            "description": "Missing or invalid Authorization: Bearer token."
          },
          "403": {
            "description": "Token is missing a required scope (data:read)."
          }
        }
      }
    }
  }
}
