{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/popp/json-schema/popp-process-document-request-schema.json",
  "title": "ProcessDocumentRequest",
  "description": "Request to classify and validate a document. Beta endpoint. Two modes: supply the definition inline via `documentType` (stateless), or reference a stored DocumentType via `documentTypeId` (stateful) — exactly one of the two is required. Supply the document itself via `documentBase64` (inline) or `documentUrl` (server downloads); again, exactly one of the two is required. Supported formats: PDF, JPEG, PNG, GIF, WebP, DOC, DOCX. The format is detected server-side from the file's magic bytes, and non-image inputs are converted to an image before classification.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/popp-documents-api-openapi.yml#/components/schemas/ProcessDocumentRequest",
  "type": "object",
  "properties": {
    "documentBase64": {
      "type": "string",
      "minLength": 1,
      "description": "Base64-encoded document. API Gateway caps the request body at ~6 MB. Required when documentUrl is not supplied; do not send both."
    },
    "documentUrl": {
      "type": "string",
      "format": "uri",
      "description": "Publicly accessible URL the server can GET the document from. Required when documentBase64 is not supplied; do not send both."
    },
    "candidateName": {
      "type": "string",
      "minLength": 1,
      "description": "Candidate name. Required when the validation list contains CHECK_NAME_MATCH; safe to omit otherwise."
    },
    "documentTypeId": {
      "type": "string",
      "format": "uuid",
      "description": "Id of a stored DocumentType to resolve server-side. Mutually exclusive with `documentType` — exactly one of the two is required. Returns 404 if the id is unknown, 403 if the record belongs to a different organisation."
    },
    "documentType": {
      "type": "object",
      "required": [
        "name"
      ],
      "description": "Inline document type definition. Mirrors the DocumentType resource shape. Supply at least one of validation or classificationRules so the classifier has something to evaluate against. Mutually exclusive with `documentTypeId` — exactly one of the two is required.",
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1,
          "description": "Display name of the document type (e.g. \"Passport\")."
        },
        "validation": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "CHECK_DOCUMENT_CORNER_INCLUSION",
              "CHECK_NAME_MATCH",
              "CHECK_EXPIRATION_DATE",
              "CHECK_ISSUE_DATE",
              "CHECK_DATE_OF_BIRTH_INCLUSION",
              "CHECK_HOME_ADDRESS_INCLUSION"
            ]
          },
          "description": "Validation checks to run against the uploaded document."
        },
        "classificationRules": {
          "type": "array",
          "description": "Rules that determine whether the document qualifies as this type.",
          "items": {
            "type": "object",
            "required": [
              "type",
              "value"
            ],
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "INCLUDES_FIELD"
                ],
                "description": "Rule kind. Only INCLUDES_FIELD is supported today."
              },
              "value": {
                "type": "string",
                "minLength": 1,
                "description": "Argument for the rule. For INCLUDES_FIELD, the field name that must appear on the document."
              }
            }
          }
        },
        "validationSettings": {
          "type": "object",
          "description": "Parameters tuning the configured validations. Currently supports validFor (paired with CHECK_EXPIRATION_DATE) and issuedAfter (paired with CHECK_ISSUE_DATE). Each is a relative DateRange.",
          "properties": {
            "validFor": {
              "type": "object",
              "required": [
                "value",
                "unit"
              ],
              "properties": {
                "value": {
                  "type": "integer",
                  "minimum": 1
                },
                "unit": {
                  "type": "string",
                  "enum": [
                    "DAYS",
                    "MONTHS",
                    "YEARS"
                  ]
                }
              }
            },
            "issuedAfter": {
              "type": "object",
              "required": [
                "value",
                "unit"
              ],
              "properties": {
                "value": {
                  "type": "integer",
                  "minimum": 1
                },
                "unit": {
                  "type": "string",
                  "enum": [
                    "DAYS",
                    "MONTHS",
                    "YEARS"
                  ]
                }
              }
            }
          }
        }
      }
    }
  },
  "additionalProperties": false
}