{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/rivaire-pro/json-schema/rivaire-pro-recurring-series-schema.json",
  "title": "RecurringSeries",
  "x-generated": "2026-11-23",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/rivaire-pro-openapi.json#/components/schemas/RecurringSeries",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "workspaceId": {
      "type": "string",
      "format": "uuid"
    },
    "createdBy": {
      "type": "string",
      "format": "uuid"
    },
    "kind": {
      "type": "string",
      "enum": [
        "subscription",
        "income",
        "installment"
      ]
    },
    "type": {
      "type": "string",
      "enum": [
        "expense",
        "income",
        "transfer"
      ]
    },
    "name": {
      "type": "string"
    },
    "icon": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "frequency": {
      "type": "string",
      "enum": [
        "daily",
        "weekly",
        "biweekly",
        "monthly",
        "quarterly",
        "yearly",
        "custom"
      ]
    },
    "walletId": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ]
    },
    "categoryId": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ]
    },
    "tagIds": {
      "type": "array",
      "items": {
        "type": "string",
        "format": "uuid"
      }
    },
    "isStopped": {
      "type": "boolean"
    },
    "periods": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "startDate": {
            "type": "string",
            "format": "date"
          },
          "endDate": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ]
          },
          "amount": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "Decimal price; null when the connection cannot read amounts."
          },
          "currencyId": {
            "type": "string",
            "pattern": "^[A-Z]{3}$",
            "description": "Currency code, e.g. `USD`."
          },
          "encrypted": {
            "type": "object",
            "properties": {
              "amount": {
                "$ref": "#/$defs/EncryptedMoney"
              }
            },
            "required": [
              "amount"
            ]
          }
        },
        "required": [
          "startDate",
          "endDate",
          "amount",
          "currencyId"
        ]
      }
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    }
  },
  "required": [
    "id",
    "workspaceId",
    "createdBy",
    "kind",
    "type",
    "name",
    "icon",
    "frequency",
    "walletId",
    "categoryId",
    "tagIds",
    "isStopped",
    "periods",
    "createdAt"
  ],
  "$defs": {
    "EncryptedMoney": {
      "type": "object",
      "properties": {
        "ciphertext": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1024
        },
        "iv": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        },
        "algorithm": {
          "type": "string",
          "const": "AES-GCM"
        },
        "keyVersion": {
          "type": "integer",
          "exclusiveMinimum": 0
        },
        "keyId": {
          "type": "string",
          "format": "uuid"
        }
      },
      "required": [
        "ciphertext",
        "iv",
        "algorithm",
        "keyVersion"
      ],
      "description": "An encrypted value (AES-256-GCM; `ciphertext` and `iv` in base64). Without `keyId` it is under your money key (Main workspace); with it, under that workspace key."
    }
  }
}