{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://c-app.uk/schemas/capp.links.v1.schema.json",
  "title": "cApp saved links",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "protocol",
    "links"
  ],
  "properties": {
    "protocol": {
      "const": "capp.links.v1"
    },
    "links": {
      "type": "array",
      "maxItems": 500,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "url"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,96}$"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "pattern": "^https?://",
            "maxLength": 4096
          },
          "title": {
            "type": "string",
            "maxLength": 160
          },
          "folder": {
            "type": "string",
            "maxLength": 80
          },
          "notes": {
            "type": "string",
            "maxLength": 2000
          },
          "pinned": {
            "type": "boolean"
          }
        }
      }
    }
  },
  "$comment": "Runtime additionally canonicalises URLs, rejects embedded credentials/control characters, enforces unique IDs/URLs, the selected link limit and the compiled HTTP opt-in. Import merges by URL and does not overwrite existing records."
}
