{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/rivaire-pro/json-schema/rivaire-pro-transaction-schema.json",
  "title": "Transaction",
  "x-generated": "2026-11-23",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/rivaire-pro-openapi.json#/components/schemas/Transaction",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "workspaceId": {
      "type": "string",
      "format": "uuid"
    },
    "type": {
      "type": "string",
      "enum": [
        "expense",
        "income",
        "transfer"
      ]
    },
    "seriesId": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "description": "Parent recurring series, or null for a standalone transaction."
    },
    "amount": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "Decimal string like `\"12.50\"`. `null` if the token keeps amounts locked; see `encrypted`."
    },
    "currencyId": {
      "type": "string"
    },
    "walletId": {
      "type": "string",
      "format": "uuid"
    },
    "categoryId": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ]
    },
    "tagIds": {
      "type": "array",
      "items": {
        "type": "string",
        "format": "uuid"
      }
    },
    "note": {
      "type": "string"
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "timeZone": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "transferToWalletId": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ]
    },
    "transferAmount": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "Decimal string like `\"12.50\"`. `null` if the token keeps amounts locked; see `encrypted`."
    },
    "transferCurrencyId": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "location": {
      "anyOf": [
        {
          "$ref": "#/$defs/Location"
        },
        {
          "type": "null"
        }
      ]
    },
    "original": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "amount": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Decimal string like `\"12.50\"`. `null` if the token keeps amounts locked; see `encrypted`."
            },
            "currencyId": {
              "type": "string"
            }
          },
          "required": [
            "amount",
            "currencyId"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "createdBy": {
      "type": "string",
      "format": "uuid"
    },
    "updatedBy": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ]
    },
    "encrypted": {
      "description": "The stored values, for tokens that keep amounts locked.",
      "type": "object",
      "properties": {
        "amount": {
          "anyOf": [
            {
              "$ref": "#/$defs/EncryptedMoney"
            },
            {
              "type": "null"
            }
          ]
        },
        "transferAmount": {
          "anyOf": [
            {
              "$ref": "#/$defs/EncryptedMoney"
            },
            {
              "type": "null"
            }
          ]
        },
        "location": {
          "anyOf": [
            {
              "$ref": "#/$defs/EncryptedMoney"
            },
            {
              "type": "null"
            }
          ]
        },
        "originalAmount": {
          "anyOf": [
            {
              "$ref": "#/$defs/EncryptedMoney"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "amount",
        "transferAmount",
        "location",
        "originalAmount"
      ]
    }
  },
  "required": [
    "id",
    "workspaceId",
    "type",
    "seriesId",
    "amount",
    "currencyId",
    "walletId",
    "categoryId",
    "tagIds",
    "note",
    "createdAt",
    "timeZone",
    "transferToWalletId",
    "transferAmount",
    "transferCurrencyId",
    "location",
    "original",
    "createdBy",
    "updatedBy"
  ],
  "$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."
    },
    "Location": {
      "type": "object",
      "properties": {
        "latitude": {
          "type": "number"
        },
        "longitude": {
          "type": "number"
        },
        "accuracyMeters": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "latitude",
        "longitude",
        "accuracyMeters"
      ]
    }
  }
}