{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/tradesapi-com/json-schema/tradesapi-com-license-result-schema.json",
  "title": "LicenseResult",
  "x-generated": "2026-11-27",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/tradesapi-com-openapi.json#/components/schemas/LicenseResult",
  "properties": {
    "valid": {
      "type": "boolean",
      "title": "Valid"
    },
    "name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Name"
    },
    "license_number": {
      "type": "string",
      "title": "License Number"
    },
    "trade": {
      "type": "string",
      "title": "Trade"
    },
    "expiration": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Expiration"
    },
    "status": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Status"
    },
    "status_normalized": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Status Normalized",
      "description": "Normalized status bucket across states: active | expired | suspended | revoked | probation | inactive | unknown. Null when the state's mapping doesn't cover this specific raw status. Raw `status` is always preserved."
    },
    "state": {
      "type": "string",
      "title": "State"
    },
    "disciplinary_actions": {
      "items": {
        "additionalProperties": true,
        "type": "object"
      },
      "type": "array",
      "title": "Disciplinary Actions"
    },
    "disciplinary_data_available": {
      "type": "boolean",
      "title": "Disciplinary Data Available",
      "description": "True iff this jurisdiction is one where we extract board disciplinary/enforcement actions, or where the board publishes no case docket and a suspension/revocation status is itself the full public disciplinary record (status-derived, e.g. CT). When False, an empty `disciplinary_actions` means 'not collected for this jurisdiction', NOT a verified-clean record — so absence of data is never mistaken for absence of disciplinary history.",
      "default": false
    },
    "bond_info": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Bond Info"
    },
    "insurance_info": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Insurance Info"
    },
    "classifications": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Classifications"
    },
    "source_url": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Source Url"
    },
    "source_metadata": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Source Metadata",
      "description": "Per-source / per-program tags for downstream parity-audit + ER disambiguation. Example: {'program': 'dial_construction'} on Iowa DIAL Construction Contractor registrations distinguishes them from the EEB electrical and PMSB plumbing streams."
    },
    "cached": {
      "type": "boolean",
      "title": "Cached",
      "default": false
    },
    "source": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Source",
      "description": "Which read layer served this response: 'cache' (Redis), 'db' (license_current bulk feed), or 'scrape' (live portal). Null on legacy paths predating the cut-over (e.g. sandbox)."
    },
    "last_verified_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Last Verified At",
      "description": "Timestamp of the underlying observation. Equal to `checked_at` for fresh scrapes; older than `checked_at` when served from DB."
    },
    "staleness_seconds": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Staleness Seconds",
      "description": "Age of the underlying observation in seconds. Zero for fresh scrapes; >0 when served from DB."
    },
    "sandbox": {
      "type": "boolean",
      "title": "Sandbox",
      "description": "True iff this response came from the sandbox responder (sandbox-scoped API key). Sandbox responses are deterministic fixtures, not live data. Always false for production scrapes — clients can rely on this field to assert they're talking to the live API.",
      "default": false
    },
    "verification_type": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "license",
            "registration"
          ]
        },
        {
          "type": "null"
        }
      ],
      "title": "Verification Type",
      "description": "Disambiguates the legal weight of a positive (`valid=true`) result:\n  - 'license' → competency license (the holder has met the state's exam / experience / continuing-ed bar for the trade).\n  - 'registration' → an administrative registration only. The holder has filed paperwork and (typically) carries insurance / a bond / workers'-comp coverage, but the state has NOT certified trade competency. Examples: PA HICPA Home Improvement Contractor registration, MT ERD Contractor Registration / ICEC.\n  - null → not specified by the upstream scraper. Treat as 'license' for backward compatibility (this is the default for the 40+ scrapers that pre-date the field, all of which surface true competency licenses)."
    },
    "license_class": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 200
        },
        {
          "type": "null"
        }
      ],
      "title": "License Class",
      "description": "The issuer's exact classification term, e.g. 'Master Electrician'."
    },
    "facets": {
      "anyOf": [
        {
          "additionalProperties": {
            "type": "string"
          },
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Facets",
      "description": "Normalized trade/role/scope facets from app.license_class_facets."
    },
    "credential_role": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "standalone",
            "qualifier"
          ]
        },
        {
          "type": "null"
        }
      ],
      "title": "Credential Role",
      "description": "Distinguishes a standalone operating license from an individual qualifier credential that requires linkage to a parent business license to be operationally valid. Today only IL 105* (Qualifying Party ROOFING CONTRACTOR) surfaces 'qualifier'; all other paths leave this null (treat as 'standalone' for backward compatibility)."
    },
    "qualifier_note": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Qualifier Note",
      "description": "Human-readable note when credential_role='qualifier' — explains the credential class and operational scope (e.g. requires linkage to a parent business license). Null for standalone licenses."
    },
    "checked_at": {
      "type": "string",
      "format": "date-time",
      "title": "Checked At"
    },
    "has_disciplinary_action": {
      "type": "boolean",
      "title": "Has Disciplinary Action",
      "description": "Quick-check boolean: true iff disciplinary_actions is non-empty.\n\nComputed on every read/serialization so in-place mutation of\ndisciplinary_actions after construction can never leave this field\nstale. Cannot be set by the caller — derived is the source of truth.",
      "readOnly": true
    }
  },
  "type": "object",
  "required": [
    "valid",
    "license_number",
    "trade",
    "state",
    "has_disciplinary_action"
  ]
}