{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/agendaforge-app/json-schema/agendaforge-app-job-schema.json",
  "title": "Job",
  "x-generated": "2026-10-29",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/agendaforge-app-openapi.json#/components/schemas/Job",
  "type": "object",
  "required": [
    "jobId",
    "type",
    "status",
    "createdAt",
    "completedAt",
    "result"
  ],
  "properties": {
    "jobId": {
      "type": "string"
    },
    "type": {
      "type": "string",
      "enum": [
        "contacts_import"
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "pending",
        "processing",
        "completed",
        "failed"
      ],
      "description": "Terminal states are completed and failed; keep polling until one is reached."
    },
    "createdAt": {
      "type": "string",
      "description": "ISO-8601 UTC timestamp."
    },
    "completedAt": {
      "type": [
        "string",
        "null"
      ],
      "description": "ISO-8601 UTC timestamp; null until the job reaches a terminal state."
    },
    "result": {
      "type": "object",
      "required": [
        "total",
        "processed",
        "created",
        "failed",
        "errors"
      ],
      "properties": {
        "total": {
          "type": "integer"
        },
        "processed": {
          "type": "integer",
          "description": "Items handled so far; equals total when done."
        },
        "created": {
          "type": "integer"
        },
        "failed": {
          "type": "integer"
        },
        "errors": {
          "type": "array",
          "description": "Per-item failures (first 50), each with the failing input index.",
          "items": {
            "type": "object",
            "required": [
              "index",
              "code",
              "message"
            ],
            "properties": {
              "index": {
                "type": "integer"
              },
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}