{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/ai2fin-com/json-schema/ai2fin-com-transaction-category-schema.json",
  "title": "TransactionCategory",
  "description": "A category assignment for a transaction. Transactions can have multiple categories from different sets.",
  "x-generated": "2026-11-01",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/ai2fin-com-openapi.json#/components/schemas/TransactionCategory",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "transactionId": {
      "type": "string"
    },
    "categoryId": {
      "type": "string"
    },
    "categorySetId": {
      "type": "string"
    },
    "userId": {
      "type": "string"
    },
    "isPrimary": {
      "type": "boolean",
      "description": "Whether this is the primary category for the transaction"
    },
    "confidence": {
      "type": "number",
      "minimum": 0,
      "maximum": 1,
      "description": "AI confidence score for the assignment"
    },
    "assignedBy": {
      "type": "string",
      "enum": [
        "user",
        "ai",
        "import",
        "rule",
        "bulk"
      ],
      "description": "Source of the category assignment"
    },
    "assignedAt": {
      "type": "string",
      "format": "date-time"
    },
    "notes": {
      "type": "string"
    },
    "category": {
      "$ref": "#/$defs/Category"
    }
  },
  "$defs": {
    "Category": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "icon": {
          "type": "string"
        },
        "color": {
          "type": "string"
        },
        "isTaxDeductible": {
          "type": "boolean"
        },
        "taxCategory": {
          "type": "string"
        },
        "defaultGstRate": {
          "type": "number"
        }
      }
    }
  }
}