{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/deepswapai-com/json-schema/deepswapai-com-task-schema.json",
  "title": "Task",
  "x-generated": "2026-12-02",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/deepswapai-com-openapi.json#/components/schemas/Task",
  "type": "object",
  "required": [
    "id",
    "taskType",
    "status",
    "costCredits",
    "createdAt"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "taskType": {
      "type": "string",
      "enum": [
        "IMAGE_SWAP",
        "BATCH_FACE_SWAP",
        "MULTI_FACE_SWAP",
        "VIDEO_SWAP",
        "GIF_FACE_SWAP"
      ]
    },
    "status": {
      "$ref": "#/$defs/TaskStatus"
    },
    "costCredits": {
      "type": "integer",
      "minimum": 0
    },
    "parameters": {
      "type": "object",
      "additionalProperties": true
    },
    "result": {
      "anyOf": [
        {
          "$ref": "#/$defs/TaskResult"
        },
        {
          "type": "null"
        }
      ],
      "description": "Terminal result when available; null while no result has been recorded."
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "startedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "completedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    }
  },
  "$defs": {
    "TaskResult": {
      "type": "object",
      "description": "Terminal task output. Fields vary by workflow; the documented URL fields below cover single-output and batch delivery.",
      "properties": {
        "url": {
          "type": "string",
          "format": "uri",
          "description": "Single-output result URL when the workflow returns one primary asset."
        },
        "urls": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "uri"
          },
          "description": "Batch output URLs in deterministic request order. Present on completed batch photo tasks, including single-output batches."
        },
        "zipUrl": {
          "anyOf": [
            {
              "type": "string",
              "format": "uri"
            },
            {
              "type": "null"
            }
          ],
          "description": "Batch ZIP download URL when more than one output was produced; null for a completed single-output batch."
        }
      },
      "additionalProperties": true
    },
    "TaskStatus": {
      "type": "string",
      "enum": [
        "PENDING",
        "PROCESSING",
        "COMPLETED",
        "FAILED",
        "CANCELLED"
      ]
    }
  }
}