{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/dotsy-ai/json-schema/dotsy-ai-brief-response-schema.json",
  "title": "BriefResponse",
  "description": "The site brief, or the page brief when the request carried `?page=`.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/dotsy-ai-brief-api-openapi.yml#/components/schemas/BriefResponse",
  "anyOf": [
    {
      "$ref": "#/$defs/SiteBrief"
    },
    {
      "$ref": "#/$defs/PageBrief"
    }
  ],
  "$defs": {
    "PageBrief": {
      "type": "object",
      "properties": {
        "head": {
          "$ref": "#/$defs/PageBriefHead"
        },
        "notes": {
          "type": [
            "string",
            "null"
          ],
          "description": "The page brief's `## Notes` section, or null when it has none."
        },
        "hash": {
          "type": "string"
        },
        "hasBody": {
          "type": "boolean"
        }
      },
      "required": [
        "head",
        "notes",
        "hasBody"
      ]
    },
    "PageBriefHead": {
      "type": "object",
      "properties": {
        "purpose": {
          "type": "string",
          "maxLength": 280
        },
        "design": {
          "type": "object",
          "properties": {
            "direction": {
              "type": "string",
              "maxLength": 80
            },
            "hero": {
              "type": "string",
              "maxLength": 80
            }
          },
          "additionalProperties": false
        }
      }
    },
    "SiteBrief": {
      "type": "object",
      "properties": {
        "head": {
          "$ref": "#/$defs/SiteBriefHead"
        },
        "notes": {
          "type": [
            "string",
            "null"
          ],
          "description": "The brief's `## Notes` section, or null when it has none."
        },
        "hash": {
          "type": "string",
          "description": "Content hash of the stored brief (changes on every write)."
        },
        "sectionNotes": {
          "type": "object",
          "properties": {
            "design": {
              "type": "string"
            },
            "content": {
              "type": "string"
            },
            "seo": {
              "type": "string"
            }
          },
          "description": "The Design system, Content & CMS and SEO notes that are set (full text). Omitted when none is."
        },
        "hasBody": {
          "type": "boolean",
          "description": "True when the brief has narrative text beyond the head and notes. Omitted on a site-brief write."
        },
        "aiAccess": {
          "type": "string",
          "enum": [
            "viewer",
            "contributor",
            "editor",
            "owner"
          ],
          "description": "GET only (also on the 404 `brief_not_set` and 409 `brief_head_corrupt` answers): what AI agents and API keys may do on this site — the effective level, `owner` (Full access) by default."
        },
        "ruleFailures": {
          "type": "object",
          "properties": {
            "intent": {
              "type": "integer"
            },
            "design": {
              "type": "integer"
            },
            "content": {
              "type": "integer"
            },
            "seo": {
              "type": "integer"
            }
          },
          "required": [
            "intent",
            "design",
            "content",
            "seo"
          ],
          "description": "GET only (also on the 404 and 409 answers): how many Rules failed in each section on the site's last check. Omitted until a check has counted any."
        },
        "ruleFailuresCheckedAt": {
          "type": "integer",
          "description": "GET only, with `ruleFailures`: when that check ran (epoch ms). A Rule added after it has not been checked yet."
        }
      },
      "required": [
        "head",
        "notes"
      ]
    },
    "SiteBriefHead": {
      "type": "object",
      "properties": {
        "purpose": {
          "type": "string",
          "minLength": 5,
          "maxLength": 280
        },
        "audience": {
          "type": "string",
          "maxLength": 200
        },
        "kind": {
          "type": "string",
          "enum": [
            "exploration",
            "production"
          ]
        },
        "priorities": {
          "type": "object",
          "properties": {
            "seo": {
              "type": "string",
              "enum": [
                "must",
                "nice",
                "skip"
              ]
            },
            "analytics": {
              "type": "string",
              "enum": [
                "must",
                "nice",
                "skip"
              ]
            },
            "design": {
              "type": "string",
              "enum": [
                "must",
                "nice",
                "skip"
              ]
            },
            "mobile": {
              "type": "string",
              "enum": [
                "must",
                "nice",
                "skip"
              ]
            }
          }
        },
        "editingModel": {
          "type": "string",
          "enum": [
            "ai",
            "simple-editor",
            "creator"
          ]
        },
        "sections": {
          "type": "array",
          "items": {
            "type": "string",
            "maxLength": 60
          },
          "maxItems": 20
        },
        "design": {
          "type": "object",
          "properties": {
            "palette": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "maxItems": 8
            },
            "type": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "maxItems": 6
            },
            "layout": {
              "type": "string",
              "maxLength": 80
            }
          },
          "additionalProperties": false
        },
        "business": {
          "type": "object",
          "properties": {
            "name": {
              "type": "string",
              "minLength": 1,
              "maxLength": 120
            },
            "type": {
              "type": "string",
              "enum": [
                "Organization",
                "LocalBusiness",
                "ProfessionalService",
                "Store",
                "Restaurant",
                "Dentist",
                "MedicalBusiness",
                "HomeAndConstructionBusiness"
              ]
            },
            "description": {
              "type": "string",
              "maxLength": 300
            },
            "phone": {
              "type": "string",
              "maxLength": 40
            },
            "email": {
              "type": "string",
              "maxLength": 120,
              "format": "email"
            },
            "hours": {
              "type": "string",
              "maxLength": 200
            },
            "areaServed": {
              "type": "string",
              "maxLength": 200
            },
            "sameAs": {
              "type": "array",
              "items": {
                "type": "string",
                "maxLength": 300
              },
              "maxItems": 8
            },
            "foundingYear": {
              "type": "integer",
              "minimum": 1000,
              "maximum": 2100
            },
            "logo": {
              "type": "string",
              "maxLength": 300
            },
            "url": {
              "type": "string",
              "maxLength": 300
            },
            "address": {
              "type": "object",
              "properties": {
                "street": {
                  "type": "string",
                  "maxLength": 120
                },
                "city": {
                  "type": "string",
                  "maxLength": 120
                },
                "region": {
                  "type": "string",
                  "maxLength": 120
                },
                "postalCode": {
                  "type": "string",
                  "maxLength": 120
                },
                "country": {
                  "type": "string",
                  "maxLength": 120
                }
              },
              "additionalProperties": false
            }
          },
          "additionalProperties": false
        },
        "authors": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 80
              },
              "role": {
                "type": "string",
                "maxLength": 80
              },
              "url": {
                "type": "string",
                "maxLength": 300
              },
              "image": {
                "type": "string",
                "maxLength": 300
              },
              "sameAs": {
                "type": "array",
                "items": {
                  "type": "string",
                  "maxLength": 300
                },
                "maxItems": 4
              }
            },
            "required": [
              "name"
            ],
            "additionalProperties": false
          },
          "maxItems": 20
        },
        "rules": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^[a-z0-9-]{2,40}$"
              },
              "card": {
                "type": "string",
                "enum": [
                  "intent",
                  "design",
                  "content",
                  "seo"
                ]
              },
              "text": {
                "type": "string",
                "minLength": 1,
                "maxLength": 160
              },
              "level": {
                "type": "string",
                "enum": [
                  "block",
                  "warn"
                ]
              },
              "locked": {
                "type": "boolean"
              },
              "check": {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 40
                  }
                },
                "required": [
                  "type"
                ]
              }
            },
            "required": [
              "id",
              "card",
              "text"
            ]
          },
          "maxItems": 30
        },
        "updated": {
          "type": "string"
        },
        "updatedBy": {
          "type": "string",
          "enum": [
            "agent",
            "human"
          ]
        }
      },
      "required": [
        "purpose"
      ],
      "description": "The structured top of the site brief. `purpose` is required (5–280 characters). `business` and `authors` reach live pages at the next publish."
    }
  }
}