{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/osintverse-com/json-schema/osintverse-com-search-response-schema.json",
  "title": "SearchResponse",
  "description": "Search job status and results.",
  "x-generated": "2026-11-20",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/osintverse-com-api-openapi.json#/components/schemas/SearchResponse",
  "properties": {
    "id": {
      "type": "string",
      "title": "Id",
      "description": "Unique search job UUID."
    },
    "status": {
      "type": "string",
      "enum": [
        "pending",
        "running",
        "completed",
        "failed",
        "refunded"
      ],
      "title": "Status",
      "description": "Job status. Poll while `running`. `failed` = insufficient balance. `refunded` = charged then upstream failed."
    },
    "provider": {
      "type": "string",
      "title": "Provider",
      "description": "Provider that processed this search."
    },
    "input_type": {
      "type": "string",
      "title": "Input Type",
      "description": "Input type used for the query."
    },
    "query": {
      "type": "string",
      "title": "Query",
      "description": "Normalized query string."
    },
    "cost_usd": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Cost Usd",
      "description": "USD charged for this search."
    },
    "balance_after": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Balance After",
      "description": "Account balance after billing action."
    },
    "result": {
      "anyOf": [
        {
          "$ref": "#/$defs/ProviderResultPayload"
        },
        {
          "type": "null"
        }
      ],
      "description": "Results when status is completed."
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Error",
      "description": "Error message when status is failed or refunded."
    },
    "poll_url": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Poll Url",
      "description": "Relative URL to poll when status is running."
    },
    "has_stored_result": {
      "type": "boolean",
      "title": "Has Stored Result",
      "description": "True when this search has a stored result that can be reopened or shared.",
      "default": false
    },
    "result_expires_at": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Result Expires At",
      "description": "When stored results expire. Null means lifetime or nothing stored."
    },
    "batch_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Batch Id",
      "description": "Session UUID shared by every job from the same submit (one query × N providers)."
    }
  },
  "type": "object",
  "required": [
    "id",
    "status",
    "provider",
    "input_type",
    "query"
  ],
  "$defs": {
    "ProviderResultPayload": {
      "properties": {
        "sources": {
          "items": {
            "additionalProperties": true,
            "type": "object"
          },
          "type": "array",
          "title": "Sources",
          "description": "High-level source metadata from the provider response."
        },
        "matches": {
          "items": {
            "additionalProperties": true,
            "type": "object"
          },
          "type": "array",
          "title": "Matches",
          "description": "Individual match records to display or process."
        },
        "raw": {
          "anyOf": [
            {
              "additionalProperties": true,
              "type": "object"
            },
            {
              "items": {},
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Raw",
          "description": "Unmodified upstream provider payload."
        }
      },
      "type": "object",
      "title": "ProviderResultPayload",
      "description": "Normalized search results from the upstream OSINT provider."
    }
  }
}