{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/rightmoney-com/json-schema/rightmoney-com-transactions-response-schema.json",
  "title": "TransactionsResponse",
  "x-generated": "2026-11-23",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/rightmoney-com-openapi.json#/components/schemas/TransactionsResponse",
  "type": "object",
  "required": [
    "userId",
    "transactionCount",
    "merchantCount",
    "merchants",
    "buckets"
  ],
  "properties": {
    "userId": {
      "type": "string",
      "format": "uuid"
    },
    "transactionCount": {
      "type": "integer",
      "description": "Total number of transactions in the date range"
    },
    "merchantCount": {
      "type": "integer",
      "description": "Number of unique merchant patterns"
    },
    "dateRange": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "start": {
          "type": "string",
          "format": "date"
        },
        "end": {
          "type": "string",
          "format": "date"
        }
      }
    },
    "merchants": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "pattern": {
            "type": "string",
            "description": "Normalized merchant pattern"
          },
          "displayName": {
            "type": "string"
          },
          "totalAmount": {
            "type": "number"
          },
          "transactionCount": {
            "type": "integer"
          },
          "avgAmount": {
            "type": "number"
          },
          "direction": {
            "type": "string",
            "enum": [
              "inflow",
              "outflow"
            ]
          },
          "sampleDates": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "date"
            }
          },
          "suggestedBucket": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      }
    },
    "buckets": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Valid bucket values"
    },
    "fallbackRecommended": {
      "type": "boolean",
      "description": "True if >100 merchant patterns — recommend backend classification instead"
    },
    "instructions": {
      "type": "string",
      "description": "Classification guidance for the AI agent"
    }
  }
}