> ## Documentation Index
> Fetch the complete documentation index at: https://docs.layerfi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update categorization rule

> Updates an existing categorization rule. This replaces the entire rule content. The rule can optionally be applied retroactively to existing uncategorized transactions.



## OpenAPI

````yaml put /v1/businesses/{businessId}/categorization-rules/{categorizationRuleId}
openapi: 3.0.1
info:
  title: API
  version: latest
servers: []
security:
  - BearerAuth: []
tags: []
externalDocs:
  url: /
paths:
  /v1/businesses/{businessId}/categorization-rules/{categorizationRuleId}:
    put:
      tags:
        - Categorization Rules
      summary: Update categorization rule
      description: >-
        Updates an existing categorization rule. This replaces the entire rule
        content. The rule can optionally be applied retroactively to existing
        uncategorized transactions.
      operationId: business.categorization-rules.update
      parameters:
        - name: businessId
          in: path
          description: The UUID of the business.
          required: true
          schema:
            type: string
            format: uuid
        - name: categorizationRuleId
          in: path
          description: The UUID of the categorization rule.
          required: true
          schema:
            type: string
            format: uuid
        - name: Content-Type
          in: header
          description: Content-Type must be set to application/json.
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCategorizationRuleParams'
      responses:
        '200':
          description: Categorization rule updated successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CategorizationRule'
        '404':
          description: Categorization rule not found.
      deprecated: false
