{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/safetydatasheetapi/main/json-schema/safetydatasheetapi-extraction-response-schema.json",
  "title": "ExtractionResponse",
  "x-generated": "2026-10-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/safetydatasheetapi-openapi.yaml#/components/schemas/ExtractionResponse",
  "type": "object",
  "required": [
    "ok",
    "request_id",
    "output_formats",
    "confidence_score",
    "warnings",
    "outputs"
  ],
  "properties": {
    "ok": {
      "type": "boolean",
      "const": true
    },
    "request_id": {
      "type": "string",
      "description": "Id for this request (the Cloudflare Ray id when present, otherwise a UUID). Quote it when contacting support."
    },
    "output_formats": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "JSON",
          "XML",
          "CSV"
        ]
      }
    },
    "confidence_score": {
      "type": "number",
      "minimum": 0,
      "maximum": 1,
      "description": "Extraction confidence from 0 to 1."
    },
    "document_language": {
      "type": [
        "string",
        "null"
      ],
      "description": "Language the document is written in, detected from the document itself (an ISO 639-1 code such as `sv`, or a regional form such as `pt-BR`). `null` when it could not be determined. Not the same as `language_hint`, which is only the hint you sent."
    },
    "billing": {
      "type": "object",
      "description": "Present when a per-customer API key is used. Failed extractions are never billed.",
      "properties": {
        "pages": {
          "type": "integer",
          "description": "Pages in the document."
        },
        "documents_billed": {
          "type": "integer",
          "description": "Documents charged; one per 40 pages (rounded up)."
        },
        "cost_usd": {
          "type": "number"
        }
      }
    },
    "schema_version": {
      "type": [
        "string",
        "null"
      ],
      "description": "Version of the response schema applied to `outputs.json` (`1.0`). Also returned in `metadata.schema_version`."
    },
    "is_safety_data_sheet": {
      "type": [
        "boolean",
        "null"
      ],
      "description": "Whether the uploaded document looks like a safety data sheet. Present when the fixed schema is enabled for the deployment; `false` is accompanied by a warning and mostly empty fields."
    },
    "warnings": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "outputs": {
      "type": "object",
      "properties": {
        "json": {
          "type": "object",
          "additionalProperties": true,
          "description": "Normalized SDS record, grouped by SDS section. Top-level keys: product_identification, hazards_identification, composition, first_aid, fire_fighting, accidental_release, handling_storage, exposure_controls_ppe, physical_chemical_properties, stability_reactivity, toxicological_information, ecological_information, disposal_considerations, transport_information, regulatory_information, revision_metadata."
        },
        "csv": {
          "type": "string",
          "description": "The same record as CSV with a `field,value` header and dotted field paths such as `product_identification.product_name`."
        }
      }
    },
    "metadata": {
      "type": "object",
      "properties": {
        "file_name": {
          "type": "string"
        },
        "file_size_bytes": {
          "type": "integer"
        },
        "language_hint": {
          "type": [
            "string",
            "null"
          ],
          "description": "The hint you sent, or `null` if you sent none."
        },
        "document_language": {
          "type": [
            "string",
            "null"
          ],
          "description": "Same value as the top-level `document_language`."
        },
        "schema_version": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "processing_ms": {
      "type": "integer",
      "description": "Server-side processing time in milliseconds."
    }
  }
}