{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/skavio-eu/json-schema/skavio-eu-batch-schema.json",
  "title": "Batch",
  "x-generated": "2026-10-30",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/skavio-eu-processing-openapi.json#/components/schemas/Batch",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "operation": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "queued",
        "processing",
        "completed",
        "partial",
        "failed"
      ]
    },
    "estimated_credits": {
      "type": "integer"
    },
    "charged_credits": {
      "type": "integer"
    },
    "total_items": {
      "type": "integer"
    },
    "completed_items": {
      "type": "integer"
    },
    "failed_items": {
      "type": "integer"
    },
    "pending_items": {
      "type": "integer"
    },
    "progress": {
      "type": "number",
      "minimum": 0,
      "maximum": 1
    },
    "webhook_mode": {
      "type": "string",
      "enum": [
        "batch",
        "items",
        "both"
      ]
    },
    "retry_of": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "created_at": {
      "type": "string"
    },
    "updated_at": {
      "type": "string"
    },
    "items": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/BatchItem"
      }
    }
  },
  "required": [
    "id",
    "operation",
    "status",
    "estimated_credits",
    "charged_credits",
    "total_items",
    "completed_items",
    "failed_items",
    "pending_items",
    "progress",
    "webhook_mode",
    "created_at",
    "updated_at"
  ],
  "$defs": {
    "BatchItem": {
      "type": "object",
      "properties": {
        "index": {
          "type": "integer"
        },
        "upload_ids": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "job": {
          "$ref": "#/$defs/Job"
        }
      },
      "required": [
        "index",
        "upload_ids",
        "job"
      ]
    },
    "Job": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "operation": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "queued",
            "processing",
            "completed",
            "failed"
          ]
        },
        "stage": {
          "type": "string"
        },
        "estimated_credits": {
          "type": "integer"
        },
        "charged_credits": {
          "type": "integer"
        },
        "error": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "result": {
          "anyOf": [
            {
              "$ref": "#/$defs/JobResult"
            },
            {
              "type": "null"
            }
          ]
        },
        "created_at": {
          "type": "string"
        },
        "updated_at": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "operation",
        "status",
        "estimated_credits",
        "charged_credits",
        "result"
      ]
    },
    "JobResult": {
      "type": "object",
      "properties": {
        "files": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ResultFile"
          }
        },
        "documents": {
          "type": "integer"
        },
        "review_required_documents": {
          "type": "integer"
        },
        "estimated_time_saved_minutes": {
          "type": "integer"
        },
        "time_saved_basis": {
          "type": "string"
        }
      },
      "required": [
        "files"
      ]
    },
    "ResultFile": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "size_bytes": {
          "type": "integer"
        },
        "download_path": {
          "type": "string",
          "description": "Authenticated path relative to the API server."
        },
        "storage_object_id": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "name",
        "size_bytes",
        "download_path"
      ]
    }
  }
}