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

# Update a Classification Rule

> Update a rule. Omitted fields keep their current values.

**Scopes:** `classification_rule:update`



## OpenAPI

````yaml /api-reference/openapi.json patch /v0/business/{business_id}/rules/classifications/{rule_id}
openapi: 3.1.0
info:
  title: Asset API
  version: '0.1'
servers:
  - url: https://api.sandbox.getasset.com
    description: Sandbox
  - url: https://api.getasset.com
    description: Production
security: []
paths:
  /v0/business/{business_id}/rules/classifications/{rule_id}:
    patch:
      tags:
        - Classification Rules
      summary: Update a Classification Rule
      description: |-
        Update a rule. Omitted fields keep their current values.

        **Scopes:** `classification_rule:update`
      operationId: >-
        update_classification_rule_v0_business__business_id__rules_classifications__rule_id__patch
      parameters:
        - name: rule_id
          in: path
          required: true
          schema:
            description: The id of the classification rule
            examples:
              - clr_GA6EG2qFxA97NZHtxeLPUy
            type: string
            format: clr_string
            title: Rule Id
          description: The id of the classification rule
        - name: business_id
          in: path
          required: true
          schema:
            description: The id of the business
            examples:
              - biz_GA6EG2qFxA97NZHtxeLPUy
            type: string
            format: biz_string
            title: Business Id
          description: The id of the business
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateTxnClassificationRuleRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TxnClassificationRulePublic'
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Forbidden
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Not Found
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Unprocessable Content
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Service Unavailable
      security:
        - OAuth2ClientCredentialsBearer:
            - classification_rule:update
