{
  "openapi": "3.1.0",
  "info": {
    "title": "Impartis Developer API",
    "version": "1.0.0",
    "description": "Read-only access to Workspace-visible, governed Impartis research and communication artifacts. Organization API keys never expose Personal or Restricted Team records."
  },
  "servers": [
    { "url": "https://impartis.app/functions/api-v1" }
  ],
  "security": [
    { "bearerApiKey": [] }
  ],
  "components": {
    "securitySchemes": {
      "bearerApiKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "Impartis API key"
      }
    },
    "schemas": {
      "Meta": {
        "type": "object",
        "properties": {
          "count": { "type": "integer" },
          "total": { "type": "integer" },
          "limit": { "type": "integer" },
          "offset": { "type": "integer" },
          "next_offset": { "type": ["integer", "null"] },
          "request_id": { "type": "string" },
          "governance": { "type": "string" }
        }
      },
      "Research": {
        "type": "object",
        "properties": {
          "id": { "type": "string" },
          "title": { "type": "string" },
          "authors": { "type": "array", "items": { "type": "string" } },
          "institution": { "type": "string" },
          "publication": { "type": "string" },
          "publication_date": { "type": ["string", "null"] },
          "doi": { "type": "string" },
          "source_type": { "type": "string" },
          "discipline": { "type": "string" },
          "executive_summary": { "type": "string" },
          "primary_research_question": { "type": "string" },
          "why_it_matters": { "type": "string" },
          "topics": { "type": "array", "items": { "type": "string" } },
          "impact_areas": { "type": "array", "items": { "type": "string" } },
          "stakeholder_groups": { "type": "array", "items": { "type": "string" } },
          "communication_tags": { "type": "array", "items": { "type": "string" } },
          "geographic_scope": { "type": "string" },
          "timeframe": { "type": "string" },
          "human_verified": { "type": "boolean", "const": true },
          "verification_date": { "type": ["string", "null"] },
          "truth_model_version": { "type": ["integer", "null"] },
          "extraction_version": { "type": "string" }
        }
      },
      "Claim": {
        "type": "object",
        "properties": {
          "id": { "type": "string" },
          "research_source_id": { "type": "string" },
          "claim_text": { "type": "string" },
          "claim_type": { "type": "string" },
          "causal_status": { "type": "string" },
          "confidence": { "type": "string" },
          "caveat": { "type": "string" },
          "required_qualification": { "type": "string" },
          "supported_population": { "type": "string" },
          "supported_geography": { "type": "string" },
          "supported_timeframe": { "type": "string" },
          "generalization_boundary": { "type": "string" },
          "permitted_language": { "type": "array", "items": { "type": "string" } },
          "prohibited_overstatement": { "type": "string" },
          "source_page": { "type": ["integer", "null"] },
          "source_section": { "type": "string" },
          "topics": { "type": "array", "items": { "type": "string" } },
          "use_cases": { "type": "array", "items": { "type": "string" } },
          "materiality": { "type": "string" },
          "verification_status": { "type": "string" },
          "human_verified": { "type": "boolean", "const": true }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": { "type": "string" },
              "message": { "type": "string" }
            }
          },
          "meta": {
            "type": "object",
            "properties": { "request_id": { "type": "string" } }
          }
        }
      }
    }
  },
  "paths": {
    "/": {
      "get": {
        "summary": "Read governed Impartis data",
        "description": "Select a resource with the resource query parameter. The endpoint is read-only.",
        "parameters": [
          {
            "name": "resource",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["status", "research", "claims", "reports", "outputs"],
              "default": "status"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": { "type": "string" },
            "description": "Case-insensitive search across the selected resource."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": { "type": "integer", "minimum": 1, "maximum": 100, "default": 25 }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": { "type": "integer", "minimum": 0, "default": 0 }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "401": {
            "description": "Missing, invalid, revoked, or expired API key",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
          },
          "403": {
            "description": "Insufficient scope or workspace unavailable",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
          }
        }
      }
    }
  }
}
