{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/scale-ai/json-schema/scale-ai-job-entity-schema.json",
  "title": "JobEntity",
  "description": "Job response model representing an asynchronous operation.",
  "x-generated": "2026-10-27",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/scale-ai-document-understanding-openapi.yml#/components/schemas/JobEntity",
  "properties": {
    "id": {
      "type": "string",
      "title": "Id",
      "description": "ID of the entity"
    },
    "project_id": {
      "type": "string",
      "title": "Project Id",
      "description": "ID of the project"
    },
    "object": {
      "type": "string",
      "const": "job",
      "title": "Object",
      "default": "job"
    },
    "operation": {
      "$ref": "#/$defs/JobOperationType",
      "description": "Operation type (e.g., 'parse')"
    },
    "status": {
      "$ref": "#/$defs/JobStatus",
      "description": "Current job status"
    },
    "source_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Source Id",
      "description": "Source document/file ID"
    },
    "correlation_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Correlation Id",
      "description": "Request correlation ID for tracing"
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "title": "Created At",
      "description": "When the job was created"
    },
    "started_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Started At",
      "description": "When the job started processing"
    },
    "completed_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Completed At",
      "description": "When the job completed"
    },
    "result": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Result",
      "description": "Job result payload when completed"
    },
    "progress": {
      "anyOf": [
        {
          "$ref": "#/$defs/BatchParseProgress"
        },
        {
          "type": "null"
        }
      ],
      "description": "Live progress payload (used by batch jobs)"
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Error",
      "description": "Error message if job failed"
    },
    "history": {
      "anyOf": [
        {
          "items": {
            "$ref": "#/$defs/JobHistoryEvent"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "History",
      "description": "Timeline of job execution events"
    }
  },
  "type": "object",
  "required": [
    "id",
    "project_id",
    "operation",
    "status",
    "created_at"
  ],
  "$defs": {
    "BatchChildJobInfo": {
      "properties": {
        "source_document_id": {
          "type": "string",
          "title": "Source Document Id",
          "description": "Source document ID"
        },
        "job_id": {
          "type": "string",
          "title": "Job Id",
          "description": "Child job ID"
        },
        "status": {
          "$ref": "#/$defs/JobStatus",
          "description": "Status of the child job"
        },
        "parse_result_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Parse Result Id",
          "description": "Parse result ID if succeeded"
        },
        "error": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Error",
          "description": "Error message if failed"
        }
      },
      "type": "object",
      "required": [
        "source_document_id",
        "job_id",
        "status"
      ],
      "title": "BatchChildJobInfo",
      "description": "Status of a single child job within a batch."
    },
    "BatchParseProgress": {
      "properties": {
        "total": {
          "type": "integer",
          "title": "Total",
          "description": "Total number of files in the batch"
        },
        "succeeded": {
          "type": "integer",
          "title": "Succeeded",
          "description": "Number of successfully parsed files"
        },
        "failed": {
          "type": "integer",
          "title": "Failed",
          "description": "Number of files that failed to parse"
        },
        "cancelled": {
          "type": "integer",
          "title": "Cancelled",
          "description": "Number of cancelled child jobs"
        },
        "pending": {
          "type": "integer",
          "title": "Pending",
          "description": "Number of files still pending (0 when job is terminal)"
        },
        "child_jobs": {
          "items": {
            "$ref": "#/$defs/BatchChildJobInfo"
          },
          "type": "array",
          "title": "Child Jobs",
          "description": "Per-child job status"
        }
      },
      "type": "object",
      "required": [
        "total",
        "succeeded",
        "failed",
        "cancelled",
        "pending",
        "child_jobs"
      ],
      "title": "BatchParseProgress",
      "description": "Live progress tracking for a batch parse job."
    },
    "JobHistoryEvent": {
      "properties": {
        "step": {
          "type": "string",
          "title": "Step",
          "description": "Human-readable step name"
        },
        "timestamp": {
          "type": "string",
          "format": "date-time",
          "title": "Timestamp",
          "description": "When this event occurred"
        },
        "duration_ms": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Duration Ms",
          "description": "Duration in milliseconds (for completed steps)"
        },
        "status": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Status",
          "description": "Event status (e.g., 'completed', 'failed')"
        },
        "details": {
          "anyOf": [
            {
              "additionalProperties": true,
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "title": "Details",
          "description": "Additional event details"
        }
      },
      "type": "object",
      "required": [
        "step",
        "timestamp"
      ],
      "title": "JobHistoryEvent",
      "description": "A single event in the job execution timeline."
    },
    "JobOperationType": {
      "type": "string",
      "enum": [
        "parse",
        "batch_parse",
        "extract",
        "research",
        "vector_store",
        "chunk",
        "summarization",
        "create_index",
        "update_index"
      ],
      "title": "JobOperationType",
      "description": "Enum for job operation values."
    },
    "JobStatus": {
      "type": "string",
      "enum": [
        "pending",
        "running",
        "succeeded",
        "partially_succeeded",
        "failed",
        "cancelled"
      ],
      "title": "JobStatus",
      "description": "Enum for job status values."
    }
  }
}