{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/nanostudiopro-com/json-schema/nanostudiopro-com-task-schema.json",
  "title": "Task",
  "description": "Lifecycle row for an async operation (generations, uploads, scans, exports). Returned by `/v1/tasks` so external clients can poll their jobs the same way the in-app UI does.",
  "x-generated": "2026-11-19",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/nanostudiopro-com-openapi.json#/components/schemas/Task",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "action": {
      "type": "string",
      "enum": [
        "upload",
        "scan",
        "export",
        "generate"
      ],
      "description": "High-level grouping of the operation."
    },
    "kind": {
      "type": "string",
      "description": "Specific operation — e.g. `generate.quick`, `generate.restyle`, `generate.video`, `generate.angles`, `upload`, `scan`, `export`."
    },
    "status": {
      "type": "string",
      "enum": [
        "queued",
        "running",
        "complete",
        "failed",
        "canceled"
      ]
    },
    "progress": {
      "type": "integer",
      "minimum": 0,
      "maximum": 100,
      "description": "Best-effort 0-100; many endpoints leave it at 0."
    },
    "error": {
      "type": [
        "string",
        "null"
      ],
      "description": "User-facing error message if `status=failed`."
    },
    "label": {
      "type": [
        "string",
        "null"
      ]
    },
    "origin": {
      "type": [
        "string",
        "null"
      ],
      "description": "Where the task was triggered from. `API` for external callers, plus values like `Prompter`, `Card menu`, `Pose editor`."
    },
    "display_meta": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": true,
      "description": "Free-form metadata (aspect ratio, project id, thumbnail path) used by the UI placeholder. Safe for external clients to display verbatim."
    },
    "intent": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": true,
      "description": "Endpoint + body the task originated from. Used internally for retries."
    },
    "retries": {
      "type": "integer",
      "description": "How many retry attempts have been made."
    },
    "max_retries": {
      "type": "integer"
    },
    "provider": {
      "type": [
        "object",
        "null"
      ],
      "description": "External-system tracking for async providers (Kling video, future Runway/Pika/etc.). `null` for synchronous providers like Gemini.",
      "properties": {
        "key": {
          "type": "string"
        },
        "task_id": {
          "type": [
            "string",
            "null"
          ],
          "description": "External system's job id."
        },
        "status": {
          "type": [
            "string",
            "null"
          ],
          "description": "Provider-specific status string."
        },
        "updated_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        }
      }
    },
    "generation_id": {
      "type": [
        "string",
        "null"
      ],
      "description": "FK to the resulting Generation, if applicable."
    },
    "asset_id": {
      "type": [
        "string",
        "null"
      ],
      "description": "FK to the resulting Asset, if applicable."
    },
    "scan_result_id": {
      "type": [
        "string",
        "null"
      ]
    },
    "parent_task_id": {
      "type": [
        "string",
        "null"
      ],
      "description": "For batched operations — points to the parent Task."
    },
    "started_at": {
      "type": "string",
      "format": "date-time"
    },
    "completed_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    }
  }
}