{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/answerline-dev/json-schema/answerline-dev-task-status-response-schema.json",
  "title": "TaskStatusResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/answerline-dev-async-api-openapi.yml#/components/schemas/TaskStatusResponse",
  "type": "object",
  "required": [
    "task",
    "credits"
  ],
  "properties": {
    "task": {
      "$ref": "#/$defs/AsyncTaskSummary"
    },
    "credits": {
      "$ref": "#/$defs/AsyncTaskCredits"
    },
    "response": {
      "type": "object",
      "description": "Complete response payload; included only once the task status is COMPLETED or FAILED."
    }
  },
  "$defs": {
    "AsyncTaskCredits": {
      "type": "object",
      "required": [
        "creditsToCharge",
        "creditsCharged"
      ],
      "description": "Charge details for one async task, in USD.",
      "properties": {
        "creditsToCharge": {
          "type": "number",
          "description": "USD amount held back from the balance for this task."
        },
        "creditsCharged": {
          "type": [
            "number",
            "null"
          ],
          "description": "USD amount charged for the task (0 when a free request covered it); null while it has not finished."
        }
      }
    },
    "AsyncTaskSummary": {
      "type": "object",
      "required": [
        "id",
        "taskType",
        "status",
        "priority",
        "createdAt"
      ],
      "description": "Summary fields that every async task response includes.",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "description": "Identifier unique to the task."
        },
        "taskType": {
          "type": "string",
          "enum": [
            "AIMODE",
            "GOOGLE",
            "GOOGLE_NEWS",
            "GEMINI",
            "CHATGPT",
            "COPILOT",
            "PERPLEXITY",
            "GROK"
          ],
          "description": "Engine that handles this task."
        },
        "status": {
          "type": "string",
          "enum": [
            "QUEUED",
            "PROCESSING",
            "COMPLETED",
            "FAILED"
          ],
          "description": "Status of the task right now."
        },
        "priority": {
          "type": "integer",
          "description": "Priority of the task, from 1 to 10; tasks with higher numbers run first. Default: 1.",
          "minimum": 1,
          "maximum": 10
        },
        "createdAt": {
          "type": "string",
          "format": "date-time",
          "description": "Creation time of the task."
        },
        "latencyMs": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Time spent processing, in milliseconds, measured from the first pickup until the final outcome. The initial wait in the queue is not counted, but for a retried task it spans all attempts plus the backoff in between. Null for tasks in `QUEUED` or `PROCESSING` state, and for tasks that failed before processing began."
        },
        "idempotencyKey": {
          "type": [
            "string",
            "null"
          ],
          "description": "Idempotency key supplied with the request, if any."
        }
      }
    }
  }
}