{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/keep-md/json-schema/keep-md-item-change-event-schema.json",
  "title": "ItemChangeEvent",
  "x-generated": "2026-11-13",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/keep-md-openapi.json#/components/schemas/ItemChangeEvent",
  "type": "object",
  "required": [
    "id",
    "type",
    "changedAt",
    "itemId"
  ],
  "properties": {
    "id": {
      "type": "string"
    },
    "type": {
      "type": "string",
      "enum": [
        "item.created",
        "item.updated",
        "item.deleted",
        "item.tagged",
        "item.untagged",
        "item.collection_added",
        "item.collection_removed",
        "item.removed_from_scope",
        "webhook.test"
      ]
    },
    "originalType": {
      "type": "string",
      "enum": [
        "item.created",
        "item.updated",
        "item.deleted",
        "item.tagged",
        "item.untagged",
        "item.collection_added",
        "item.collection_removed",
        "item.removed_from_scope",
        "webhook.test"
      ]
    },
    "changedAt": {
      "type": "integer"
    },
    "itemId": {
      "type": "string"
    },
    "beforeScope": {
      "type": [
        "object",
        "null"
      ],
      "allOf": [
        {
          "$ref": "#/$defs/ItemScopeSnapshot"
        }
      ]
    },
    "afterScope": {
      "type": [
        "object",
        "null"
      ],
      "allOf": [
        {
          "$ref": "#/$defs/ItemScopeSnapshot"
        }
      ]
    },
    "payload": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": true
    },
    "item": {
      "$ref": "#/$defs/Item"
    }
  },
  "$defs": {
    "Highlight": {
      "type": "object",
      "required": [
        "id",
        "itemId",
        "text",
        "createdAt",
        "updatedAt"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "itemId": {
          "type": "string"
        },
        "text": {
          "type": "string"
        },
        "prefix": {
          "type": "string"
        },
        "suffix": {
          "type": "string"
        },
        "note": {
          "type": [
            "string",
            "null"
          ]
        },
        "startOffset": {
          "type": "integer"
        },
        "endOffset": {
          "type": "integer"
        },
        "createdAt": {
          "type": "integer"
        },
        "updatedAt": {
          "type": "integer"
        }
      },
      "additionalProperties": true
    },
    "Item": {
      "type": "object",
      "required": [
        "id",
        "url",
        "status",
        "createdAt"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "title": {
          "type": "string"
        },
        "favicon": {
          "type": "string"
        },
        "status": {
          "type": "string"
        },
        "createdAt": {
          "type": "integer"
        },
        "lastSeenAt": {
          "type": "integer"
        },
        "updatedAt": {
          "type": "integer"
        },
        "timesAdded": {
          "type": "integer"
        },
        "notes": {
          "type": "string"
        },
        "tags": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "tagSlugs": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "collectionId": {
          "type": [
            "string",
            "null"
          ]
        },
        "collectionIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "collectionName": {
          "type": "string"
        },
        "collectionSlug": {
          "type": "string"
        },
        "summaryMarkdown": {
          "type": "string"
        },
        "contentAvailable": {
          "type": "boolean"
        },
        "contentMarkdown": {
          "type": "string"
        },
        "content": {
          "$ref": "#/$defs/ItemContent"
        },
        "highlights": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Highlight"
          }
        },
        "connectedNotes": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "processedAt": {
          "type": "integer"
        }
      },
      "additionalProperties": true
    },
    "ItemContent": {
      "type": "object",
      "required": [
        "schemaVersion",
        "items"
      ],
      "properties": {
        "schemaVersion": {
          "type": "integer",
          "enum": [
            2
          ]
        },
        "meta": {
          "type": "object",
          "additionalProperties": true
        },
        "items": {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/$defs/ItemContentPart"
          }
        },
        "media": {
          "type": "array",
          "maxItems": 8,
          "items": {
            "$ref": "#/$defs/MediaRef"
          }
        }
      }
    },
    "ItemContentPart": {
      "type": "object",
      "required": [
        "format",
        "markdown"
      ],
      "properties": {
        "format": {
          "type": "string",
          "enum": [
            "markdown"
          ]
        },
        "markdown": {
          "type": "string"
        },
        "meta": {
          "type": "object",
          "additionalProperties": true
        }
      }
    },
    "ItemScopeSnapshot": {
      "type": "object",
      "properties": {
        "status": {
          "type": "string"
        },
        "tagSlugs": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "collectionIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "MediaRef": {
      "type": "object",
      "required": [
        "id",
        "kind",
        "role",
        "url",
        "order"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "kind": {
          "type": "string",
          "enum": [
            "image"
          ]
        },
        "role": {
          "type": "string",
          "enum": [
            "lead",
            "inline",
            "gallery",
            "thumbnail",
            "attachment"
          ]
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "order": {
          "type": "integer",
          "minimum": 0
        },
        "sourceUrl": {
          "type": "string",
          "format": "uri"
        },
        "alt": {
          "type": "string"
        },
        "width": {
          "type": "integer",
          "minimum": 1
        },
        "height": {
          "type": "integer",
          "minimum": 1
        },
        "mimeType": {
          "type": "string"
        },
        "byteSize": {
          "type": "integer",
          "minimum": 1
        },
        "contentHash": {
          "type": "string"
        }
      },
      "additionalProperties": true
    }
  }
}