{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/ai2fin-com/json-schema/ai2fin-com-transaction-field-history-schema.json",
  "title": "TransactionFieldHistory",
  "description": "A history entry tracking a field change on a transaction, expense, bill, or bill pattern. Maximum 11 entries per field.",
  "x-generated": "2026-11-01",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/ai2fin-com-openapi.json#/components/schemas/TransactionFieldHistory",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "userId": {
      "type": "string"
    },
    "entityType": {
      "type": "string",
      "enum": [
        "transaction",
        "expense",
        "bill",
        "billPattern"
      ],
      "description": "Type of entity being tracked"
    },
    "entityId": {
      "type": "string",
      "description": "ID of the entity"
    },
    "fieldName": {
      "type": "string",
      "description": "Name of the field that was changed (e.g., categoryId, amount, description)"
    },
    "oldValue": {
      "type": "string",
      "description": "Previous value (JSON string)"
    },
    "newValue": {
      "type": "string",
      "description": "New value (JSON string)"
    },
    "changeReason": {
      "type": "string",
      "description": "Optional reason for the change"
    },
    "changedBy": {
      "type": "string",
      "enum": [
        "user",
        "ai",
        "rule",
        "system",
        "import",
        "bulk"
      ],
      "description": "Source of the change"
    },
    "changeSource": {
      "type": "string",
      "description": "Additional context about the change source"
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    }
  }
}