openapi: 3.1.0
info:
  title: Pledger.io System API
  version: 3.0.0
  contact:
    name: Jong Soft Development
    url: https://github.com/pledger-io/rest-application
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
security:
  - bearerAuth: []
tags:
  - name: i18n
    description: i18n
  - name: account-fetcher
    description: Operations to fetch account information
  - name: account-commands
    description: Operations to manipulate account information
  - name: transaction-fetcher
    description: Operations to fetch transaction information
paths:
  /.well-known/openid-connect:
    get:
      operationId: openIdConfiguration
      tags:
        - open-id
      security: []
      summary: Get configuration
      description: |
        Get the configuration needed to setup an OpenId integration in the front-end.
      responses:
        '200':
          description: The configuration
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/open-id-configuration'
  /.well-known/public-key:
    get:
      operationId: getJwtSignature
      tags:
        - security
      security: []
      summary: Get JWT signature
      description: |
        Get the public key used to verify the JWT signature.
      responses:
        '200':
          description: The public key
          content:
            application/json:
              schema:
                type: string
  /v2/api/user-account:
    post:
      operationId: createUser
      tags:
        - security
      security: []
      summary: Create user
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/user'
      responses:
        '204':
          description: Confirmation the account was created
        '400':
          $ref: '#/components/responses/400-response'
  /v2/api/user-account/verify-2-factor:
    post:
      operationId: verifyTwoFactor
      tags:
        - security
      summary: Verify 2-factor
      description: |
        Used to verify the user token against that what is expected. If valid the user will get a new JWT with updated authorizations.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/token'
      responses:
        '200':
          description: Confirmation the 2 factor was OK
          content:
            application/json:
              schema:
                type: object
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
  /v2/api/user-account/{user}:
    parameters:
      - name: user
        in: path
        required: true
        schema:
          type: string
          example: e@example.nl
    get:
      operationId: getProfile
      tags:
        - profile
      summary: Get profile
      description: |
        Get the profile of the authenticated user
      responses:
        '200':
          description: The users profile
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/user-profile'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
    patch:
      operationId: patchProfile
      tags:
        - profile
      summary: Update profile
      description: |
        Update a part of the users profile
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                theme:
                  type: string
                  example: dark
                currency:
                  type: string
                  example: EUR
                password:
                  type: string
      responses:
        '200':
          description: The users profile
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/user-profile'
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
  /v2/api/user-account/{user}/sessions:
    parameters:
      - name: user
        in: path
        required: true
        schema:
          type: string
          example: e@example.nl
    get:
      operationId: listSessions
      tags:
        - profile
      summary: List sessions
      description: |
        Retrieve a list of all active sessions of the user
      responses:
        '200':
          description: A list of the users session
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/session'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
    post:
      operationId: createSession
      tags:
        - profile
      summary: Create session
      description: |
        Start a new durable long term session. This can for example be used in a mobile app.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/session-2'
      responses:
        '201':
          description: The created session
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/session'
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
  /v2/api/user-account/{user}/sessions/{session}:
    parameters:
      - name: user
        in: path
        required: true
        schema:
          type: string
          example: e@example.nl
      - name: session
        in: path
        required: true
        schema:
          type: integer
          example: 123
    delete:
      operationId: revokeSession
      tags:
        - profile
      summary: Revoke session
      description: |
        Revoke a session. This will disable any future use of the session in any app.
      responses:
        '204':
          description: Confirmation the session is deleted
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
  /v2/api/user-account/{user}/2-factor:
    parameters:
      - name: user
        in: path
        required: true
        schema:
          type: string
          example: e@example.nl
    get:
      operationId: generateQrCode
      tags:
        - profile
      summary: Create QR code
      description: |
        Get the QR-code that can be used to active the 2-factor authentication.
      responses:
        '200':
          description: The content of the file
          content:
            '*/*':
              schema:
                type: string
                format: byte
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
    patch:
      operationId: patch2Factor
      tags:
        - profile
      summary: Update 2-factor
      description: |
        Enable or disable the 2-factor authentication  for the user.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/patch-multi-factor'
      responses:
        '204':
          description: Confirmation that the command was executed
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
  /v2/api/export:
    get:
      operationId: exportUserAccount
      tags:
        - export
      summary: Export profile
      description: |
        Create an export of all information that belongs to the authenticated user.
      responses:
        '200':
          description: The JSON of the export
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/export-profile'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
  /v2/api/export/transactions:
    get:
      operationId: exportTransactions
      tags:
        - export
      summary: Export transactions
      description: |
        Export transactions in CSV format.
      responses:
        '200':
          description: OK
          content:
            text/csv:
              schema:
                type: Writable
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
  /v2/api/import:
    post:
      operationId: importUserAccount
      tags:
        - import
      summary: Import profile
      description: |
        Import profile from external source.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/export-profile'
      responses:
        '204':
          description: Profile imported successfully.
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
  /v2/api/i18n/{languageCode}:
    get:
      security: []
      tags:
        - i18n
      summary: Get i18n
      operationId: getTranslations
      parameters:
        - name: languageCode
          in: path
          required: true
          schema:
            type: string
            example: en
      responses:
        '200':
          description: getTranslations 200 response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/i18n'
  /v2/api/currencies:
    get:
      operationId: getCurrencies
      tags:
        - currency
      summary: Search currencies
      responses:
        '200':
          description: The list of currencies
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/currency'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
    post:
      operationId: createCurrency
      tags:
        - currency
      summary: Create currency
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/currency-2'
      responses:
        '201':
          description: The created currency
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/currency'
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
  /v2/api/currencies/{currencyCode}:
    parameters:
      - name: currencyCode
        description: The currency code
        in: path
        required: true
        schema:
          type: string
          example: EUR
    get:
      operationId: getCurrencyByCode
      tags:
        - currency
      summary: Fetch currency
      responses:
        '200':
          description: The currency
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/currency'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
    put:
      operationId: updateCurrencyByCode
      tags:
        - currency
      summary: Update currency
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/currency-2'
      responses:
        '200':
          description: The updated currency
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/currency'
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
    patch:
      operationId: patchCurrencyByCode
      tags:
        - currency
      summary: Patch currency
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/currency-patch'
      responses:
        '200':
          description: The updated currency
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/currency'
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
  /v2/api/settings:
    get:
      operationId: getAllSettings
      tags:
        - settings
      security: []
      summary: Fetch settings
      responses:
        '200':
          description: The list of currencies
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/setting'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
  /v2/api/settings/{setting}:
    parameters:
      - name: setting
        description: The setting name
        in: path
        required: true
        schema:
          type: string
    patch:
      operationId: patchSetting
      tags:
        - settings
      summary: Update setting
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/setting-2'
      responses:
        '204':
          description: Confirmation the setting was updated
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
  /v2/api/files:
    post:
      operationId: uploadFile
      tags:
        - files
      summary: Create file
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                upload:
                  type: string
                  format: binary
        required: true
      responses:
        '201':
          description: The file code for the created file
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/file'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
  /v2/api/files/{fileCode}:
    parameters:
      - name: fileCode
        in: path
        required: true
        schema:
          type: string
    get:
      operationId: downloadFile
      tags:
        - files
      summary: Download file
      description: |
        Download an existing file from the system. If encryption is enabled this will throw an exception if the file was not uploaded by the user  downloading it.
      responses:
        '200':
          description: The content of the file
          content:
            '*/*':
              schema:
                type: string
                format: byte
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
    delete:
      operationId: deleteFile
      tags:
        - files
      summary: Delete file
      responses:
        '204':
          description: Confirmation the file was removed
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
  /v2/api/account-types:
    get:
      operationId: getAccountTypes
      tags:
        - system-information
      summary: Get account types
      description: |
        Get a listing of all available account types in the system.
      responses:
        '200':
          description: A list of all available account types
          content:
            application/json:
              schema:
                type: array
                items:
                  type: string
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
  /v2/api/accounts:
    get:
      operationId: getAccounts
      tags:
        - account-fetcher
      summary: Search accounts
      description: |
        List available accounts that the current user has access to
      parameters:
        - name: type
          description: The account type to filter on
          in: query
          schema:
            type: array
            items:
              type: string
        - $ref: '#/components/parameters/offset'
        - $ref: '#/components/parameters/number-of-results'
        - name: accountName
          in: query
          description: A partial name of an account to look for
          schema:
            type: string
      responses:
        '200':
          description: The list of accounts
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/accounts-paged'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
    post:
      operationId: createAccount
      tags:
        - account-command
      summary: Create account
      description: |
        Create a new account for the current user
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/account-2'
      responses:
        '201':
          description: The created account
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/account'
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
  /v2/api/accounts/top-by-spending:
    get:
      operationId: getTopAccountsBySpending
      tags:
        - account-fetcher
      summary: Top account by spending
      description: |
        Returns the top spending accounts for the current user within the optional date range. You can filter by account type or include only your own accounts using useOwnAccounts. The response is an array ordered by highest spending, each item providing account and amount details.
      parameters:
        - $ref: '#/components/parameters/startDate'
        - $ref: '#/components/parameters/endDate'
        - name: type
          description: Filter on the type of account. Must not be set when useOwnAccounts is provided.
          in: query
          schema:
            $ref: '#/components/schemas/account-type'
        - name: useOwnAccounts
          description: Filter on all of the users own accounts. If set the type filter will be ignored.
          in: query
          schema:
            type: boolean
      responses:
        '200':
          description: The list of top spending accounts
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/account-spending'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
  /v2/api/accounts/{id}:
    parameters:
      - name: id
        description: The identifier of the account
        in: path
        required: true
        schema:
          type: integer
          format: int64
          example: 1234567890
    get:
      operationId: getAccountById
      tags:
        - account-fetcher
      summary: Get account
      description: |
        Get account details by id for the current user
      responses:
        '200':
          description: The created account
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/account'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          description: Saving goal not found
    put:
      operationId: updateAccountById
      tags:
        - account-command
      summary: Update account
      description: |
        Update account details by id for the current user
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/account-2'
      responses:
        '200':
          description: The created account
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/account'
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          description: Saving goal not found
    delete:
      operationId: deleteAccountById
      tags:
        - account-command
      summary: Delete account
      description: |
        Delete account details by id for the current user
      responses:
        '204':
          description: Confirmation that the account was deleted
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
  /v2/api/accounts/{id}/saving-goals:
    parameters:
      - name: id
        description: The identifier of the account
        in: path
        required: true
        schema:
          type: integer
          format: int64
          example: 1234567890
    get:
      operationId: getSavingGoalsForAccount
      tags:
        - account-fetcher
      summary: List saving goals
      description: |
        Get the saving goals for the account, note this can only be called if the account type is SAVINGS.
      responses:
        '200':
          description: The list of saving goals
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/saving-goal'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
    post:
      operationId: createSavingGoalForAccount
      tags:
        - account-command
      summary: Create saving goal
      description: |
        Create a new saving goal for the account, note this can only be called if the account type is SAVINGS.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/saving-goal-2'
      responses:
        '201':
          description: The created saving goal
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/saving-goal'
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
  /v2/api/accounts/{id}/saving-goals/{goalId}:
    parameters:
      - name: id
        description: The identifier of the account
        in: path
        required: true
        schema:
          type: integer
          format: int64
          example: 1234567890
      - name: goalId
        description: The identifier of the saving goal
        in: path
        required: true
        schema:
          type: integer
          format: int64
          example: 1234567890
    put:
      operationId: updateSavingGoalForAccount
      tags:
        - account-command
      summary: Update saving goal
      description: |
        Update a saving goal for the account, note this can only be called if the account type is SAVINGS.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/saving-goal-2'
      responses:
        '200':
          description: The updated saving goal
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/saving-goal'
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
    delete:
      operationId: deleteSavingGoalForAccount
      tags:
        - account-command
      summary: Delete saving goal
      description: |
        Remove a saving goal for the account, note this can only be called if the account type is SAVINGS.
      responses:
        '204':
          description: Confirmation that the saving goal was deleted
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
  /v2/api/accounts/{id}/saving-goals/{goalId}/make-reservation:
    parameters:
      - name: id
        description: The identifier of the account
        in: path
        required: true
        schema:
          type: integer
          format: int64
          example: 1234567890
      - name: goalId
        description: The identifier of the saving goal
        in: path
        required: true
        schema:
          type: integer
          format: int64
          example: 1234567890
    post:
      operationId: makeReservationForSavingGoal
      tags:
        - account-command
      summary: Reserve money saving goal
      description: |
        Make a reservation for the saving goal, note this can only be called if the account type is SAVINGS.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/saving-goal-reservation'
      responses:
        '204':
          description: Confirmation that a reservation was added to the saving goal
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
  /v2/api/accounts/{id}/reconcile:
    parameters:
      - name: id
        description: The identifier of the account
        in: path
        required: true
        schema:
          type: integer
          format: int64
          example: 1234567890
    get:
      operationId: fetchAccountsReconcile
      tags:
        - account-fetcher
      responses:
        '200':
          description: |
            The list of pending reconciliations that the user started.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/account-reconciled'
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
    post:
      operationId: reconcileAccount
      tags:
        - account-command
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/account-reconcile'
      responses:
        '200':
          description: |
            Failed to reconcile the account. The previous year must be reconciled first.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/account-reconciled'
        '204':
          description: |
            The reconciliation was successful.
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
  /v2/api/contracts:
    get:
      operationId: findContractBy
      tags:
        - contract-fetcher
      summary: Search contracts
      description: |
        Retrieve contracts filtered by optional name and status (ACTIVE or INACTIVE). Returns a list of matching contracts for the current user.
      parameters:
        - $ref: '#/components/parameters/name'
        - name: status
          in: query
          schema:
            type: string
            enum:
              - ACTIVE
              - INACTIVE
      responses:
        '200':
          description: The contracts matching the filters
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/contract'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
    post:
      operationId: createContract
      tags:
        - contract-command
      summary: Create contract
      description: Create a new contract in the application.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/contract-2'
      responses:
        '201':
          description: The created contract
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/contract'
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
  /v2/api/contracts/{id}:
    parameters:
      - name: id
        description: The identifier of the contract
        in: path
        required: true
        schema:
          type: integer
          format: int64
          example: 1234567890
    get:
      operationId: getContractById
      tags:
        - contract-fetcher
      summary: Fetch contract
      description: Fetch a single contract by its unique identifier.
      responses:
        '200':
          description: The contract
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/contract'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
    put:
      operationId: updateContract
      tags:
        - contract-command
      summary: Update contract
      description: Update an existing contract in the application.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/contract-2'
      responses:
        '200':
          description: The updated category
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/contract'
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
    delete:
      operationId: deleteContractById
      tags:
        - contract-command
      summary: Delete contract
      description: Marks a contract that it is no longer relevant in the application.
      responses:
        '204':
          description: Confirmation that a contract was removed
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
  /v2/api/contracts/{id}/warn-before-expiration:
    parameters:
      - name: id
        description: The identifier of the contract
        in: path
        required: true
        schema:
          type: integer
          format: int64
          example: 123
    post:
      operationId: warnBeforeContractExpiry
      tags:
        - contract-command
      summary: Warn before end
      description: Send out a warning e-mail before the contract expiry date
      responses:
        '204':
          description: Confirmation that a contract was removed
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
  /v2/api/tags:
    get:
      operationId: findTagsBy
      tags:
        - tag-fetcher
      summary: Search tags
      description: |
        Return a list of tag names matching the optional name filter for the current user.
      parameters:
        - $ref: '#/components/parameters/name'
      responses:
        '200':
          description: The tags matching the filters
          content:
            application/json:
              schema:
                type: array
                items:
                  type: string
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
    post:
      operationId: createTag
      tags:
        - tag-command
      summary: Create tag
      description: |
        Create a new tag with the given name for the current user. Returns 204 on success.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
      responses:
        '204':
          description: Confirmation the tag was created
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
  /v2/api/tags/{tag}:
    parameters:
      - name: tag
        schema:
          type: string
        in: path
        required: true
    delete:
      operationId: deleteTag
      tags:
        - tag-command
      summary: Delete tag
      description: |
        Delete an existing tag by its name. Returns 204 on success; if the tag does not exist, a 404 may be returned.
      responses:
        '204':
          description: Confirmation the tag was deleted
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
  /v2/api/categories:
    get:
      operationId: findCategoriesBy
      tags:
        - category-fetcher
      summary: Search categories
      description: |
        Retrieve a paged list of categories that match the optional name filter. Use offset and number-of-results to paginate through the result set.
      parameters:
        - $ref: '#/components/parameters/name'
        - $ref: '#/components/parameters/offset'
        - $ref: '#/components/parameters/number-of-results'
      responses:
        '200':
          description: The categories matching the filters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/categories-paged'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
    post:
      operationId: createCategory
      tags:
        - category-command
      summary: Create category
      description: |
        Create a new category using the provided request body. Returns the created category with its generated identifier and details.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/category-2'
      responses:
        '201':
          description: The created category
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/category'
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
  /v2/api/categories/{id}:
    parameters:
      - name: id
        description: The identifier of the category
        in: path
        required: true
        schema:
          type: integer
          format: int64
          example: 1234567890
    get:
      operationId: getCategoryById
      tags:
        - category-fetcher
      summary: Fetch category
      description: |
        Retrieve a single category by its identifier. Returns the full category details if it exists and the user has access.
      responses:
        '200':
          description: The category
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/category'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
    put:
      operationId: updateCategory
      tags:
        - category-command
      summary: Update category
      description: |
        Update an existing category identified by its id using the provided request body. Returns the updated category details.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/category-2'
      responses:
        '200':
          description: The updated category
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/category'
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
    delete:
      operationId: deleteCategoryById
      tags:
        - category-command
      summary: Delete category
      description: |
        Delete a category by its identifier. On success, a 204 No Content is returned to confirm removal.
      responses:
        '204':
          description: Confirmation that a transaction was removed
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
  /v2/api/transactions:
    get:
      operationId: findTransactionBy
      tags:
        - transaction-fetcher
      summary: Search transactions
      description: |
        Search the current user's transactions using optional filters such as date range, account, budget/expense, category, contract, tags, description text, type, import id, and currency. Results are returned as a paged list that can be navigated with offset and number-of-results parameters.
      parameters:
        - $ref: '#/components/parameters/startDate'
        - $ref: '#/components/parameters/endDate'
        - $ref: '#/components/parameters/number-of-results'
        - $ref: '#/components/parameters/offset'
        - $ref: '#/components/parameters/accounts'
        - $ref: '#/components/parameters/expenses'
        - $ref: '#/components/parameters/categories'
        - $ref: '#/components/parameters/contracts'
        - $ref: '#/components/parameters/tags'
        - $ref: '#/components/parameters/import-id'
        - name: description
          in: query
          description: Filter on a part of the transaction description
          schema:
            type: string
        - name: type
          in: query
          description: Filter on the transaction type
          schema:
            type: string
            enum:
              - INCOME
              - EXPENSE
              - TRANSFER
        - name: currency
          in: query
          description: Filter based on the currency code
          schema:
            type: string
            minLength: 3
            maxLength: 3
            example: EUR
      responses:
        '200':
          description: The transactions matching the filters in a paged way
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/transaction-paged'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
    post:
      operationId: createTransaction
      tags:
        - transaction-command
      summary: Create transaction
      description: Create a new transaction in the system
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/transaction-2'
      responses:
        '201':
          description: The created transaction
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/transaction'
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
  /v2/api/transactions/{id}:
    parameters:
      - name: id
        description: The identifier of the transaction
        in: path
        required: true
        schema:
          type: integer
          format: int64
          example: 1234567890
    get:
      operationId: getTransactionById
      tags:
        - transaction-fetcher
      summary: Fetch transaction
      description: Fetch a single transaction from the system
      responses:
        '200':
          description: The matching transaction
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/transaction'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
    put:
      operationId: updateTransaction
      tags:
        - transaction-command
      summary: Update transaction
      description: Update a transaction in the system
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/transaction-2'
      responses:
        '200':
          description: The updated transaction
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/transaction'
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
    patch:
      operationId: splitTransaction
      tags:
        - transaction-command
      summary: Split transaction
      description: Provide the new split for the transaction
      requestBody:
        content:
          application/json:
            schema:
              type: array
              items:
                type: object
                properties:
                  description:
                    type: string
                  amount:
                    type: number
      responses:
        '200':
          description: The updated transaction
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/transaction'
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
    delete:
      operationId: deleteTransaction
      tags:
        - transaction-command
      summary: Delete transaction
      description: Remove a transaction from the system
      responses:
        '204':
          description: Confirmation that a transaction was removed
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
  /v2/api/schedules:
    get:
      operationId: findScheduleByFilter
      tags:
        - schedule-fetcher
      summary: Search schedules
      description: |
        List transaction schedules matching optional filters on account and contract. Returns all schedules the current user has access to.
      parameters:
        - name: account
          description: |
            Identifiers of accounts to filter for. Can be either a source or destination for the schedule.
          in: query
          schema:
            type: array
            items:
              type: integer
        - name: contract
          in: query
          description: |
            Identifiers of contracts to filter on.
          schema:
            type: array
            items:
              type: integer
      responses:
        '200':
          description: The list of schedules based upon the filters
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/transaction-schedule'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
    post:
      operationId: createSchedule
      tags:
        - schedule-command
      summary: Create schedule
      description: |
        Create a new transaction schedule using the provided request body. Returns the created schedule including its identifier and configuration.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/transaction-schedule-2'
      responses:
        '201':
          description: Confirmation the schedule was created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/transaction-schedule'
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
  /v2/api/schedules/{id}:
    parameters:
      - name: id
        description: The identifier of the schedule
        in: path
        required: true
        schema:
          type: integer
          format: int64
          example: 123
    get:
      operationId: findScheduleById
      tags:
        - schedule-fetcher
      summary: Fetch schedule
      description: |
        Retrieve a single transaction schedule by its identifier. Returns full details of the schedule if found.
      responses:
        '200':
          description: The schedule
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/transaction-schedule'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
    patch:
      operationId: updateSchedule
      tags:
        - schedule-command
      summary: Update schedule
      description: |
        Partially update an existing transaction schedule using the provided patch request. Returns the updated schedule.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/transaction-schedule-patch'
      responses:
        '200':
          description: The updated schedule
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/transaction-schedule'
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
    delete:
      operationId: deleteSchedule
      tags:
        - schedule-command
      summary: Delete schedule
      description: |
        Delete a transaction schedule by its identifier. Returns 204 on successful deletion.
      responses:
        '204':
          description: Confirmation the schedule was deleted
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
  /v2/api/budgets:
    get:
      operationId: findByFilter
      tags:
        - budget-fetcher
      summary: Search budgets
      description: |
        Retrieve budget periods for the authenticated user. You can filter by year and/or month. When firstOnly is true, only the first matching budget period is returned.
      parameters:
        - name: year
          required: false
          description: The year to get the budget for
          in: query
          schema:
            type: int
        - name: month
          required: false
          description: The month to get the budget for
          in: query
          schema:
            type: int
            min: 1
            max: 12
        - name: firstOnly
          description: If true, only the first budget will be returned.
          in: query
          schema:
            type: boolean
      responses:
        '200':
          description: The list of matching budget periods
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/budget'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
    post:
      operationId: createInitialBudget
      tags:
        - budget-command
      summary: Create budget
      description: |
        Create the initial budget for the current user. This can only be called once if no budget exists for the current user.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/budget-2'
      responses:
        '201':
          description: The created budget
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/budget'
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
    patch:
      operationId: updateCurrentBudget
      tags:
        - budget-command
      summary: Update budget
      description: |
        Update the current budget for the current user. This operation will also index all expenses based upon the difference between the previous expected income and the new expected income.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/budget-2'
      responses:
        '200':
          description: The created budget
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/budget'
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
  /v2/api/budgets/expenses:
    get:
      operationId: findExpensesByFilter
      tags:
        - budget-fetcher
      summary: Search expenses
      description: |
        Search expenses within the currently active budget for the authenticated user. You can provide a partial name to filter the results. Returns the matching expenses.
      parameters:
        - name: name
          description: Filter expenses based upon the partial name
          in: query
          schema:
            type: string
      responses:
        '200':
          description: The found expenses
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/expense'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
    patch:
      operationId: updateExpense
      tags:
        - budget-command
      summary: Update expense
      description: |
        Create or update an expense under the current active budget.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/expense-2'
      responses:
        '200':
          description: The updated budget
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/budget'
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
  /v2/api/budgets/expenses/balance:
    get:
      operationId: computeBudgetExpenseBalance
      tags:
        - budget-fetcher
      summary: Compute expense balance
      description: |
        Compute the budget-vs-spending balance for one month of the authenticated user. Provide year and month to select the period. Optionally pass one or more expenseId values to limit the calculation to specific expenses. Returns the computed balance per expense for the selected period.
      parameters:
        - name: year
          required: true
          description: The year to get the budget for
          in: query
          schema:
            type: int
        - name: month
          required: true
          description: The month to get the budget for
          in: query
          schema:
            type: int
            min: 1
            max: 12
        - name: expenseId
          description: Optional list of expense identifiers to filter on
          in: query
          schema:
            type: array
            items:
              type: integer
              format: int64
      responses:
        '200':
          description: The current balance
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/expense-computed'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
  /v2/api/balance:
    post:
      operationId: computeBalanceWithFilter
      tags:
        - statistics-balance
      summary: Compute balance
      description: |
        Computes a balance for the user based on the filters applied.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/balance'
      responses:
        '200':
          description: The balance for the given filters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/balance-2'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
  /v2/api/balance/{partition}:
    parameters:
      - name: partition
        in: path
        required: true
        schema:
          type: string
          enum:
            - account
            - budget
            - category
    post:
      operationId: computePartitionedBalanceWithFilter
      tags:
        - statistics-balance
      summary: Compute partitioned balance
      description: |
        Computes a balance for the user based on the filters applied.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/balance'
      responses:
        '200':
          description: The balance for the given filters
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/balance-partitioned'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
  /v2/api/balance/by-date/{type}:
    parameters:
      - name: type
        in: path
        required: true
        schema:
          type: string
          enum:
            - daily
            - monthly
    post:
      operationId: computeBalanceGroupedByDate
      tags:
        - statistics-balance
      summary: Compute date partitioned balance
      description: |
        Computes the balance grouping it by date as indicated in the `type`.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/balance'
      responses:
        '200':
          description: The balance for the given filters
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/balance-dated'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
  /v2/api/detected/insight:
    get:
      operationId: getInsightsByFilters
      tags:
        - insight
      summary: Fetch insights
      description: |
        Retrieve detected financial insights for a given year and optional month. Returns an array of insights for the current user.
      parameters:
        - name: year
          in: query
          schema:
            type: integer
            min: 1990
            max: 9999
        - name: month
          in: query
          schema:
            type: integer
            min: 1
            max: 12
      responses:
        '200':
          description: The list of detected insights
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/detected-insight'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
  /v2/api/detected/pattern:
    get:
      operationId: getPatternsByFilters
      tags:
        - insight
      summary: Fetch patterns
      description: |
        Retrieve detected spending patterns for a given year and optional month. Returns an array of patterns for the current user.
      parameters:
        - name: year
          in: query
          schema:
            type: integer
            min: 1990
            max: 9999
        - name: month
          in: query
          schema:
            type: integer
            min: 1
            max: 12
      responses:
        '200':
          description: The list of detected patterns
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/detected-pattern'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
  /v2/api/batch-importer:
    get:
      operationId: getJobsByFilters
      tags:
        - batch-importer
      summary: Search import jobs
      parameters:
        - $ref: '#/components/parameters/number-of-results'
        - $ref: '#/components/parameters/offset'
      responses:
        '200':
          description: The batch jobs that were executed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/batch-job-paged'
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
    post:
      operationId: createJob
      tags:
        - batch-importer
      summary: Create import job
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                configuration:
                  type: string
                fileToken:
                  type: string
      responses:
        '201':
          description: The created batch job
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/batch-job'
        '400':
          $ref: '#/components/responses/400-response'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
  /v2/api/batch-importer/{slug}:
    parameters:
      - name: slug
        required: true
        in: path
        description: The unique identifier
        schema:
          type: string
    get:
      operationId: getJobBySlug
      tags:
        - batch-importer
      summary: Get import job
      responses:
        '200':
          description: The batch job
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/batch-job'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
    delete:
      operationId: deleteJobBySlug
      tags:
        - batch-importer
      summary: Delete import job
      responses:
        '204':
          description: Confirmation that the batch job was deleted
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
  /v2/api/batch-importer/{slug}/tasks:
    parameters:
      - name: slug
        required: true
        in: path
        description: The unique identifier
        schema:
          type: string
    get:
      operationId: getTasks
      tags:
        - batch-task-engine
      summary: Search tasks for process
      responses:
        '200':
          description: A list of tasks for the process instance
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/task'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
    post:
      operationId: completeTask
      tags:
        - batch-task-engine
      summary: Complete task
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - name
                - variables
              properties:
                name:
                  type: string
                variables:
                  $ref: '#/components/schemas/process-variable'
      responses:
        '204':
          description: A confirmation that task was completed
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/403-response'
  /v2/api/batch-importer-config:
    get:
      operationId: getConfigurations
      tags:
        - batch-importer
      summary: Search configuration
      responses:
        '200':
          description: A list of all available configurations
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/batch-configuration'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
    post:
      operationId: createConfiguration
      tags:
        - batch-importer
      summary: Create configuration
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - name
                - type
                - fileCode
              properties:
                name:
                  type: string
                  description: The name of the configuration
                type:
                  type: string
                  description: The type of importer that will be used
                fileCode:
                  type: string
                  description: The file code to get the contents of the configuration
      responses:
        '201':
          description: THe created configuration
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/batch-configuration'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
  /v2/api/transaction-rules:
    get:
      operationId: fetchRuleGroups
      tags:
        - learning-rule-fetcher
      summary: Fetch rule groups
      responses:
        '200':
          description: The list of rule groups
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/transaction-rule-group'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
    post:
      operationId: createRuleGroup
      tags:
        - learning-rule-command
      summary: Create rule group
      requestBody:
        description: |
          The request body for creating a new rule group.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/transaction-rule-group'
      responses:
        '204':
          description: Confirmation that the group was created.
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
  /v2/api/transaction-rules/{group}:
    parameters:
      - name: group
        required: true
        in: path
        description: The name of the group
        schema:
          type: string
    get:
      operationId: fetchRulesByGroup
      tags:
        - learning-rule-fetcher
      summary: Fetch rules by group
      responses:
        '200':
          description: The list of rule groups
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/transaction-rule'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
    delete:
      operationId: deleteRuleGroup
      tags:
        - learning-rule-command
      summary: Delete rule group
      responses:
        '204':
          description: Confirmation that the group was deleted.
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
    patch:
      operationId: updateRuleGroup
      tags:
        - learning-rule-command
      summary: Update rule group
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/transaction-rule-group-patch'
      responses:
        '204':
          description: Confirmation that the group was deleted.
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
    post:
      operationId: createRule
      tags:
        - learning-rule-command
      summary: Create rule
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/transaction-rule-2'
      responses:
        '201':
          description: The created rule
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/transaction-rule'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
  /v2/api/transaction-rules/{group}/{ruleId}:
    parameters:
      - name: group
        required: true
        in: path
        description: The name of the group
        schema:
          type: string
      - name: ruleId
        required: true
        in: path
        description: The name of the group
        schema:
          type: integer
          format: int64
    get:
      operationId: fetchRule
      tags:
        - learning-rule-fetcher
      summary: Fetch rule
      responses:
        '200':
          description: The rule
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/transaction-rule'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
    put:
      operationId: updateRule
      tags:
        - learning-rule-command
      summary: Update rule
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/transaction-rule-2'
      responses:
        '200':
          description: The updated rule
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/transaction-rule'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
    patch:
      operationId: patchRule
      tags:
        - learning-rule-command
      summary: Patch rule
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - move
              properties:
                move:
                  type: string
                  enum:
                    - UP
                    - DOWN
      responses:
        '204':
          description: The rule was patched
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
    delete:
      operationId: deleteRule
      tags:
        - learning-rule-command
      summary: Delete rule
      responses:
        '204':
          description: The rule was deleted
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
        '404':
          $ref: '#/components/responses/404-response'
  /v2/api/ai/auto-complete:
    get:
      operationId: suggestClassifications
      tags:
        - learning-rule-applier
      summary: Classify transaction
      parameters:
        - name: amount
          required: false
          in: query
          schema:
            type: number
            format: double
        - name: description
          required: false
          in: query
          schema:
            type: string
        - name: source
          required: false
          in: query
          schema:
            type: string
        - name: destination
          required: false
          in: query
          schema:
            type: string
      responses:
        '200':
          description: The suggestions made by Pledger.io
          content:
            application/json:
              schema:
                type: object
                properties:
                  budget:
                    type: string
                  category:
                    type: string
                  tags:
                    type: array
                    items:
                      type: string
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
  /v2/api/ai/extract:
    post:
      operationId: extractTransaction
      tags:
        - transaction-extractor
      summary: Extract transaction
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                text:
                  type: string
      responses:
        '200':
          description: The extracted transaction
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/extracted-transaction'
        '401':
          $ref: '#/components/responses/401-response'
        '403':
          $ref: '#/components/responses/403-response'
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
  responses:
    '400':
      $ref: '#/components/responses/400-response'
    '401':
      $ref: '#/components/responses/401-response'
    '403':
      $ref: '#/components/responses/403-response'
    '404':
      $ref: '#/components/responses/404-response'
    400-response:
      description: Bad Request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/json-error-response'
    401-response:
      description: Not authenticated
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/json-error-response'
    403-response:
      description: Not authorized for resource
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/json-error-response'
    404-response:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/json-error-response'
  parameters:
    offset:
      name: offset
      description: The number of rows to skip in the result set
      in: query
      required: true
      schema:
        type: integer
    number-of-results:
      name: numberOfResults
      description: The number of accounts to be returned
      in: query
      required: true
      schema:
        type: integer
    start-date:
      $ref: '#/components/parameters/startDate'
    end-date:
      $ref: '#/components/parameters/endDate'
    name-filter:
      $ref: '#/components/parameters/name'
    account-filter:
      $ref: '#/components/parameters/accounts'
    expense-filter:
      $ref: '#/components/parameters/expenses'
    category-filter:
      $ref: '#/components/parameters/categories'
    contract-filter:
      $ref: '#/components/parameters/contracts'
    tag-filter:
      $ref: '#/components/parameters/tags'
    import-slug-filter:
      $ref: '#/components/parameters/import-id'
    startDate:
      name: startDate
      required: true
      in: query
      schema:
        type: string
        format: date
    endDate:
      name: endDate
      required: true
      in: query
      schema:
        type: string
        format: date
    name:
      name: name
      description: Filter based on a partial name
      in: query
      schema:
        type: string
    accounts:
      name: account
      in: query
      schema:
        type: array
        items:
          type: integer
          format: int64
          example: 12
    expenses:
      name: category
      in: query
      schema:
        type: array
        items:
          type: integer
          format: int64
          example: 12
    categories:
      name: expense
      in: query
      schema:
        type: array
        items:
          type: integer
          format: int64
          example: 12
    contracts:
      name: contract
      in: query
      schema:
        type: array
        items:
          type: integer
          format: int64
          example: 12
    tags:
      name: tag
      required: false
      in: query
      schema:
        type: array
        items:
          type: string
          example: groceries
    import-id:
      name: importSlug
      required: false
      in: query
      schema:
        type: integer
        format: int64
  schemas:
    date-range:
      type: object
      required:
        - startDate
        - endDate
      properties:
        startDate:
          type: string
          format: date
        endDate:
          type: string
          format: date
    periodicity:
      type: string
      description: The interval the interest is calculated on
      example: MONTHS
      enum:
        - MONTHS
        - WEEKS
        - YEARS
    account-link:
      type: object
      required:
        - id
        - name
        - type
      properties:
        id:
          type: integer
          description: The identifier of the account
          format: int64
          example: 3212
        name:
          type: string
          description: The account name, is unique for the user
          example: Fast food & co
        type:
          type: string
          description: The type of account, as defined by the account type API
          example: creditor
    paged-response:
      type: object
      required:
        - info
      properties:
        info:
          type: object
          required:
            - pageSize
            - pages
            - records
          properties:
            records:
              type: integer
              description: The total amount of matches
              format: int64
              example: 20
            pages:
              type: integer
              description: The amount of pages available
              format: int32
              example: 2
            pageSize:
              type: integer
              description: The amount of matches per page
              format: int32
              example: 15
    account-type:
      type: string
      enum:
        - creditor
        - debit
    rule-column:
      type: string
      enum:
        - SOURCE_ACCOUNT
        - TO_ACCOUNT
        - DESCRIPTION
        - AMOUNT
        - CATEGORY
        - CHANGE_TRANSFER_TO
        - CHANGE_TRANSFER_FROM
        - BUDGET
        - CONTRACT
        - TAGS
    operation-type:
      type: string
      enum:
        - EQUALS
        - CONTAINS
        - STARTS_WITH
        - LESS_THAN
        - MORE_THAN
    user-request:
      $ref: '#/components/schemas/user'
    token-request:
      $ref: '#/components/schemas/token'
    session-request:
      $ref: '#/components/schemas/session-2'
    patch-multi-factor-request:
      $ref: '#/components/schemas/patch-multi-factor'
    currency-request:
      $ref: '#/components/schemas/currency-2'
    currency-patch-request:
      $ref: '#/components/schemas/currency-patch'
    setting-request:
      $ref: '#/components/schemas/setting-2'
    account-request:
      $ref: '#/components/schemas/account-2'
    account-reconcile-request:
      $ref: '#/components/schemas/account-reconcile'
    saving-goal-request:
      $ref: '#/components/schemas/saving-goal-2'
    saving-reservation-request:
      $ref: '#/components/schemas/saving-goal-reservation'
    contract-request:
      $ref: '#/components/schemas/contract-2'
    category-request:
      $ref: '#/components/schemas/category-2'
    transaction-request:
      $ref: '#/components/schemas/transaction-2'
    transaction-schedule-request:
      $ref: '#/components/schemas/transaction-schedule-2'
    transaction-schedule-patch-request:
      $ref: '#/components/schemas/transaction-schedule-patch'
    budget-request:
      $ref: '#/components/schemas/budget-2'
    expense-request:
      $ref: '#/components/schemas/expense-2'
    balance-request:
      $ref: '#/components/schemas/balance'
    rule-request:
      $ref: '#/components/schemas/transaction-rule-2'
    rule-group-patch-request:
      $ref: '#/components/schemas/transaction-rule-group-patch'
    user-profile-response:
      $ref: '#/components/schemas/user-profile'
    export-profile-response:
      $ref: '#/components/schemas/export-profile'
    session-response:
      $ref: '#/components/schemas/session'
    i18n-response:
      $ref: '#/components/schemas/i18n'
    currency-response:
      $ref: '#/components/schemas/currency'
    setting-response:
      $ref: '#/components/schemas/setting'
    file-response:
      $ref: '#/components/schemas/file'
    account-response:
      $ref: '#/components/schemas/account'
    account-paged-response:
      $ref: '#/components/schemas/accounts-paged'
    account-spending-response:
      $ref: '#/components/schemas/account-spending'
    account-reconcile-response:
      $ref: '#/components/schemas/account-reconciled'
    saving-goal-response:
      $ref: '#/components/schemas/saving-goal'
    schedule-response:
      $ref: '#/components/schemas/schedule'
    contract-response:
      $ref: '#/components/schemas/contract'
    category-response:
      $ref: '#/components/schemas/category'
    category-paged-response:
      $ref: '#/components/schemas/categories-paged'
    transaction-response:
      $ref: '#/components/schemas/transaction'
    transaction-paged-response:
      $ref: '#/components/schemas/transaction-paged'
    transaction-schedule-response:
      $ref: '#/components/schemas/transaction-schedule'
    extracted-transaction-response:
      $ref: '#/components/schemas/extracted-transaction'
    budget-response:
      $ref: '#/components/schemas/budget'
    expense-response:
      $ref: '#/components/schemas/expense'
    expense-computed-response:
      $ref: '#/components/schemas/expense-computed'
    balance-response:
      $ref: '#/components/schemas/balance-2'
    balance-partitioned-response:
      $ref: '#/components/schemas/balance-partitioned'
    balance-dated-response:
      $ref: '#/components/schemas/balance-dated'
    detected-insight-response:
      $ref: '#/components/schemas/detected-insight'
    detected-pattern-response:
      $ref: '#/components/schemas/detected-pattern'
    batch-job-response:
      $ref: '#/components/schemas/batch-job'
    batch-job-paged-response:
      $ref: '#/components/schemas/batch-job-paged'
    batch-configuration-response:
      $ref: '#/components/schemas/batch-configuration'
    rule-response:
      $ref: '#/components/schemas/transaction-rule'
    rule-group-response:
      $ref: '#/components/schemas/transaction-rule-group'
    task-response:
      $ref: '#/components/schemas/task'
    enable-mfa-request:
      type: object
      required:
        - action
        - verificationCode
      properties:
        verificationCode:
          type: string
          min: 4
          max: 8
        action:
          type: string
    disable-mfa-request:
      type: object
      required:
        - action
      properties:
        action:
          type: string
    json-error-response:
      type: object
      description: Standard error response payload
      properties:
        message:
          type: string
        status:
          type: integer
      additionalProperties: true
    process-variable:
      type: object
      description: Key-value variables for batch import task completion
      additionalProperties: true
    open-id-configuration:
      type: object
      required:
        - authority
        - client-id
        - client-secret
      properties:
        authority:
          type: string
        client-id:
          type: string
        client-secret:
          type: string
    user:
      type: object
      properties:
        username:
          type: string
          example: me@example.org
        password:
          type: string
          example: this.password.is.to.simple
    token:
      type: object
      required:
        - verificationCode
      properties:
        verificationCode:
          maxLength: 8
          minLength: 4
          pattern: '[\d]{6}'
          type: string
          description: The 2-factor verification code from a hardware device.
    user-profile:
      type: object
      required:
        - theme
        - currency
        - mfa
      properties:
        theme:
          type: string
          description: The theme to use for the user interface.
          example: light
        currency:
          type: string
          description: The default currency to use for the user interface.
          example: EUR
          min: 3
          max: 3
        profilePicture:
          type: string
        mfa:
          type: boolean
          description: Whether the user has enabled 2-factor authentication.
          example: true
    session:
      type: object
      properties:
        id:
          type: integer
          description: The unique identifier for the session
        description:
          type: string
          description: The description of the session
        token:
          type: string
          description: The long lived token that can be used for this session
        valid:
          $ref: '#/components/schemas/date-range'
    session-2:
      type: object
      required:
        - description
        - expires
      properties:
        description:
          type: string
          minLength: 8
          description: The description for the session that is created
        expires:
          type: string
          format: date
          description: The date on which the long lived token should expire
    patch-multi-factor:
      discriminator:
        propertyName: action
        mapping:
          ENABLE: '#/components/schemas/enable-mfa-request'
          DISABLE: '#/components/schemas/disable-mfa-request'
      oneOf:
        - $ref: '#/components/schemas/enable-mfa-request'
        - $ref: '#/components/schemas/disable-mfa-request'
    account:
      type: object
      description: A bank account for the user
      required:
        - account
        - id
        - name
        - type
      allOf:
        - $ref: '#/components/schemas/account-link'
        - type: object
          properties:
            description:
              type: string
              description: The description for the account
            iconFileCode:
              type: string
              description: The file code for the image of the account
            account:
              type: object
              description: Bank identification numbers for the account
              properties:
                iban:
                  type: string
                bic:
                  type: string
                number:
                  type: string
                currency:
                  type: string
            interest:
              description: |
                The interest information for the account, only used for loans, debts and mortgage
              type: object
              required:
                - periodicity
                - interest
              properties:
                periodicity:
                  description: The interval the interest is calculated on
                  $ref: '#/components/schemas/periodicity'
                interest:
                  type: number
                  description: The amount of interest that is owed
                  format: double
                  example: 0.0754
            history:
              type: object
              description: Transaction history information for the account
              required:
                - firstTransaction
                - lastTransaction
              properties:
                firstTransaction:
                  type: string
                  description: The date of the first recorded transaction for the account
                  format: date
                lastTransaction:
                  type: string
                  description: The date of the latest recorded transaction for the account
                  format: date
    category:
      type: object
      required:
        - id
        - label
      properties:
        id:
          type: integer
          format: int64
          description: The unique identifier for the category
        name:
          type: string
          description: The name for the category
        description:
          type: string
          description: The description for the category
        lastUsed:
          type: string
          format: date
          description: The last date the category was used
    contract:
      type: object
      required:
        - id
        - name
        - company
        - start
        - end
      properties:
        id:
          type: integer
          description: The identifier of the contract
          format: int64
        name:
          type: string
          description: The name of the contract
          example: Cable company
        description:
          type: string
          description: The description for the contract
        contractAvailable:
          type: boolean
          description: Indicator for an digital copy of the contract being present
        fileToken:
          type: string
          description: The file token to get the digital copy
        start:
          type: string
          description: The start date of the contract
          format: date
        end:
          type: string
          description: The end date of the contract
          format: date
        terminated:
          type: boolean
          description: Indicator that the contract has ended and is closed by the user
        notification:
          type: boolean
          description: Indicator if a pre-emptive warning is active before the contract end date
        company:
          description: The company / account the contract is with
          allOf:
            - $ref: '#/components/schemas/account-link'
    schedule:
      type: object
      description: The schedule that allocations are created automatically
      required:
        - interval
        - periodicity
      properties:
        periodicity:
          description: The type of the interval
          example: MONTHS
          allOf:
            - $ref: '#/components/schemas/periodicity'
        interval:
          type: integer
          description: The actual interval
          format: int32
          example: 3
    transaction-schedule:
      type: object
      properties:
        id:
          type: integer
          format: int64
        name:
          type: string
          description: The name for the transaction schedule
        description:
          type: string
          description: The description for the transaction schedule
        activeBetween:
          $ref: '#/components/schemas/date-range'
        schedule:
          $ref: '#/components/schemas/schedule'
        amount:
          type: number
          format: double
        forContract:
          $ref: '#/components/schemas/contract'
        transferBetween:
          type: object
          description: The source and destination accounts for the transfer
          required:
            - source
            - destination
          properties:
            source:
              $ref: '#/components/schemas/account-link'
            destination:
              $ref: '#/components/schemas/account-link'
    transaction:
      type: object
      description: A transaction representing a transfer of money between two accounts
      properties:
        id:
          type: integer
          description: The identifier of this transaction
          format: int64
          example: 1
        description:
          type: string
          description: The description of the transaction
          example: Purchase of flowers
        currency:
          type: string
          description: The currency the transaction was in
          example: EUR
        amount:
          type: number
          description: The amount of money transferred from one account into the other
          format: double
          example: 30.5
        metadata:
          description: The meta-information of the transaction
          type: object
          properties:
            category:
              type: string
              description: The category this transaction was linked to
              example: Food related expenses
            budget:
              type: string
              description: The budget expense this transaction contributes to
              example: Dining out
            contract:
              type: string
              description: This transaction is part of this contract
              example: Weekly dining
            import:
              type: string
              description: The import job that created the transaction
              example: 0b9b79faddd9ad388f3aa3b59048b7cd
            tags:
              type: array
              description: The tags that the transaction has
              example:
                - food
                - dining
              items:
                type: string
        type:
          type: string
          description: The type of transaction
          enum:
            - CREDIT
            - DEBIT
            - TRANSFER
        dates:
          description: All dates relevant for this transaction
          type: object
          properties:
            transaction:
              type: string
              description: The date this transaction was created
              format: date
            booked:
              type: string
              description: The date the transaction was recorded into the books
              format: date
            interest:
              type: string
              description: The date from which the transaction gets interest applied
              format: date
        destination:
          description: The account where the money went to
          allOf:
            - $ref: '#/components/schemas/account-link'
        source:
          description: The account where the money came from
          allOf:
            - $ref: '#/components/schemas/account-link'
        split:
          type: array
          description: 'The multi-line split of the transaction, eg: purchased items'
          items:
            type: object
            required:
              - description
              - amount
            properties:
              description:
                type: string
              amount:
                type: number
                format: double
    transaction-rule-group:
      type: object
      required:
        - name
        - sort
      properties:
        sort:
          type: integer
          format: int32
        name:
          type: string
    transaction-rule:
      type: object
      required:
        - id
        - name
        - active
        - restrictive
        - sort
      properties:
        id:
          type: integer
          format: int64
        name:
          type: string
        description:
          type: string
        active:
          type: boolean
        restrictive:
          type: boolean
        sort:
          type: integer
          format: int32
        changes:
          type: array
          items:
            type: object
            required:
              - id
              - field
              - change
            properties:
              id:
                type: integer
                format: int64
              field:
                $ref: '#/components/schemas/rule-column'
              change:
                type: string
        conditions:
          type: array
          items:
            type: object
            required:
              - id
              - field
              - operation
              - condition
            properties:
              id:
                type: integer
                format: int64
              field:
                $ref: '#/components/schemas/rule-column'
              operation:
                $ref: '#/components/schemas/operation-type'
              condition:
                type: string
    export-profile:
      type: object
      properties:
        accounts:
          type: array
          items:
            allOf:
              - $ref: '#/components/schemas/account'
              - type: object
                properties:
                  icon:
                    type: string
                    description: The icon of the account, in a base64 encoded string
        categories:
          type: array
          items:
            $ref: '#/components/schemas/category'
        budget:
          type: array
          items:
            type: object
            required:
              - income
              - period
              - expenses
            properties:
              income:
                type: number
                format: double
              period:
                $ref: '#/components/schemas/date-range'
              expenses:
                type: array
                items:
                  type: object
                  required:
                    - id
                    - name
                    - expected
                  properties:
                    id:
                      type: integer
                      format: int64
                    name:
                      type: string
                    expected:
                      type: number
        contract:
          type: array
          items:
            allOf:
              - $ref: '#/components/schemas/contract'
              - type: object
                properties:
                  contract:
                    type: string
                    description: The HEX encoded attached contract file
        tags:
          type: array
          items:
            type: string
        schedules:
          type: array
          items:
            allOf:
              - $ref: '#/components/schemas/transaction-schedule'
              - type: object
                properties:
                  lastRun:
                    type: string
                    format: date
                  nextRun:
                    type: string
                    format: date
        transaction:
          type: array
          items:
            $ref: '#/components/schemas/transaction'
        ruleGroups:
          type: array
          items:
            allOf:
              - $ref: '#/components/schemas/transaction-rule-group'
              - type: object
                properties:
                  rules:
                    type: array
                    items:
                      $ref: '#/components/schemas/transaction-rule'
    i18n:
      type: object
      example:
        common.hello: Hello
        common.test: Test
      additionalProperties:
        type: string
    currency:
      type: object
      required:
        - name
        - code
        - symbol
        - decimalPlaces
        - enabled
      properties:
        name:
          type: string
        code:
          type: string
          max: 3
          min: 3
        symbol:
          type: string
          max: 1
          min: 1
        decimalPlaces:
          type: integer
          minimum: 0
          maximum: 10
        enabled:
          type: boolean
    currency-2:
      type: object
      required:
        - name
        - code
        - symbol
      properties:
        name:
          type: string
        code:
          type: string
          min: 3
          max: 3
        symbol:
          type: string
          minLength: 1
          maxLength: 1
    currency-patch:
      type: object
      properties:
        decimalPlaces:
          type: integer
          minimum: 0
          maximum: 10
        enabled:
          type: boolean
    setting:
      type: object
      required:
        - name
        - value
        - type
      properties:
        name:
          type: string
        value:
          type: object
        type:
          type: string
          enum:
            - STRING
            - NUMBER
            - FLAG
            - DATE
    setting-2:
      type: object
      required:
        - value
      properties:
        value:
          type: object
    file:
      type: object
      required:
        - fileCode
      properties:
        fileCode:
          type: string
    accounts-paged:
      allOf:
        - $ref: '#/components/schemas/paged-response'
        - type: object
          required:
            - content
          properties:
            content:
              type: array
              items:
                $ref: '#/components/schemas/account'
    account-2:
      type: object
      required:
        - name
        - currency
        - type
      properties:
        name:
          minLength: 1
          type: string
          description: Account name
        description:
          type: string
          description: Account description
          minLength: 1
        currency:
          type: string
          description: |
            Currency code of the account.  This currency code must already exist in the system.
          minLength: 3
          maxLength: 3
        iban:
          pattern: |
            ^([A-Z]{2}[ \\-]?[0-9]{2})(?=(?:[ \\-]?[A-Z0-9]){9,30}$)((?:[\\-]?[A-Z0-9]{3,5}){2,7})([ \\-]?[A-Z0-9]{1,3})?$
          type: string
          description: IBAN number
        bic:
          pattern: ^([a-zA-Z]{4}[a-zA-Z]{2}[a-zA-Z0-9]{2}([a-zA-Z0-9]{3})?)$
          type: string
          description: The banks BIC number
        number:
          type: string
          description: The account number, in case IBAN is not applicable
        interest:
          maximum: 1
          minimum: 0
          type: number
          format: double
        interestPeriodicity:
          $ref: '#/components/schemas/periodicity'
        type:
          description: The type of the account, as defined by the account type API
          type: string
        imageIcon:
          description: The file code for the image of the account
          type: string
    account-spending:
      type: object
      description: The spending for a specific account
      required:
        - account
        - total
        - average
      properties:
        account:
          $ref: '#/components/schemas/account'
        total:
          type: number
          format: double
        average:
          type: number
          format: double
    saving-goal:
      type: object
      required:
        - goal
        - id
        - reserved
        - targetDate
      properties:
        id:
          type: integer
          description: The identifier of the saving goal
          format: int64
          example: 132
        name:
          type: string
          description: The name of the saving goal
          example: Car replacement
        description:
          type: string
          description: The description of the saving goal
        schedule:
          description: The schedule that allocations are created automatically
          $ref: '#/components/schemas/schedule'
        goal:
          type: number
          description: The goal one wishes to achieve by the end date
          example: 1500.4
        reserved:
          type: number
          description: The amount of money reserved for this saving goal
          example: 200
        installments:
          type: number
          description: |
            The amount of money allocated each interval, only when schedule is set
          example: 25.5
        targetDate:
          type: string
          description: The date before which the goal must be met
          format: date
          example: '2021-01-12'
        monthsLeft:
          type: integer
          description: The amount of months left until the target date
          format: int64
          example: 23
    saving-goal-2:
      type: object
      required:
        - goal
        - name
        - targetDate
      properties:
        name:
          minLength: 1
          type: string
        goal:
          minimum: 0
          exclusiveMinimum: true
          type: number
        targetDate:
          type: string
          format: date
    saving-goal-reservation:
      type: object
      description: A saving reservation for a specific amount
      required:
        - amount
      properties:
        amount:
          type: number
          format: double
    account-reconciled:
      type: object
      description: The response for an account reconciliation
      required:
        - period
        - balance
        - computed
      properties:
        period:
          type: integer
          format: int32
          description: The year to reconcile this account for
        balance:
          type: object
          description: The balance for the period
          required:
            - start
            - end
          properties:
            start:
              type: number
              description: The starting balance on the start date of the period
              format: double
              example: 30.5
            end:
              type: number
              description: The ending balance on the end date of the period
              format: double
              example: 35.7
        computed:
          type: object
          description: The computed balance for the period
          required:
            - start
          properties:
            start:
              type: number
              description: The current opening balance computed from the previous year
              format: double
              example: 30.5
    account-reconcile:
      type: object
      description: The request to reconcile an account
      required:
        - period
        - balance
      properties:
        period:
          type: integer
          format: int32
          description: The year to reconcile this account for
        balance:
          type: object
          description: The balance for the period
          required:
            - start
            - end
          properties:
            start:
              type: number
              description: The starting balance on the start date of the period
              format: double
              example: 30.5
            end:
              type: number
              description: The ending balance on the end date of the period
              format: double
              example: 35.7
    contract-2:
      type: object
      properties:
        name:
          minLength: 1
          type: string
          description: The name of the contract.
          example: Contract 1
        description:
          type: string
          description: The description of the contract.
          example: Contract 1 description
        company:
          description: The company the contract is with.
          allOf:
            - $ref: '#/components/schemas/account-link'
        start:
          type: string
          description: The start date of the contract.
          format: date
        end:
          type: string
          description: The end date of the contract.
          format: date
        attachmentCode:
          type: string
          description: The file code to get the digital copy of the contract.
    categories-paged:
      allOf:
        - $ref: '#/components/schemas/paged-response'
        - type: object
          required:
            - content
          properties:
            content:
              type: array
              items:
                $ref: '#/components/schemas/category'
    category-2:
      type: object
      required:
        - name
      properties:
        name:
          type: string
          minLength: 1
        description:
          type: string
    transaction-paged:
      allOf:
        - $ref: '#/components/schemas/paged-response'
        - type: object
          required:
            - content
          properties:
            content:
              type: array
              items:
                $ref: '#/components/schemas/transaction'
    transaction-2:
      type: object
      description: Transaction request
      required:
        - date
        - currency
        - description
        - amount
        - source
        - target
      properties:
        date:
          type: string
          format: date
        interestDate:
          type: string
          format: date
        bookDate:
          type: string
          format: date
        currency:
          minLength: 1
          maxLength: 3
          type: string
        description:
          maxLength: 1024
          minLength: 1
          type: string
        amount:
          type: number
          format: double
        source:
          type: integer
          description: The account paying the money
        target:
          type: integer
          description: The account receiving the money
        category:
          type: integer
          format: int64
          description: The category this transaction falls into
        expense:
          type: integer
          format: int64
          description: The expense grouping this transaction falls into
        contract:
          type: integer
          format: int64
          description: The contract this payment was for
        tags:
          type: array
          items:
            type: string
    transaction-schedule-2:
      type: object
      required:
        - name
        - amount
        - schedule
        - transferBetween
      properties:
        name:
          type: string
          minLength: 1
        amount:
          type: number
          format: double
        schedule:
          type: object
          required:
            - periodicity
            - interval
          properties:
            periodicity:
              $ref: '#/components/schemas/periodicity'
            interval:
              type: integer
              format: int32
        transferBetween:
          type: object
          description: The source and destination accounts for the transfer
          required:
            - source
            - destination
          properties:
            source:
              $ref: '#/components/schemas/account-link'
            destination:
              $ref: '#/components/schemas/account-link'
    transaction-schedule-patch:
      type: object
      properties:
        name:
          type: string
        description:
          type: string
        schedule:
          type: object
          required:
            - periodicity
            - interval
          properties:
            periodicity:
              $ref: '#/components/schemas/periodicity'
            interval:
              type: integer
              format: int32
        activeBetween:
          $ref: '#/components/schemas/date-range'
    expense:
      type: object
      required:
        - id
        - name
        - expected
      properties:
        id:
          type: integer
          format: int64
        name:
          type: string
        expected:
          type: number
    budget:
      type: object
      required:
        - income
        - period
        - expenses
      properties:
        income:
          type: number
        period:
          $ref: '#/components/schemas/date-range'
        expenses:
          type: array
          items:
            $ref: '#/components/schemas/expense'
    budget-2:
      type: object
      required:
        - year
        - month
        - income
      properties:
        year:
          type: integer
          min: 1900
          max: 9999
        month:
          type: integer
          min: 1
          max: 12
        income:
          type: number
          format: double
          minimum: 0
    expense-2:
      type: object
      required:
        - name
        - amount
      properties:
        id:
          type: integer
          format: int64
          description: |
            The unique identifier for the expense. Only fill when updating an existing expense.
        name:
          type: string
          minLength: 1
        amount:
          type: number
          format: double
          minimum: 0
    expense-computed:
      type: object
      required:
        - id
        - left
        - dailyLeft
        - spent
        - dailySpent
      properties:
        id:
          description: The identifier of the expense
          type: integer
          format: int64
        left:
          description: The amount of money left to spend on the expense
          type: number
          format: double
        dailyLeft:
          description: The amount of money left to spend on the expense each day
          type: number
          format: double
        spent:
          description: The amount of money spent on the expense
          type: number
          format: double
        dailySpent:
          description: The amount of money spent on the expense each day
          type: number
          format: double
    balance:
      type: object
      description: A filter that can be applied when computing the balance
      required:
        - range
      properties:
        accounts:
          type: array
          items:
            type: integer
            format: int64
        categories:
          type: array
          items:
            type: integer
            format: int64
        contracts:
          type: array
          items:
            type: integer
            format: int64
        expenses:
          type: array
          items:
            type: integer
            format: int64
        range:
          $ref: '#/components/schemas/date-range'
        type:
          type: string
          description: Filter a type of transaction
          enum:
            - INCOME
            - EXPENSE
            - ALL
        currency:
          type: string
          description: Filter on a specific currency code.
          min: 3
          max: 3
        importSlug:
          type: string
          description: Filter on the batch import job that created transactions
    balance-2:
      type: object
      required:
        - balance
      properties:
        balance:
          type: number
          format: double
    balance-partitioned:
      type: object
      required:
        - balance
        - partition
      allOf:
        - $ref: '#/components/schemas/balance-2'
        - type: object
          properties:
            partition:
              type: string
    balance-dated:
      allOf:
        - $ref: '#/components/schemas/balance-2'
        - type: object
          required:
            - date
          properties:
            date:
              type: string
              format: date
    detected-insight:
      type: object
      required:
        - type
        - category
        - severity
        - score
        - detected-date
        - message
        - metadata
      properties:
        type:
          description: The type of insight
          type: string
          enum:
            - UNUSUAL_AMOUNT
            - UNUSUAL_FREQUENCY
            - UNUSUAL_MERCHANT
            - UNUSUAL_TIMING
            - POTENTIAL_DUPLICATE
            - BUDGET_EXCEEDED
            - SPENDING_SPIKE
            - UNUSUAL_LOCATION
        category:
          description: The category of the insight
          type: string
        severity:
          description: The severity of the insight
          type: string
          enum:
            - INFO
            - WARNING
            - ALERT
        score:
          description: The confidence score of the insight (0.0 to 1.0)
          type: number
          format: double
          min: 0
          max: 1
        detected-date:
          description: The date when the insight was detected
          type: string
          format: date
        message:
          description: The message describing the insight
          type: string
        transaction-id:
          description: Any involved transaction identifier
          type: integer
        metadata:
          description: Additional metadata for the insight
          type: object
          additionalProperties:
            type: object
    detected-pattern:
      type: object
      properties:
        type:
          type: string
          enum:
            - RECURRING_MONTHLY
            - RECURRING_WEEKLY
            - SEASONAL
            - INCREASING_TREND
            - DECREASING_TREND
        category:
          type: string
        confidence:
          type: number
          format: double
          min: 0
          max: 1
        detected-date:
          type: string
          format: date
        metadata:
          description: Additional metadata for the insight
          type: object
          additionalProperties:
            type: object
    batch-configuration:
      type: object
      required:
        - id
        - name
        - type
        - fileCode
      properties:
        id:
          type: integer
          format: int64
          description: The configuration identifier
        name:
          type: string
          description: The name of the configuration
        type:
          type: string
          description: The type of importer that will be used
        fileCode:
          type: string
          description: The file code to get the contents of the configuration
    batch-job:
      type: object
      required:
        - id
        - slug
        - created
        - config
        - balance
      properties:
        id:
          type: integer
          format: int64
        slug:
          type: string
          description: The unique identifier of the import job
        created:
          type: string
          format: date
          description: The date the job was created
        finished:
          type: string
          format: date
          description: The date the job was finished
        config:
          $ref: '#/components/schemas/batch-configuration'
        balance:
          type: object
          required:
            - income
            - expenses
          properties:
            income:
              type: number
              format: double
              description: The total amount of money earned in this import
            expenses:
              type: number
              format: double
              description: The total amount of money spent in this import
    batch-job-paged:
      allOf:
        - $ref: '#/components/schemas/paged-response'
        - type: object
          required:
            - content
          properties:
            content:
              type: array
              items:
                $ref: '#/components/schemas/batch-job'
    task:
      type: object
      required:
        - id
        - name
      properties:
        id:
          type: string
        name:
          type: string
        variables:
          $ref: '#/components/schemas/process-variable'
    transaction-rule-2:
      type: object
      required:
        - name
        - active
        - restrictive
      properties:
        name:
          type: string
          description: The name of the rule
        description:
          type: string
          description: A long description of the rule
        active:
          type: boolean
          description: Should the rule be executed when the engine runs
        restrictive:
          type: boolean
          description: Should the rule execution stop after a positive match
        changes:
          type: array
          description: List of all the changes to be applied
          items:
            type: object
            required:
              - field
              - change
            properties:
              column:
                $ref: '#/components/schemas/rule-column'
              value:
                type: string
                description: The value to be applied, this could be an identifier
        conditions:
          type: array
          description: List of all pre-conditions that must be met
          items:
            type: object
            required:
              - field
              - operation
              - condition
            properties:
              column:
                description: The column on which the change is effected
                $ref: '#/components/schemas/rule-column'
              operation:
                description: The type of comparison operation to perform
                $ref: '#/components/schemas/operation-type'
              value:
                type: string
                description: The value the column must have to match the pre-condition
                example: My personal account
    transaction-rule-group-patch:
      type: object
      description: |
        Patch part of the rule group. Either `name` or `move` must be provided.
      properties:
        name:
          type: string
        move:
          type: string
          enum:
            - UP
            - DOWN
    extracted-transaction:
      type: object
      properties:
        type:
          type: string
          enum:
            - TRANSFER
            - CREDIT
            - DEBIT
        date:
          type: string
          format: date
        from:
          type: object
          required:
            - id
            - name
          properties:
            id:
              type: integer
              format: int64
            name:
              type: string
        to:
          type: object
          required:
            - id
            - name
          properties:
            id:
              type: integer
              format: int64
            name:
              type: string
        description:
          type: string
        amount:
          type: number
          format: double
