{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/africacompliancedata-com/json-schema/africacompliancedata-com-tax-id-rules-schema.json",
  "title": "TaxIdRules",
  "x-generated": "2026-10-30",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/africacompliancedata-com-openapi.json#/components/schemas/TaxIdRules",
  "type": "object",
  "required": [
    "rules",
    "signature"
  ],
  "properties": {
    "rules": {
      "type": "object",
      "required": [
        "format",
        "dataset_version",
        "issued_at",
        "expires_at",
        "key_id",
        "disclaimer",
        "countries"
      ],
      "properties": {
        "format": {
          "type": "integer",
          "enum": [
            1
          ]
        },
        "dataset_version": {
          "type": "string"
        },
        "data_revision": {
          "$ref": "#/$defs/DataRevision"
        },
        "issued_at": {
          "type": "string",
          "format": "date-time"
        },
        "expires_at": {
          "type": "string",
          "format": "date-time",
          "description": "35 days after issued_at: do not use the rules after this"
        },
        "key_id": {
          "type": "string",
          "description": "First 16 hex digits of the SHA-256 of the signing public key"
        },
        "disclaimer": {
          "type": "string"
        },
        "scope": {
          "type": "string",
          "enum": [
            "pack"
          ],
          "description": "Present on Pro keys: 'countries' holds the country pack only"
        },
        "countries": {
          "type": "object",
          "description": "By ISO 3166-1 alpha-2 code",
          "additionalProperties": {
            "type": "object",
            "properties": {
              "country_name": {
                "type": "string"
              },
              "name": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The identifier's name; null when there is no tax ID entry for the country"
              },
              "pattern": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "JavaScript regular expression, anchored; null when no format is known"
              },
              "pattern_partial": {
                "type": "boolean",
                "description": "Only characters and length are known (a weak check)"
              },
              "check_digit": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "'luhn' and 'SARS mod10' are verified; other values are not"
              },
              "normalise": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The authority's wording, for information"
              },
              "coverage": {
                "type": "string",
                "enum": [
                  "ready",
                  "partial",
                  "gap"
                ]
              }
            }
          }
        }
      }
    },
    "signature": {
      "type": "object",
      "properties": {
        "alg": {
          "type": "string",
          "enum": [
            "Ed25519"
          ]
        },
        "key_id": {
          "type": "string"
        },
        "value": {
          "type": "string",
          "description": "Base64 Ed25519 signature of the UTF-8 canonical JSON of 'rules'"
        }
      }
    }
  },
  "$defs": {
    "DataRevision": {
      "type": "string",
      "description": "Short commit id of the data the answer was built from (e.g. 928cb72b). dataset_version is the build date: the daily rebuild changes it with no data change, while data_revision changes only when the data does. Keep it with saved results to know exactly which data you used."
    }
  }
}