{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/hjarni-com/json-schema/hjarni-com-revision-schema.json",
  "title": "Revision",
  "description": "One revision of a note. `meta_changes` appears only when fields other than the body changed; `body` only with include_body=true or seq.",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/hjarni-com-openapi.json#/components/schemas/Revision",
  "type": "object",
  "required": [
    "seq",
    "at",
    "kind",
    "changed",
    "edit_count",
    "reverted_from_seq",
    "summary",
    "by"
  ],
  "properties": {
    "seq": {
      "type": "integer",
      "description": "Revision number, starting at 1."
    },
    "at": {
      "type": "string",
      "format": "date-time",
      "description": "When the revision was last written (quick successive edits by one author fold into one)."
    },
    "kind": {
      "type": "string",
      "enum": [
        "diff",
        "keyframe",
        "delete",
        "restore"
      ],
      "description": "How the revision is stored or what it records."
    },
    "changed": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "What changed, e.g. body, title, summary, container, source_url, favorited, archived, or link_title for a system edit."
    },
    "edit_count": {
      "type": "integer",
      "description": "How many edits were folded into this revision."
    },
    "reverted_from_seq": {
      "type": [
        "integer",
        "null"
      ],
      "description": "For a revert, the revision it brought back."
    },
    "summary": {
      "type": "string",
      "description": "One readable line, e.g. \"alice@example.com edited the body and renamed it\"."
    },
    "by": {
      "$ref": "#/$defs/RevisionAuthor"
    },
    "meta_changes": {
      "type": "object",
      "additionalProperties": true,
      "description": "Non-body fields that changed, keyed by column (title, summary, container_id, source_url, favorited, archived) with [old, new] pairs, plus revert_to for a revert."
    },
    "body": {
      "type": [
        "string",
        "null"
      ],
      "description": "The body as of this revision; null when it could not be rebuilt."
    },
    "body_error": {
      "type": "string",
      "description": "Present when body is null because the stored history did not verify."
    }
  },
  "$defs": {
    "RevisionAuthor": {
      "type": "object",
      "description": "Who made a revision.",
      "required": [
        "label",
        "kind",
        "client",
        "agent",
        "source"
      ],
      "properties": {
        "label": {
          "type": [
            "string",
            "null"
          ],
          "description": "Display name, e.g. an email address, an agent token's name, or \"(system)\"."
        },
        "kind": {
          "type": "string",
          "enum": [
            "user",
            "agent",
            "system",
            "anonymous"
          ]
        },
        "client": {
          "type": [
            "string",
            "null"
          ],
          "description": "The AI client, for agent edits."
        },
        "agent": {
          "type": [
            "string",
            "null"
          ],
          "description": "The token or agent name, when there was one."
        },
        "source": {
          "type": "string",
          "description": "The surface the edit came through, such as web, api, mcp or system."
        }
      }
    }
  }
}