# Returns the account determination rules that match the given filters.

`POST /inventory/account-determination-rules/search`

Group: Inventory › Account Determination Rules · Operation ID: `searchAccountDeterminationRules`

Every filter matches a stored dimension, not matching behavior: a filter on itemTypeId finds the rules pinned to that item type, not the wildcard rules that would also apply to it. This endpoint returns the whole rule and is the only one that can filter by entity, book, item type, item category, location or transaction type, which the collection cannot. Reviewing one entity's configuration means filters.entityId. There is no free-text filter. An identifier that matches nothing returns an empty page.

[Open in the interactive reference](https://docs.api.lensing.ai/?op=searchAccountDeterminationRules)

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `Api-Version` | header | `"v1"` | yes | The API version this request targets, named by its public identifier. Required on every request; omitting it, or naming a version this company does not have, is answered with 400. This document describes version `v1`. |

## Request body

Required, `application/json`: searchAccountDeterminationRulesInput.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `filters` | object | yes | The filters to apply. A rule must match every filter you send. Each filter matches a stored dimension, not matching behavior: a filter on itemTypeId finds the rules pinned to that item type, not the wildcard rules that would also apply to it. Send an empty object to return all rules. |
| `filters.entityId` | string | no | Limits results to the rules belonging to this legal entity. See id on GET base/entities. This is the usual way to review one entity's configuration. An identifier that matches no entity returns an empty page. |
| `filters.bookId` | string | no | Limits results to the rules pinned to this accounting book. See id on GET accounting/books/:id. Rules with no book, which apply to every book, are not returned. |
| `filters.itemTypeId` | string | no | Limits results to the rules pinned to this item type. See id on GET inventory/item-types/:id. Wildcard rules are not returned. |
| `filters.itemCategoryId` | string | no | Limits results to the rules pinned to this item category. See id on GET inventory/item-categories/:id. Wildcard rules are not returned. |
| `filters.locationId` | string | no | Limits results to the rules pinned to this warehouse location. See id on GET inventory/warehouses/:id. Wildcard rules are not returned. |
| `filters.transactionTypeContext` | string, one of `"RECEIPT"`, `"SHIPMENT"`, `"SALES_RETURN"`, `"SALES_INVOICE"`, `"SALES_CREDIT_MEMO"`, `"PURCHASE_RETURN"`, `"PURCHASE_INVOICE"`, `"PURCHASE_CREDIT_MEMO"`, `"INVENTORY_INCREASE"`, `"INVENTORY_DECREASE"`, `"INVENTORY_REVALUATION"`, `"WAREHOUSE_TRANSFER"`, `"INTERCOMPANY_TRANSFER"`, `"DEFAULT"` | no | Limits results to the rules pinned to this document kind. Filtering on DEFAULT returns the rules whose transaction type is DEFAULT. A rule whose transaction type is absent is not returned. |
| `filters.isActive` | boolean | no | Limits results to rules that take part in account determination when true, or to disabled ones when false. Omit to match both. |
| `filters.modifiedSince` | string (date-time) | no | Limits results to rules whose header changed on or after this time. Format YYYY-MM-DDTHH:mm:ss.sssZ. Adding or changing a reason-code override does not change lastModifiedDate. |
| `page` | object | no | The pagination controls. Omit for the first page. |
| `page.cursor` | string | no | The cursor from the previous response's pagination.nextCursor. Omit for the first page. |
| `page.size` | number | no | The number of rules per page. Defaults to 50. A value above 200 is treated as 200, not rejected. |

Example:

```json
{
  "filters": {
    "entityId": "81e8beb1-1415-4012-9012-8138580f43dc",
    "isActive": true
  },
  "page": {
    "size": 50
  }
}
```

## Response

`200` Success

Under `data` (searchAccountDeterminationRulesOutput):

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `items` | array of object | yes | The rules on this page, ordered by id. An empty array when nothing matches. |
| `items[].id` | string | yes | The unique identifier for the rule. |
| `items[].ruleName` | string | yes | A free-text label for the rule. It is not unique and is never read when matching. |
| `items[].priority` | number | no | The tie-breaker between rules of equal specificity. The lower number wins. An absent priority counts as 0, which outranks any positive value. |
| `items[].isActive` | boolean | no | Whether the rule takes part in account determination. When false, the rule is skipped. |
| `items[].matching` | object | yes | The dimensions this rule is pinned to. An absent dimension matches every value of it. |
| `items[].matching.entityId` | string | yes | The legal entity this rule belongs to. See id on GET base/entities. Matching is always scoped to one entity, so this is never absent. |
| `items[].matching.bookId` | string | no | The accounting book this rule is pinned to. See id on GET accounting/books/:id. Absent means the rule matches every value of this dimension. |
| `items[].matching.itemTypeId` | string | no | The item type this rule is pinned to. See id on GET inventory/item-types/:id. Absent means the rule matches every value of this dimension. |
| `items[].matching.itemCategoryId` | string | no | The item category this rule is pinned to. See id on GET inventory/item-categories/:id. Absent means the rule matches every value of this dimension. |
| `items[].matching.locationId` | string | no | The warehouse location this rule is pinned to. See id on GET inventory/warehouses/:id. Absent means the rule matches every value of this dimension. |
| `items[].matching.inventoryLocationType` | string | no | An advisory classification of the location. It is stored on the rule and never read when matching, so it does not affect which rule the posting selects. Absent when none was set. |
| `items[].matching.transactionTypeContext` | string, one of `"RECEIPT"`, `"SHIPMENT"`, `"SALES_RETURN"`, `"SALES_INVOICE"`, `"SALES_CREDIT_MEMO"`, `"PURCHASE_RETURN"`, `"PURCHASE_INVOICE"`, `"PURCHASE_CREDIT_MEMO"`, `"INVENTORY_INCREASE"`, `"INVENTORY_DECREASE"`, `"INVENTORY_REVALUATION"`, `"WAREHOUSE_TRANSFER"`, `"INTERCOMPANY_TRANSFER"`, `"DEFAULT"` | no | The document kind this rule is pinned to. The wildcard that matches every transaction type reads back in two forms: the field is absent, or it is DEFAULT. Do not treat absence alone as the wildcard, because the transaction type can be DEFAULT explicitly. WAREHOUSE_TRANSFER and INTERCOMPANY_TRANSFER are the kinds used for transfer postings. |
| `items[].accounts` | object | yes | The GL accounts this rule assigns. An account the rule does not assign is absent, and a less specific rule decides that posting. |
| `items[].accounts.inventoryAssetAccountId` | string | no | The account for inventory value on the balance sheet. See id on GET accounting/accounts/:id. Absent when the rule assigns none. |
| `items[].accounts.cogsAccountId` | string | no | The cost of goods sold account. See id on GET accounting/accounts/:id. Absent when the rule assigns none. |
| `items[].accounts.cogsClearingAccountId` | string | no | The cost of goods sold clearing account. See id on GET accounting/accounts/:id. Absent when the rule assigns none. |
| `items[].accounts.deferredCogsAccountId` | string | no | The deferred cost of goods sold account. See id on GET accounting/accounts/:id. Absent when the rule assigns none. |
| `items[].accounts.salesRevenueAccountId` | string | no | The sales revenue account. See id on GET accounting/accounts/:id. Absent when the rule assigns none. |
| `items[].accounts.salesReturnAccountId` | string | no | The sales return account. See id on GET accounting/accounts/:id. It can be overridden per reason code. Absent when the rule assigns none. |
| `items[].accounts.salesStockInTransitAccountId` | string | no | The sales stock-in-transit account. See id on GET accounting/accounts/:id. Absent when the rule assigns none. |
| `items[].accounts.grniClearingAccountId` | string | no | The goods-received-not-invoiced clearing account, for inventory items. See id on GET accounting/accounts/:id. Absent when the rule assigns none. |
| `items[].accounts.grncClearingAccountId` | string | no | The goods-returned-not-credited clearing account. It is the offset leg booked on purchase returns and credit memos. See id on GET accounting/accounts/:id. It can be overridden per reason code. Absent when the rule assigns none. |
| `items[].accounts.servicesReceivedNotInvoicedAccountId` | string | no | The clearing account for services received but not yet invoiced, for non-inventory items. See id on GET accounting/accounts/:id. Absent when the rule assigns none. |
| `items[].accounts.expenseAccountId` | string | no | The expense account for non-inventory items and description lines. See id on GET accounting/accounts/:id. Absent when the rule assigns none. |
| `items[].accounts.purchasePriceVarianceAccountId` | string | no | The purchase price variance account, under standard costing. See id on GET accounting/accounts/:id. Absent when the rule assigns none. |
| `items[].accounts.inventoryAdjustmentGainAccountId` | string | no | The account for positive inventory count and adjustment differences. See id on GET accounting/accounts/:id. It can be overridden per reason code. Absent when the rule assigns none. |
| `items[].accounts.inventoryAdjustmentLossAccountId` | string | no | The account for negative inventory count and adjustment differences. See id on GET accounting/accounts/:id. It can be overridden per reason code. Absent when the rule assigns none. |
| `items[].accounts.revaluationGainAccountId` | string | no | The account for gains from inventory revaluation. See id on GET accounting/accounts/:id. Absent when the rule assigns none. |
| `items[].accounts.revaluationLossAccountId` | string | no | The account for losses from inventory revaluation. See id on GET accounting/accounts/:id. Absent when the rule assigns none. |
| `items[].accounts.soldQuantitiesRevaluationAccountId` | string | no | The account for the revaluation of quantities already sold. See id on GET accounting/accounts/:id. Absent when the rule assigns none. |
| `items[].accounts.purchaseReturnVarianceGainAccountId` | string | no | The account for gains on purchase returns. See id on GET accounting/accounts/:id. It can be overridden per reason code. Absent when the rule assigns none. |
| `items[].accounts.purchaseReturnVarianceLossAccountId` | string | no | The account for losses on purchase returns. See id on GET accounting/accounts/:id. It can be overridden per reason code. Absent when the rule assigns none. |
| `items[].accounts.fxRateDiffAccountId` | string | no | The account that absorbs FX rate differences between receipt and invoice posting. See id on GET accounting/accounts/:id. Absent when the rule assigns none. |
| `items[].reasonCodeOverrides` | array of object | yes | The per-reason-code account overrides, ordered by id. An empty array when the rule has none. When a document line uses one of these reason codes, its account replaces the rule account named by parentAccountType. It is not returned by the collection GET inventory/account-determination-rules. |
| `items[].reasonCodeOverrides[].id` | string | yes | The unique identifier for the override. updateReasonCodeOverrides and deleteReasonCodeOverrides address it on PATCH. |
| `items[].reasonCodeOverrides[].reasonCodeId` | string | yes | The reason code that triggers this override. See id on GET inventory/reason-codes/:id. |
| `items[].reasonCodeOverrides[].accountId` | string | yes | The account posted instead of the rule account. See id on GET accounting/accounts/:id. |
| `items[].reasonCodeOverrides[].parentAccountType` | string, one of `"inventoryAdjustmentGainAccount"`, `"inventoryAdjustmentLossAccount"`, `"salesReturnAccount"`, `"purchaseReturnVarianceGainAccount"`, `"purchaseReturnVarianceLossAccount"`, `"grncClearingAccount"` | yes | Which rule account this override replaces. Only six of the twenty accounts can be overridden. |
| `items[].lastModifiedDate` | string (date-time) | no | The date and time the rule header last changed, in UTC. Format YYYY-MM-DDTHH:mm:ss.sssZ. Adding or changing a reason-code override does not change it. |
| `pagination` | object | yes | The pagination cursor for this page. |
| `pagination.nextCursor` | string | no | The cursor for the next page. Pass it as page.cursor. Absent on the last page. |
| `pagination.hasMore` | boolean | yes | True when more rules remain beyond this page. |

## Statuses

- `400` — Invalid request or business failure
- `401` — Missing or invalid access token
- `403` — Not authorized
- `404` — Not found
- `429` — Too many requests
- `500` — Internal server error
