{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/safetydatasheetapi/main/json-schema/safetydatasheetapi-bulk-job-status-schema.json",
  "title": "BulkJobStatus",
  "x-generated": "2026-10-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/safetydatasheetapi-openapi.yaml#/components/schemas/BulkJobStatus",
  "type": "object",
  "required": [
    "ok",
    "job_id",
    "status",
    "total_items",
    "completed_items",
    "failed_items",
    "items"
  ],
  "properties": {
    "ok": {
      "type": "boolean",
      "const": true
    },
    "idempotent_replay": {
      "type": "boolean",
      "description": "Present and true when this response replays an existing job for a repeated `Idempotency-Key`."
    },
    "job_id": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "queued",
        "processing",
        "completed",
        "failed"
      ]
    },
    "total_items": {
      "type": "integer"
    },
    "completed_items": {
      "type": "integer"
    },
    "failed_items": {
      "type": "integer"
    },
    "webhook_status": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        null,
        "delivered",
        "failed"
      ],
      "description": "Webhook delivery outcome, or null if no `callback_url` was supplied or delivery has not finished."
    },
    "webhook_attempts": {
      "type": "integer",
      "description": "Number of webhook delivery attempts made so far."
    },
    "items": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/BulkJobItem"
      }
    }
  },
  "$defs": {
    "BulkJobItem": {
      "type": "object",
      "properties": {
        "file_name": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "queued",
            "success",
            "error"
          ]
        },
        "confidence_score": {
          "type": [
            "number",
            "null"
          ],
          "minimum": 0,
          "maximum": 1
        },
        "warnings": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "data": {
          "type": [
            "object",
            "null"
          ],
          "additionalProperties": true,
          "description": "Normalized SDS record when `status` is `success`."
        },
        "error_code": {
          "type": "string",
          "enum": [
            "provider_error",
            "provider_not_configured"
          ],
          "description": "Present when `status` is `error`. Stable machine-readable code."
        },
        "error_message": {
          "type": "string",
          "description": "Present when `status` is `error`. Generic human-readable text; provider detail is never exposed."
        }
      }
    }
  }
}