components:
  schemas:
    CreateCategorizationRuleParams:
      type: object
      description: >-
        Parameters for creating or updating a categorization rule. At least one
        filter must be specified.
      properties:
        name:
          type: string
          description: Optional name for the rule.
        category:
          $ref: '#/components/schemas/BankTransactionClassification'
        suggestion_1:
          $ref: '#/components/schemas/BankTransactionClassification'
        suggestion_2:
          $ref: '#/components/schemas/BankTransactionClassification'
        suggestion_3:
          $ref: '#/components/schemas/BankTransactionClassification'
        apply_retroactively:
          type: boolean
          default: false
          description: Whether to apply this rule to existing uncategorized transactions.
        external_id:
          type: string
          description: >-
            External identifier for idempotency. Used for create/upsert
            operations.
        created_by_suggestion_id:
          type: string
          format: uuid
          description: UUID of the suggestion that created this rule (if applicable).
        merchant_type_filter:
          type: string
          description: Regex pattern to match against merchant type (minimum 7 characters).
          minLength: 7
        transaction_description_filter:
          type: string
          description: >-
            Regex pattern to match against transaction description (minimum 7
            characters).
          minLength: 7
        counterparty_filter:
          type: string
          format: uuid
          description: UUID of a specific counterparty (merchant/vendor) to match.
        bank_transaction_type_filter:
          $ref: '#/components/schemas/BankTransactionType'
        bank_direction_filter:
          type: string
          enum:
            - MONEY_IN
            - MONEY_OUT
          description: Transaction direction to match.
        amount_min_filter:
          type: integer
          format: int64
          description: Minimum transaction amount in cents.
        amount_max_filter:
          type: integer
          format: int64
          description: Maximum transaction amount in cents.
    CategorizationRule:
      type: object
      description: >-
        A categorization rule that automatically categorizes transactions
        matching specified filters.
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier for the rule.
        business_id:
          type: string
          format: uuid
          description: The business this rule belongs to.
        name:
          type: string
          description: Name of the rule.
        created_at:
          type: string
          format: date-time
          description: When the rule was created.
        updated_at:
          type: string
          format: date-time
          description: When the rule was last updated.
        category:
          $ref: '#/components/schemas/BankTransactionClassification'
        suggestion_1:
          $ref: '#/components/schemas/BankTransactionClassification'
        suggestion_2:
          $ref: '#/components/schemas/BankTransactionClassification'
        suggestion_3:
          $ref: '#/components/schemas/BankTransactionClassification'
        merchant_type_filter:
          type: string
          description: Regex pattern matching merchant type.
        transaction_description_filter:
          type: string
          description: Regex pattern matching transaction description.
        counterparty_filter:
          $ref: '#/components/schemas/BankTransactionCounterparty'
        bank_transaction_type_filter:
          $ref: '#/components/schemas/BankTransactionType'
        bank_direction_filter:
          type: string
          enum:
            - MONEY_IN
            - MONEY_OUT
          description: Transaction direction that this rule matches.
        amount_min_filter:
          type: integer
          format: int64
          description: Minimum amount in cents.
        amount_max_filter:
          type: integer
          format: int64
          description: Maximum amount in cents.
      required:
        - id
        - business_id
        - created_at
        - updated_at
    BankTransactionClassification:
      discriminator:
        propertyName: type
        mapping:
          AccountId:
            $ref: '#/components/schemas/AccountId'
          StableName:
            $ref: '#/components/schemas/AccountStableName'
          Exclusion:
            $ref: '#/components/schemas/Exclusion'
      oneOf:
        - $ref: '#/components/schemas/AccountId'
          title: Account ID
        - $ref: '#/components/schemas/AccountStableName'
          title: Account Stable Name
        - $ref: '#/components/schemas/Exclusion'
          title: Exclusion
    BankTransactionType:
      type: string
      description: Type of bank transaction.
      enum:
        - REVENUE
        - LOAN_DISBURSEMENT
        - REFUND_RECEIVED
        - INCOMING_P2P_TRANSFER
        - INTRA_ACCOUNT_TRANSFER_IN
        - CHECK_WITHDRAWAL
        - ATM_DEPOSIT
        - BANK_DEPOSIT
        - BANK_VERIFICATION_TRIAL_CREDIT
        - REVERSAL_IN
        - CREDIT_CARD_REWARD
        - CREDIT_CARD_PAYMENT_IN
        - INTEREST_EARNED
        - GOVERNMENT_OR_OTHER_GRANT
        - TAX_REFUND
        - PURCHASE
        - REFUND_GIVEN
        - OUTGOING_P2P_TRANSFER
        - INTRA_ACCOUNT_TRANSFER_OUT
        - CHECK_DEPOSIT
        - CREDIT_CARD_PAYMENT_OUT
        - ATM_WITHDRAWAL
        - BANK_WITHDRAWAL
        - BANKING_FEE
        - PAYMENT_PROCESSING_FEE
        - BANK_VERIFICATION_TRIAL_DEBIT
        - REVERSAL_OUT
        - LOAN_PAYMENT
        - TAX_PAYMENT
        - NOT_ENOUGH_INFORMATION
    BankTransactionCounterparty:
      type: object
      description: Information about a transaction counterparty (merchant/vendor).
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier for the counterparty.
        name:
          type: string
          description: Name of the counterparty.
        logo_url:
          type: string
          description: URL to the counterparty's logo.
        website:
          type: string
          description: Counterparty website.
    AccountId:
      type: object
      required:
        - type
        - id
      properties:
        type:
          type: string
          enum:
            - AccountId
          description: Resource type. Value will be `AccountId`.
          example: AccountId
        id:
          type: string
          format: uuid
          description: ID of the account.
    AccountStableName:
      type: object
      required:
        - type
        - stable_name
      properties:
        type:
          type: string
          enum:
            - StableName
          description: Resource type. Value will be `StableName`.
          example: StableName
        stable_name:
          type: string
          example: CURRENT_ASSETS
          description: Stable name of the account.
    Exclusion:
      type: object
      properties:
        type:
          type: string
          enum:
            - Exclusion
          description: Resource type. Value will be `Exclusion`.
        exclusion_type:
          $ref: '#/components/schemas/ExclusionType'
      required:
        - type
        - exclusion_type
    ExclusionType:
      type: string
      description: Type of exclusion for a bank transaction.
      enum:
        - PERSONAL_EXPENSES
        - PERSONAL_INFLOWS
        - DUPLICATE_TRANSACTION
        - OTHER_EXCLUSION
      x-displayStrings:
        PERSONAL_EXPENSES: Personal transactions
        PERSONAL_INFLOWS: Personal income sources
        DUPLICATE_TRANSACTION: Duplicate transaction
        OTHER_EXCLUSION: Other exclusion
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````