{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/elicit/json-schema/elicit-report-session-detail-schema.json",
  "title": "ReportSessionDetail",
  "x-generated": "2026-11-29",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/elicit-openapi.json#/components/schemas/ReportSessionDetail",
  "type": "object",
  "properties": {
    "type": {
      "type": "string",
      "const": "report"
    },
    "sessionId": {
      "type": "string",
      "format": "uuid",
      "description": "The session ID (UUID) returned by the create endpoints and `GET /sessions`"
    },
    "status": {
      "type": "string",
      "enum": [
        "processing",
        "pausedForInsufficientQuota",
        "completed",
        "failed",
        "unknown"
      ],
      "description": "Current status of the report. Transitions: processing ⇄ pausedForInsufficientQuota (paused when the account exceeds its usage limit; stays paused until explicitly resumed via the resume endpoint or the Elicit web interface), processing → completed/failed. Poll until completed or failed."
    },
    "executionStage": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "gathering_sources",
        "screening_abstract",
        "screening_fulltext",
        "extracting_data",
        "generating_report",
        "done",
        null
      ],
      "description": "Current pipeline stage. Advances through gathering_sources → screening_abstract → extracting_data → generating_report → done. Null for reports created before this field was introduced or when the stage isn't known."
    },
    "url": {
      "type": "string",
      "description": "URL to view the report in the Elicit web interface"
    },
    "isPublic": {
      "type": "boolean",
      "description": "Whether the report is publicly accessible via its URL without authentication"
    },
    "result": {
      "$ref": "#/$defs/ReportResult",
      "description": "Report output, only present when status is completed"
    },
    "error": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "description": "Machine-readable error code"
        },
        "message": {
          "type": "string",
          "description": "Human-readable error message"
        }
      },
      "required": [
        "code",
        "message"
      ],
      "description": "Error details, only present when status is failed"
    },
    "pdfUrl": {
      "type": [
        "string",
        "null"
      ],
      "description": "Pre-signed URL to download the report as PDF. Only present when status is completed and assets have been generated. Expires after 7 days — re-fetch the report for a fresh URL."
    },
    "docxUrl": {
      "type": [
        "string",
        "null"
      ],
      "description": "Pre-signed URL to download the report as DOCX. Only present when status is completed and assets have been generated. Expires after 7 days — re-fetch the report for a fresh URL."
    },
    "txtUrl": {
      "type": [
        "string",
        "null"
      ],
      "description": "Pre-signed URL to download the report's reference list as a plain-text (APA) file. Only present when status is completed and the report has a non-empty bibliography. Expires after 7 days — re-fetch the report for a fresh URL."
    },
    "bibUrl": {
      "type": [
        "string",
        "null"
      ],
      "description": "Pre-signed URL to download the report's references as a BibTeX (.bib) file. Only present when status is completed and the report has a non-empty bibliography. Expires after 7 days — re-fetch the report for a fresh URL."
    },
    "risUrl": {
      "type": [
        "string",
        "null"
      ],
      "description": "Pre-signed URL to download the report's references as an RIS (.ris) file. Only present when status is completed and the report has a non-empty bibliography. Expires after 7 days — re-fetch the report for a fresh URL."
    },
    "exportsStatus": {
      "type": "string",
      "enum": [
        "ready",
        "generating",
        "unavailable"
      ],
      "description": "Availability of cached reference-list exports (`txtUrl`/`bibUrl`/`risUrl`); `pdfUrl`/`docxUrl` are unaffected. Only present when status is completed. `ready`: a cached manifest was served, which can be stale; missing URLs do not prove a format has no export. Repoll after at least 60 seconds for expected missing URLs, using bounded retries with backoff. `generating`: exports are being generated and no cached downloads can be served. `unavailable`: export generation or retrieval failed and no cached downloads can be served."
    },
    "links": {
      "$ref": "#/$defs/SessionLinks"
    }
  },
  "required": [
    "type",
    "sessionId",
    "status",
    "executionStage",
    "url",
    "isPublic",
    "links"
  ],
  "$defs": {
    "ReportResult": {
      "type": "object",
      "properties": {
        "title": {
          "type": "string",
          "description": "Auto-generated title for the report"
        },
        "summary": {
          "type": "string",
          "description": "AI-generated executive summary of the findings"
        },
        "reportBody": {
          "type": [
            "string",
            "null"
          ],
          "description": "Full report content in markdown format. Only included when ?include=reportBody is specified."
        },
        "abstract": {
          "type": [
            "string",
            "null"
          ],
          "description": "Report abstract in markdown format. Only included when ?include=reportBody is specified."
        }
      },
      "required": [
        "title",
        "summary"
      ]
    },
    "SessionLinks": {
      "type": "object",
      "properties": {
        "self": {
          "type": "string",
          "description": "API URL for this session's full status and results (the typed get endpoint for its type)"
        },
        "resume": {
          "type": "string",
          "description": "API URL to resume this session. Present only while the session is paused for insufficient quota. Only the owner can use it; a shared recipient receives 404 even when this link is present."
        }
      },
      "required": [
        "self"
      ]
    }
  }
}