---
title: "PATCH /v1/portfolios/{portfolioSlug}/accounting-rules/{ruleId}"
method: PATCH
path: "/v1/portfolios/{portfolioSlug}/accounting-rules/{ruleId}"
tags: ["AccountingRules"]
---

# PATCH /v1/portfolios/{portfolioSlug}/accounting-rules/{ruleId}

`PATCH /v1/portfolios/{portfolioSlug}/accounting-rules/{ruleId}`

## Request

- Base URL: `https://api.tokenbooks.io` (the document declares no server; this is the origin it was published from)
- URL: `https://api.tokenbooks.io/v1/portfolios/{portfolioSlug}/accounting-rules/{ruleId}`
- Auth: API key in header `x-api-key`

## Path parameters

- `ruleId` string, required
- `portfolioSlug` string, required

## Request body

- UpdateAccountingRuleRequestDto
  - `name` string: Human-readable rule name, shown in the rules list.
  - `conditions` object
    - `formatVersion` 1, required: Structure version of this envelope. Always 1.
    - `all` union[], required: Conditions that must all match for the rule to fire. At least one is required.
      - union
        - object
          - `field` 'fromAddressLabel', required: Which part of the transaction this condition tests.
          - `operator` 'equals' | 'contains' | 'notEquals' | 'notContains', required: How the field is compared with value.
          - `value` string, required: The value the field is compared against.
        - object
          - `field` 'toAddressLabel', required: Which part of the transaction this condition tests.
          - `operator` 'equals' | 'contains' | 'notEquals' | 'notContains', required: How the field is compared with value.
          - `value` string, required: The value the field is compared against.
        - object
          - `field` 'fromAddress', required: Which part of the transaction this condition tests.
          - `operator` 'equals' | 'contains', required: How the field is compared with value.
          - `value` string, required: The value the field is compared against.
        - object
          - `field` 'toAddress', required: Which part of the transaction this condition tests.
          - `operator` 'equals' | 'contains', required: How the field is compared with value.
          - `value` string, required: The value the field is compared against.
        - object
          - `field` 'direction', required: Which part of the transaction this condition tests.
          - `operator` 'equals' | 'notEquals', required: How the field is compared with value.
          - `value` 'IN' | 'OUT' | 'GAS', required: The value the field is compared against.
        - object
          - `field` 'asset', required: Which part of the transaction this condition tests.
          - `operator` 'in' | 'notIn', required: How the field is compared with value.
          - `value` string[], required: The value the field is compared against.
        - object
          - `field` 'assetClass', required: Which part of the transaction this condition tests.
          - `operator` 'in' | 'notIn', required: How the field is compared with value.
          - `value` string[], required: The value the field is compared against.
        - object
          - `field` 'stablecoin', required: Which part of the transaction this condition tests.
          - `operator` 'equals', required: How the field is compared with value.
          - `value` boolean, required: The value the field is compared against.
        - object
          - `field` 'chain', required: Which part of the transaction this condition tests.
          - `operator` 'in' | 'notIn', required: How the field is compared with value.
          - `value` string[], required: The value the field is compared against.
        - object
          - `field` 'operationType', required: Which part of the transaction this condition tests.
          - `operator` 'in' | 'notIn', required: How the field is compared with value.
          - `value` string[], required: The value the field is compared against.
        - object
          - `field` 'accountSubType', required: Which part of the transaction this condition tests.
          - `operator` 'in' | 'notIn', required: How the field is compared with value.
          - `value` string[], required: The value the field is compared against.
        - object
          - `field` 'fiatValue', required: Condition field.
          - `operator` 'gt', required: Comparison operator.
          - `value` string, required: Decimal fiat amount to compare against.
        - object
          - `field` 'fiatValue', required: Condition field.
          - `operator` 'lt', required: Comparison operator.
          - `value` string, required: Decimal fiat amount to compare against.
        - object
          - `field` 'fiatValue', required: Condition field.
          - `operator` 'gte', required: Comparison operator.
          - `value` string, required: Decimal fiat amount to compare against.
        - object
          - `field` 'fiatValue', required: Condition field.
          - `operator` 'lte', required: Comparison operator.
          - `value` string, required: Decimal fiat amount to compare against.
        - object
          - `field` 'fiatValue', required: Condition field.
          - `operator` 'between', required: Comparison operator.
          - `value` union[], required: Inclusive [low, high] decimal-string range.
            - union
              - …
        - object
          - `field` 'entryType', required: Which part of the transaction this condition tests.
          - `operator` 'equals', required: How the field is compared with value.
          - `value` 'DR' | 'CR', required: The value the field is compared against.
        - object
          - `field` 'accountType', required: Which part of the transaction this condition tests.
          - `operator` 'in' | 'notIn', required: How the field is compared with value.
          - `value` string[], required: The value the field is compared against.
        - object
          - `field` 'transactionDate', required: Owning transaction timestamp.
          - `operator` 'lt', required: Before (lt) or on or after (gte) the cutoff.
          - `value` string, date-time, required: Exact timestamp with three fractional digits and a known offset or Z; -00:00 is invalid.
        - object
          - `field` 'transactionDate', required: Owning transaction timestamp.
          - `operator` 'gte', required: Before (lt) or on or after (gte) the cutoff.
          - `value` string, date-time, required: Exact timestamp with three fractional digits and a known offset or Z; -00:00 is invalid.
        - object
          - `field` 'transactionDate', required: Owning transaction timestamp.
          - `operator` 'between', required: Within the inclusive [start, end] range.
          - `value` union[], required: Inclusive [start, end] timestamps, earliest first; each has three fractional digits and a known offset or Z, never -00:00.
            - union
              - …
        - object
          - `field` 'wallet', required: Which part of the transaction this condition tests.
          - `operator` 'in' | 'notIn', required: How the field is compared with value.
          - `value` object[], required: The value the field is compared against.
            - `chainId` string, required: Chain ID
            - `address` string, required: Wallet address
        - object
          - `operator` 'in' | 'notIn', required: How the field is compared with value.
          - `field` 'accountNumber', required: Which part of the transaction this condition tests.
          - `value` string[], required: The value the field is compared against.
        - object
          - `field` 'counterparty', required: Which part of the transaction this condition tests.
          - `operator` 'in' | 'notIn', required: How the field is compared with value.
          - `value` string[], required: The value the field is compared against.
  - `action` object
    - `formatVersion` 1, required: Structure version of this envelope. Always 1.
    - `actions` union[], required: What the rule changes when it matches. At most one action of each type.
      - union
        - object
          - `type` 'SET_COUNTERPARTY', required: Which change this action makes.
          - `target` 'LINE', required: What the change applies to: a journal line or the transaction.
          - `counterpartyName` string, required: Counterparty name, from list_journal_line_assignment_options (type: counterparty).
        - object
          - `type` 'SET_LEDGER_ACCOUNT', required: Which change this action makes.
          - `target` 'LINE', required: What the change applies to: a journal line or the transaction.
          - `accountNumber` string, required: Chart-of-accounts number, from list_journal_line_assignment_options (type: ledger_account).
        - object
          - `type` 'SET_RESPONSIBILITY_CENTERS', required: Which change this action makes.
          - `target` 'LINE', required: What the change applies to: a journal line or the transaction.
          - `responsibilityCenterAssignments` object[], required
            - `responsibilityCenterTypeKey` string, required: Stable responsibility-center type key. It uses lowercase alphanumeric snake_case segments.
            - `responsibilityCenterName` string, required: Responsibility center name, from list_journal_line_assignment_options (type: responsibility_center).

## Response `200`

- CommandResultDto
  - `mode` 'sync' | 'async', required: Whether the command ran sync or async
  - `result` union: The command result, present for synchronous commands
    - object
      - `success` true, required
      - `data` unknown
    - object
      - `success` false, required
      - `error` object, required
        - `name` string, required: The class name of the error
        - `message` string, required: The error message
        - `body` union, required: The error body, usually fields needed to reconstruct the specific error fields
          - object
            - `usageType` string, required
            - `currentUsage` number, required
            - `limit` number, required
          - unknown
  - `jobId` string: Tracking job id, present for asynchronous commands
  - `status` 'queued': Queue status, present for asynchronous commands

---

[API](https://skmtc.dev/tokenbooks/apis/tokenbooks-public-api.md) · [All operations](https://skmtc.dev/tokenbooks/apis/tokenbooks-public-api/llms.txt) · [OpenAPI document](https://skmtc.dev/tokenbooks/apis/tokenbooks-public-api/revisions/180622e6255e?raw)
