{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/editclips-online/json-schema/editclips-online-job-schema.json",
  "title": "Job",
  "x-generated": "2026-11-06",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/editclips-online-openapi.yaml#/components/schemas/Job",
  "type": "object",
  "required": [
    "id",
    "status",
    "tool",
    "progress",
    "creditsReserved",
    "createdAt"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "status": {
      "type": "string",
      "enum": [
        "pending_upload",
        "queued",
        "processing",
        "completed",
        "failed",
        "cancelled"
      ]
    },
    "tool": {
      "type": "string"
    },
    "progress": {
      "type": "integer",
      "minimum": 0,
      "maximum": 100,
      "description": "Processing progress percentage"
    },
    "progressMessage": {
      "type": [
        "string",
        "null"
      ],
      "description": "Human-readable progress update (e.g. \"Encoding...\")"
    },
    "errorMessage": {
      "type": [
        "string",
        "null"
      ],
      "description": "Error description (only when status is `failed`)"
    },
    "creditsReserved": {
      "type": "integer",
      "description": "Always 0 — nothing is held when a job is created"
    },
    "creditsCharged": {
      "type": [
        "integer",
        "null"
      ],
      "description": "AI credits charged for the result (0 for non-AI tools)"
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "completedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "outputUrl": {
      "type": [
        "string",
        "null"
      ],
      "format": "uri",
      "description": "Presigned R2 download URL (completed and unlocked jobs, valid 1 hour); null while a completed result is locked"
    },
    "outputFilename": {
      "type": [
        "string",
        "null"
      ],
      "description": "Suggested filename for the output"
    },
    "outputSize": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Output file size in bytes"
    },
    "metrics": {
      "allOf": [
        {
          "$ref": "#/$defs/Metrics"
        }
      ],
      "nullable": true,
      "description": "Processing metrics (only after completion, may be null)"
    }
  },
  "$defs": {
    "Metrics": {
      "type": "object",
      "properties": {
        "wallTimeMs": {
          "type": "integer",
          "description": "Total wall-clock execution time in milliseconds"
        },
        "cpuTimeMs": {
          "type": "integer",
          "description": "CPU time in milliseconds"
        },
        "peakMemoryBytes": {
          "type": "integer",
          "description": "Peak memory usage in bytes"
        },
        "estimatedCostMicroUsd": {
          "type": "integer",
          "description": "Estimated container cost in micro-USD"
        }
      }
    }
  }
}