components:
  schemas:
    UpdateTxnClassificationRuleRequest:
      properties:
        merchant:
          anyOf:
            - type: string
              maxLength: 255
            - type: 'null'
          title: Merchant
        description_match_type:
          anyOf:
            - $ref: '#/components/schemas/DescriptionMatchType'
            - type: 'null'
        description_value:
          anyOf:
            - type: string
              maxLength: 512
            - type: 'null'
          title: Description Value
        classifications:
          anyOf:
            - items:
                $ref: '#/components/schemas/CreateBusinessTxnClassificationRequest'
              type: array
              minItems: 1
            - type: 'null'
          title: Classifications
          description: >-
            Replaces the rule's full list of classifications; omit to keep the
            current ones.
        auto_confirm:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Auto Confirm
        is_active:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Is Active
          description: Whether the rule takes part in categorization and tagging.
      type: object
      title: UpdateTxnClassificationRuleRequest
    TxnClassificationRulePublic:
      properties:
        merchant:
          anyOf:
            - type: string
              maxLength: 255
            - type: 'null'
          title: Merchant
          description: >-
            Case-insensitive exact merchant name to match. Mutually exclusive
            with the description criterion; exactly one of the two is required.
          examples:
            - Starbucks
        description_match_type:
          anyOf:
            - $ref: '#/components/schemas/DescriptionMatchType'
            - type: 'null'
          description: How to match the transaction description.
        description_value:
          anyOf:
            - type: string
              maxLength: 512
            - type: 'null'
          title: Description Value
          description: Description text to match, case-insensitive.
          examples:
            - MONTHLY SOFTWARE SUBSCRIPTION
        id:
          type: string
          format: clr_string
          title: Id
          description: The id of the classification rule
          examples:
            - clr_GA6EG2qFxA97NZHtxeLPUy
        classifications:
          items:
            $ref: '#/components/schemas/BusinessTxnClassificationPublic'
          type: array
          title: Classifications
          description: >-
            Classifications evaluated in order. Categorization applies the first
            one whose conditions match and that has a target ledger; tagging
            applies, per tag field, the first one whose conditions match and
            that sets the field.
        auto_confirm:
          type: boolean
          title: Auto Confirm
        is_active:
          type: boolean
          title: Is Active
          description: Whether the rule takes part in categorization and tagging.
        match_count:
          type: integer
          title: Match Count
          description: Number of transactions the rule has matched.
        last_matched_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Last Matched At
          description: When the rule last matched a transaction.
        created_at:
          type: string
          format: date-time
          title: Created At
      type: object
      required:
        - id
        - classifications
        - auto_confirm
        - is_active
        - match_count
        - created_at
      title: TxnClassificationRulePublic
    ErrorResponse:
      properties:
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
          description: A description of the error
        data:
          title: Data
          description: Data associated with the error
      type: object
      required:
        - error
        - data
      title: ErrorResponse
    DescriptionMatchType:
      type: string
      enum:
        - contains
        - not_contains
        - equals
      title: DescriptionMatchType
    CreateBusinessTxnClassificationRequest:
      properties:
        conditions:
          $ref: '#/components/schemas/BusinessTxnClassificationConditionsSchema-Input'
          description: >-
            Conditions the transaction must satisfy for this classification to
            apply; omit to match every transaction.
        target_ledger_id:
          anyOf:
            - type: string
              format: ldg_string
            - type: 'null'
          title: Target Ledger Id
          description: >-
            The ledger to categorize the transaction into. Omit for a
            classification that only tags.
          examples:
            - ldg_GA6EG2qFxA97NZHtxeLPUy
        splits:
          items:
            $ref: '#/components/schemas/BusinessTxnClassificationSplitRequest'
          type: array
          title: Splits
          description: >-
            Percentages of the transaction amount posted to other ledgers ahead
            of the target ledger, in order; they total at most 100 and whatever
            remains goes to the target ledger. Requires target_ledger_id.
          examples:
            - - ledger_id: ldg_GA6EG2qFxA97NZHtxeLPUy
                percentage: 8.875
              - ledger_id: ldg_HB7FH3rGyB08OAIuyfMQVz
                percentage: 10
        tags:
          additionalProperties:
            anyOf:
              - type: string
              - items:
                  anyOf:
                    - type: string
                    - $ref: '#/components/schemas/TagShareRequest'
                type: array
          type: object
          title: Tags
          description: >-
            Tag field name to the value or values to apply, each a string or
            `{value, percentage}` to allocate a share of the transaction amount
            to the value. For each tag field, the first matching classification
            that sets it applies its values, business rules before tenant rules.
            The field must already exist; a new value is created on it if
            needed.
          examples:
            - Job:
                - percentage: 60
                  value: Maple Street Remodel
                - percentage: 40
                  value: Oak Avenue Deck
              Location: NYC
      type: object
      title: CreateBusinessTxnClassificationRequest
    BusinessTxnClassificationPublic:
      properties:
        conditions:
          $ref: >-
            #/components/schemas/BusinessTxnClassificationConditionsSchema-Output
          description: >-
            Conditions the transaction must satisfy for this classification to
            apply.
        target_ledger_id:
          anyOf:
            - type: string
              format: ldg_string
            - type: 'null'
          title: Target Ledger Id
          description: >-
            The ledger to categorize the transaction into; null for a
            classification that only tags.
        target_ledger_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Target Ledger Name
          description: Snapshot of the target ledger name at rule creation.
        splits:
          items:
            $ref: '#/components/schemas/BusinessTxnClassificationSplitPublic'
          type: array
          title: Splits
          description: >-
            Percentages of the transaction amount posted to other ledgers ahead
            of the target ledger, in order; they total at most 100 and whatever
            remains goes to the target ledger.
        tags:
          additionalProperties:
            items:
              $ref: '#/components/schemas/TagSharePublic'
            type: array
          type: object
          title: Tags
          description: Tag field name to the values applied, with their shares.
      type: object
      required:
        - conditions
        - splits
        - tags
      title: BusinessTxnClassificationPublic
    BusinessTxnClassificationConditionsSchema-Input:
      properties:
        amount:
          anyOf:
            - $ref: '#/components/schemas/AmountPredicate-Input'
            - type: 'null'
          description: Amount constraint; omit to match any amount.
        direction:
          anyOf:
            - $ref: '#/components/schemas/TransactionDirection'
            - type: 'null'
          description: >-
            Match money in (positive amounts) or money out (negative amounts).
            Zero-amount transactions match neither. Omit to match either.
        date:
          anyOf:
            - $ref: '#/components/schemas/DatePredicate'
            - type: 'null'
          description: Date constraint; omit to match any date.
        external_account_id:
          anyOf:
            - type: string
              format: eac_string
            - type: 'null'
          title: External Account Id
          description: >-
            The external account whose transactions this classification matches.
            Null matches transactions from any of the business's accounts.
          examples:
            - eac_GA6EG2qFxA97NZHtxeLPUy
      type: object
      title: BusinessTxnClassificationConditionsSchema
    BusinessTxnClassificationSplitRequest:
      properties:
        percentage:
          anyOf:
            - type: number
              maximum: 100
              exclusiveMinimum: 0
            - type: string
              pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
          title: Percentage
          description: >-
            Share of the transaction amount to post to the ledger, over 0 and up
            to 100.
          examples:
            - 50
        ledger_id:
          type: string
          format: ldg_string
          title: Ledger Id
          description: >-
            The ledger the split posts to; each split uses a different ledger.
            It may be target_ledger_id, which then also takes the remainder.
          examples:
            - ldg_GA6EG2qFxA97NZHtxeLPUy
      type: object
      required:
        - percentage
        - ledger_id
      title: BusinessTxnClassificationSplitRequest
    TagShareRequest:
      properties:
        value:
          type: string
          title: Value
          description: The tag value to apply.
          examples:
            - Maple Street Remodel
        percentage:
          anyOf:
            - type: number
              maximum: 100
              exclusiveMinimum: 0
            - type: string
              pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
            - type: 'null'
          title: Percentage
          description: >-
            Share of the transaction amount to allocate to this value, over 0
            and up to 100. Within a field either every value or none has a
            percentage, and they total at most 100. Omit to allocate the amount
            evenly across the field's values.
          examples:
            - 60
      type: object
      required:
        - value
      title: TagShareRequest
    BusinessTxnClassificationConditionsSchema-Output:
      properties:
        amount:
          anyOf:
            - $ref: '#/components/schemas/AmountPredicate-Output'
            - type: 'null'
          description: Amount constraint; omit to match any amount.
        direction:
          anyOf:
            - $ref: '#/components/schemas/TransactionDirection'
            - type: 'null'
          description: >-
            Match money in (positive amounts) or money out (negative amounts).
            Zero-amount transactions match neither. Omit to match either.
        date:
          anyOf:
            - $ref: '#/components/schemas/DatePredicate'
            - type: 'null'
          description: Date constraint; omit to match any date.
        external_account_id:
          anyOf:
            - type: string
              format: eac_string
            - type: 'null'
          title: External Account Id
          description: >-
            The external account whose transactions this classification matches.
            Null matches transactions from any of the business's accounts.
          examples:
            - eac_GA6EG2qFxA97NZHtxeLPUy
      type: object
      title: BusinessTxnClassificationConditionsSchema
    BusinessTxnClassificationSplitPublic:
      properties:
        ledger_id:
          type: string
          format: ldg_string
          title: Ledger Id
          description: The ledger the split posts to.
        ledger_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Ledger Name
          description: Snapshot of the split ledger name at rule creation.
        percentage:
          type: number
          title: Percentage
          description: Share of the transaction amount posted to the ledger.
      type: object
      required:
        - ledger_id
        - percentage
      title: BusinessTxnClassificationSplitPublic
    TagSharePublic:
      properties:
        value:
          type: string
          title: Value
          description: The tag value applied.
        percentage:
          anyOf:
            - type: number
            - type: 'null'
          title: Percentage
          description: >-
            Share of the transaction amount allocated to the value; null
            allocates evenly across the field's values.
      type: object
      required:
        - value
      title: TagSharePublic
    AmountPredicate-Input:
      properties:
        operator:
          $ref: '#/components/schemas/AmountMatchType'
          description: How to compare the transaction amount.
        value:
          anyOf:
            - type: number
              minimum: 0
            - type: string
              pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
          title: Value
          description: >-
            Absolute home-currency amount to compare against; the inclusive
            lower bound when operator is between.
          examples:
            - 100
        max_value:
          anyOf:
            - type: number
              minimum: 0
            - type: string
              pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
            - type: 'null'
          title: Max Value
          description: Inclusive upper bound, set only when operator is between.
          examples:
            - 250
      type: object
      required:
        - operator
        - value
      title: AmountPredicate
    TransactionDirection:
      type: string
      enum:
        - money_in
        - money_out
      title: TransactionDirection
    DatePredicate:
      properties:
        operator:
          $ref: '#/components/schemas/DateMatchType'
          description: How to compare the transaction date (UTC calendar date).
        value:
          type: string
          format: date
          title: Value
          description: >-
            Date to compare against; the inclusive lower bound when operator is
            between.
        max_value:
          anyOf:
            - type: string
              format: date
            - type: 'null'
          title: Max Value
          description: Inclusive upper bound, set only when operator is between.
      type: object
      required:
        - operator
        - value
      title: DatePredicate
    AmountPredicate-Output:
      properties:
        operator:
          $ref: '#/components/schemas/AmountMatchType'
          description: How to compare the transaction amount.
        value:
          type: number
          title: Value
          description: >-
            Absolute home-currency amount to compare against; the inclusive
            lower bound when operator is between.
          examples:
            - 100
        max_value:
          anyOf:
            - type: number
            - type: 'null'
          title: Max Value
          description: Inclusive upper bound, set only when operator is between.
          examples:
            - 250
      type: object
      required:
        - operator
        - value
      title: AmountPredicate
    AmountMatchType:
      type: string
      enum:
        - equals
        - greater_than
        - less_than
        - between
      title: AmountMatchType
    DateMatchType:
      type: string
      enum:
        - equals
        - before
        - after
        - between
      title: DateMatchType
  securitySchemes:
    OAuth2ClientCredentialsBearer:
      type: oauth2
      flows:
        clientCredentials:
          scopes: {}
          tokenUrl: /v0/auth/token

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.