{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/preuve-ai/json-schema/preuve-ai-analysis-export-schema.json",
  "title": "AnalysisExport",
  "description": "ideas-json export, schemaVersion 2. Deep-only fields are null on free runs. See the Scans and Enrichment guide for the field-by-field contract.\n",
  "x-generated": "2026-11-21",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/preuve-ai-openapi.json#/components/schemas/AnalysisExport",
  "type": "object",
  "properties": {
    "schemaVersion": {
      "type": "integer",
      "const": 2
    },
    "exportType": {
      "type": "string",
      "enum": [
        "analysis"
      ]
    },
    "exportedAt": {
      "type": "string",
      "format": "date-time"
    },
    "analysis": {
      "$ref": "#/$defs/AnalysisRun"
    },
    "verbosity": {
      "type": "string",
      "enum": [
        "full",
        "summary"
      ],
      "description": "The verbosity this payload was built at, echoed back. On \"summary\", idea.details.omitted names what was dropped.\n"
    },
    "locked": {
      "$ref": "#/$defs/ExportLocks"
    },
    "upsell": {
      "$ref": "#/$defs/ExportUpsell"
    },
    "idea": {
      "type": "object",
      "properties": {
        "rank": {
          "type": "integer"
        },
        "verdict": {
          "type": "string"
        },
        "score": {
          "type": "number"
        },
        "title": {
          "type": "string"
        },
        "risk": {
          "type": "string"
        },
        "quote": {
          "type": "string"
        },
        "evidence": {
          "type": "string"
        },
        "domains": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "reportId": {
          "type": "string"
        },
        "reportUrl": {
          "type": "string"
        },
        "shareUrl": {
          "type": [
            "string",
            "null"
          ]
        },
        "details": {
          "type": "object",
          "description": "Summary contract on every tier (including situationBriefing and scores); sections/pivots/communityDemand/founderFit/playbook/proofOfDemand/googleTrends on deep runs. `details.cloneability` is present on every tier but changes shape rather than going null - three fields on starter runs, the full analysis on deep runs. See the Scans and Enrichment guide.\n"
        }
      }
    }
  },
  "$defs": {
    "AnalysisRun": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "reportId": {
          "type": [
            "string",
            "null"
          ],
          "format": "uuid",
          "description": "Null until the report row is attached, which is why a run that failed before dispatch is retryable under the same clientRunId.\n"
        },
        "clientRunId": {
          "type": [
            "string",
            "null"
          ],
          "description": "The caller-chosen id from create. Null when the analysis is a dashboard-created report resolved by its report id: no run row exists, so there is no clientRunId to replay.\n"
        },
        "batchId": {
          "type": [
            "string",
            "null"
          ],
          "format": "uuid",
          "description": "The batch this run belongs to, or null for a standalone run."
        },
        "scanType": {
          "type": "string",
          "enum": [
            "starter",
            "deep"
          ],
          "description": "Your request type. Reliable from creation, even while PROCESSING."
        },
        "enrichmentMode": {
          "type": "string",
          "enum": [
            "core",
            "none"
          ]
        },
        "publish": {
          "type": "boolean"
        },
        "reportType": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "quick",
            "deep_dive",
            null
          ]
        },
        "analysisTier": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "basic",
            "advanced",
            null
          ],
          "description": "Derived from the report. Deep runs read \"basic\" until deep sections land."
        },
        "status": {
          "type": "string",
          "enum": [
            "PENDING",
            "PROCESSING",
            "COMPLETED",
            "FAILED"
          ]
        },
        "progressStep": {
          "type": [
            "string",
            "null"
          ],
          "description": "Free-text pipeline stage while PROCESSING."
        },
        "errorCode": {
          "type": [
            "string",
            "null"
          ],
          "description": "Set on a FAILED run. Two internal markers are deliberately rewritten before they leave: an ambiguous dispatch reports TRIGGER_DISPATCH_FAILED and an ambiguous claim refund reports REPORT_CREATE_FAILED.\n"
        },
        "errorMessage": {
          "type": [
            "string",
            "null"
          ]
        },
        "resetAt": {
          "type": "string",
          "format": "date-time",
          "description": "Present only on a batch item refused by the rolling daily cap; absent, not null, on every other run.\n"
        },
        "pollAfterSeconds": {
          "type": "integer",
          "description": "Present only while polling is still useful. Pace by this rather than by a fixed interval.\n"
        },
        "pollHint": {
          "type": "string",
          "description": "Present alongside pollAfterSeconds."
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "readyForExport": {
          "type": "boolean",
          "description": "Whether GET /export will serve this analysis now. Always false for a report created on the preuve.ai dashboard, whatever state the report is in, because that export answers 403 REPORT_NOT_FROM_AGENT_RUN. Branch on exportable first.\n"
        },
        "exportable": {
          "type": "boolean",
          "description": "Present, and false, only on a report created on the preuve.ai dashboard. Absent means the ordinary contract applies and readyForExport is the gate. When it is false, no amount of polling or enriching changes it.\n"
        },
        "exportBlockedCode": {
          "type": "string",
          "enum": [
            "REPORT_NOT_FROM_AGENT_RUN"
          ],
          "description": "Present alongside exportable, naming the refusal."
        },
        "exportBlockedHint": {
          "type": "string",
          "description": "Present alongside exportable. Relayable prose."
        },
        "enrichment": {
          "$ref": "#/$defs/EnrichmentState"
        },
        "modules": {
          "type": [
            "object",
            "null"
          ],
          "description": "Per-module statuses. Deep reports only; null on free runs.",
          "properties": {
            "proofOfDemand": {
              "$ref": "#/$defs/ModuleStatus"
            },
            "founderFit": {
              "$ref": "#/$defs/ModuleStatus"
            },
            "playbook": {
              "$ref": "#/$defs/ModuleStatus"
            },
            "trends": {
              "$ref": "#/$defs/ModuleStatus"
            },
            "community": {
              "$ref": "#/$defs/ModuleStatus"
            }
          }
        },
        "reportUrl": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri",
          "description": "Null until the report row exists."
        },
        "shareUrl": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri"
        }
      }
    },
    "EnrichmentState": {
      "type": "object",
      "description": "Progress of the core export sections. The four name arrays partition `required`, so a poller decides what to do next by reading them rather than by parsing `status`: anything in processing means keep polling, anything in failed means call enrich again, and missing with nothing processing means enrichment was never started for it.\n",
      "properties": {
        "mode": {
          "type": "string",
          "enum": [
            "core",
            "none"
          ]
        },
        "status": {
          "type": "string",
          "enum": [
            "not_required",
            "pending",
            "processing",
            "partial",
            "completed",
            "failed"
          ],
          "description": "Rolled up from the arrays below. \"partial\" means some sections landed and others did not; \"not_required\" is mode \"none\", or a report with no required sections.\n"
        },
        "required": {
          "type": "array",
          "description": "Every section this report and mode need. The other four arrays partition it.",
          "items": {
            "type": "string"
          }
        },
        "completed": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "missing": {
          "type": "array",
          "description": "Required, not generated, and not currently being generated.",
          "items": {
            "type": "string"
          }
        },
        "processing": {
          "type": "array",
          "description": "Generation is in flight. Keep polling rather than calling enrich again.",
          "items": {
            "type": "string"
          }
        },
        "failed": {
          "type": "array",
          "description": "Generation was attempted and failed. Retryable by calling enrich again.",
          "items": {
            "type": "string"
          }
        },
        "sections": {
          "type": "object",
          "description": "Per-section detail, keyed by section name, for every entry in required. Each value carries at least a status matching the array the section is in, plus completedAt on a completed section and whatever the last attempt recorded on a failed one.\n",
          "additionalProperties": {
            "type": "object",
            "properties": {
              "status": {
                "type": "string",
                "enum": [
                  "missing",
                  "processing",
                  "completed",
                  "failed",
                  "pending"
                ]
              },
              "completedAt": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            },
            "additionalProperties": true
          }
        }
      }
    },
    "ExportLocks": {
      "type": "object",
      "description": "Which fields this export left null, and why. Present only when the caller's tier withheld something, and absent entirely when the payload is complete. Read it before concluding a field is absent: a null under one of these paths is locked, not missing and not a failed analysis. It ships to every tier, paid included, and carries no price and no URL. On a batch export there is ONE object for the whole batch, the union of every exported item's withheld fields, deduplicated by path.\n",
      "properties": {
        "reason": {
          "type": "string",
          "description": "Why the fields were withheld. \"starter_scan\" today."
        },
        "unlockedBy": {
          "type": "string",
          "description": "What lifts the lock. \"founder_report\" today."
        },
        "fields": {
          "type": "array",
          "description": "One entry per withheld field.",
          "items": {
            "type": "object",
            "properties": {
              "path": {
                "type": "string",
                "description": "Dotted path into the export, e.g. \"details.pivots\". A path may name several keys of one object with a pipe, e.g. \"details.risks[].explanation|mitigation\".\n"
              },
              "label": {
                "type": "string",
                "description": "What that path holds, in plain language. Some labels also say the field needs an enrich call once the report is deep.\n"
              }
            }
          }
        },
        "note": {
          "type": "string",
          "description": "One sentence restating that the nulls are a tier boundary rather than missing data.\n"
        }
      }
    },
    "ExportUpsell": {
      "type": "object",
      "description": "Purchase context for a locked export or buyable quota refusal. Export upsells are free-owner only; a paid non-regional caller may receive a scan_pack top-up on INSUFFICIENT_TOKENS. Ignore it if you only need the data contract.\n",
      "properties": {
        "offer": {
          "type": "string",
          "enum": [
            "founder_report",
            "scan_pack"
          ],
          "description": "\"founder_report\" is the one-time Founder Report tier. \"scan_pack\" is a top-up for an account that already bought and has no deep credits left.\n"
        },
        "guarantee": {
          "type": "string",
          "description": "Guarantee text for offer=founder_report. Omitted for scan_pack top-ups; an empty string is never used.\n"
        },
        "url": {
          "type": "string",
          "format": "uri",
          "description": "Purchase or report URL, with attribution query parameters."
        },
        "locked": {
          "type": "array",
          "description": "Section names the offer covers. Distinct from the top-level locked object, which names response FIELDS.\n",
          "items": {
            "type": "string"
          }
        },
        "note": {
          "type": "string",
          "description": "The same facts as one sentence, for a client that relays text."
        }
      }
    },
    "ModuleStatus": {
      "type": "object",
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "not_generated",
            "generating",
            "failed",
            "completed"
          ]
        }
      }
    }
  }
}