{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/zvid-io/json-schema/zvid-io-render-job-status-schema.json",
  "title": "RenderJobStatus",
  "x-generated": "2026-10-31",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/zvid-io-openapi.yaml#/components/schemas/RenderJobStatus",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "id": {
      "type": "string",
      "description": "Job identifier"
    },
    "state": {
      "type": [
        "string",
        "null"
      ],
      "description": "Queue states include waiting, prioritized, active, delayed, completed and failed. Treat completed/failed as terminal; keep polling other states with bounded backoff."
    },
    "progress": {
      "oneOf": [
        {
          "type": "number",
          "minimum": 0,
          "maximum": 100
        },
        {
          "type": "object",
          "properties": {
            "phase": {
              "type": "string"
            },
            "percentage": {
              "type": "number"
            },
            "message": {
              "type": "string"
            }
          },
          "additionalProperties": true
        }
      ],
      "description": "A percentage or phase object. The structured progress field is percentage, not percent."
    },
    "result": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "object",
          "properties": {
            "url": {
              "type": "string"
            },
            "thumbnailUrl": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "type": {
              "enum": [
                "video",
                "image"
              ]
            },
            "duration": {
              "anyOf": [
                {
                  "type": "number"
                },
                {
                  "type": "null"
                }
              ]
            },
            "size": {
              "anyOf": [
                {
                  "type": "number"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "additionalProperties": true
        },
        {
          "type": "null"
        }
      ],
      "description": "Usually an object with url while queue data is available. Persisted history can return the output URL string. Handle both shapes. Null after output expiry; completed history remains available."
    },
    "failedReason": {
      "type": [
        "string",
        "null"
      ],
      "description": "Failure reason if the job failed"
    },
    "ts": {
      "$ref": "#/$defs/RenderJobTimestamps"
    },
    "outputExpiresAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "Availability deadline based on the plan recorded for this render, starting at completion. URLs are withheld after this time."
    },
    "outputExpiredAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "When expiration cleanup was recorded. Check outputExpiresAt even while cleanup is pending."
    },
    "outputCleanupStatus": {
      "type": [
        "string",
        "null"
      ],
      "description": "Output cleanup progress; failed storage deletion or cache purges are retried."
    }
  },
  "required": [
    "id",
    "state",
    "progress",
    "ts"
  ],
  "$defs": {
    "RenderJobTimestamps": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "created": {
          "oneOf": [
            {
              "type": "integer",
              "description": "Unix milliseconds while job data is in the queue."
            },
            {
              "type": "string",
              "format": "date-time",
              "description": "ISO date-time when served from persisted job history."
            },
            {
              "type": "null"
            }
          ]
        },
        "updated": {
          "oneOf": [
            {
              "type": "integer",
              "description": "Unix milliseconds while job data is in the queue."
            },
            {
              "type": "string",
              "format": "date-time",
              "description": "ISO date-time when served from persisted job history."
            },
            {
              "type": "null"
            }
          ]
        },
        "finished": {
          "oneOf": [
            {
              "type": "integer",
              "description": "Unix milliseconds while job data is in the queue."
            },
            {
              "type": "string",
              "format": "date-time",
              "description": "ISO date-time when served from persisted job history."
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "created",
        "updated",
        "finished"
      ]
    }
  }
}