{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.ai-visibility.org.uk/specifications/ai-json/ai-json.schema.json",
  "title": "ai.json",
  "description": "JSON Schema for ai.json files - machine-parseable AI interaction guidance. This is the unversioned 'latest' alias. The canonical permanent location is /specifications/ai-json/v1/ai-json.schema.json. See /specifications/conventions/#schema-urls for the URL versioning policy.",
  "type": "object",
  "required": [
    "$schema",
    "name",
    "url",
    "permissions",
    "restrictions"
  ],
  "properties": {
    "$schema": {
      "type": "string",
      "format": "uri",
      "description": "Reference to this JSON Schema",
      "const": "https://www.ai-visibility.org.uk/specifications/ai-json/ai-json.schema.json"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "description": "Official organisation name"
    },
    "url": {
      "type": "string",
      "format": "uri",
      "description": "Canonical website URL"
    },
    "permissions": {
      "type": "array",
      "description": "List of permitted AI actions",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/permission"
      }
    },
    "restrictions": {
      "type": "array",
      "description": "List of prohibited AI actions",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/restriction"
      }
    },
    "attribution": {
      "type": "object",
      "description": "Attribution requirements",
      "properties": {
        "required": {
          "type": "boolean",
          "description": "Whether attribution is required when citing this source"
        },
        "format": {
          "type": "string",
          "description": "Preferred attribution format"
        },
        "examples": {
          "type": "array",
          "description": "Example attribution statements",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "contact": {
      "type": "object",
      "description": "Contact information for AI-related queries",
      "properties": {
        "email": {
          "type": "string",
          "format": "email",
          "description": "Email address for AI-related questions"
        },
        "url": {
          "type": "string",
          "format": "uri",
          "description": "URL for AI-related contact form or page"
        }
      }
    },
    "scope": {
      "type": "object",
      "description": "Scope of these permissions and restrictions",
      "properties": {
        "appliesTo": {
          "type": "string",
          "description": "What content these rules apply to"
        },
        "excludes": {
          "type": "array",
          "description": "Areas or content excluded from these rules",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "licensing": {
      "type": "object",
      "description": "Content licensing information",
      "properties": {
        "contentLicense": {
          "type": "string",
          "description": "License for website content"
        },
        "aiTrainingAllowed": {
          "type": "boolean",
          "description": "Whether content may be used for AI model training"
        },
        "aiTrainingNotes": {
          "type": "string",
          "description": "Additional notes about AI training permissions"
        }
      }
    },
    "metadata": {
      "type": "object",
      "description": "File metadata",
      "properties": {
        "version": {
          "type": "string",
          "description": "Version of this ai.json file",
          "pattern": "^\\d+\\.\\d+\\.\\d+$"
        },
        "lastUpdated": {
          "type": "string",
          "format": "date",
          "description": "Date of last update (ISO 8601)"
        },
        "generator": {
          "type": "string",
          "description": "Tool or process that generated this file"
        }
      }
    },
    "language": {
      "type": "string",
      "description": "BCP 47 language tag (e.g. en-GB) declaring the natural language of human-readable content in this file. Optional. See /specifications/conventions/#language-declaration.",
      "pattern": "^[a-zA-Z]{2,3}(-[a-zA-Z0-9]+)*$"
    }
  },
  "$defs": {
    "permission": {
      "type": "object",
      "description": "A permitted AI action",
      "required": [
        "action"
      ],
      "properties": {
        "action": {
          "type": "string",
          "description": "The permitted action identifier",
          "minLength": 1
        },
        "description": {
          "type": "string",
          "description": "Human-readable description of this permission"
        },
        "conditions": {
          "type": "array",
          "description": "Conditions that apply to this permission",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "restriction": {
      "type": "object",
      "description": "A prohibited AI action",
      "required": [
        "action"
      ],
      "properties": {
        "action": {
          "type": "string",
          "description": "The prohibited action identifier",
          "minLength": 1
        },
        "reason": {
          "type": "string",
          "description": "Why this action is prohibited"
        },
        "severity": {
          "type": "string",
          "enum": [
            "must-not",
            "should-not"
          ],
          "description": "Severity level of the restriction",
          "default": "must-not"
        }
      }
    }
  },
  "additionalProperties": false
}
