# Search reason codes

Operation ID: `searchReasonCodes`

Group: Inventory › Reason Codes

[Open in the interactive reference](https://docs.api.lensing.ai/lensing/v1/endpoints/searchReasonCodes)

`POST /inventory/reason-codes/search`

Read-only: A read that takes its filters in the body. Changes nothing, and ignores Idempotency-Key.

Searches reason codes. Each matching reason code comes back with documentTypes, the document types it can be selected on. The filters include documentType.

The collection GET inventory/reason-codes neither returns documentTypes nor filters by document type.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `Api-Version` | header | string · 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`: searchReasonCodesInput.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `filters` | object | yes | The filters to apply. A reason code must match every filter you send. Send an empty object to return all reason codes. Example: `{"documentType":"InventoryDecrease","isActive":true}`. |
| `filters.code` | string | no | Limits results to the reason code with this code. The match is exact. Codes are unique, so this matches at most one reason code. |
| `filters.isActive` | boolean | no | Limits results to reason codes that can be selected on new documents when true, or to retired ones when false. Omit to match both. |
| `filters.requiresApproval` | boolean | no | Limits results to reason codes that require approval when true, or that do not when false. Omit to match both. |
| `filters.documentType` | any | no | Limits results to the reason codes linked to this document type. This filter is available only here, not on the collection. A document type nothing is linked to returns an empty page, not an error. One of: `"InventoryIncrease"`, `"InventoryDecrease"`, `"SalesReturn"`, `"PurchaseReturn"`, `"Disposal"`. |
| `filters.modifiedSince` | date-time | no | Limits results to reason codes changed on or after this time. Format YYYY-MM-DDTHH:mm:ss.sssZ. Adding or removing a document type does not change lastModifiedDate. |
| `page` | object | no | The pagination controls. Omit for the first page. Example: `{"size":50}`. |
| `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 reason codes per page. Defaults to 50. A value above 200 is treated as 200, not rejected. |

```json
{
  "filters": {
    "documentType": "InventoryDecrease",
    "isActive": true
  },
  "page": {
    "size": 50
  }
}
```

## Response

`200` Success

Under `data` (searchReasonCodesOutput):

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `items` | array<object> | yes | The reason codes on this page, ordered by id. An empty array when nothing matches. Example: `[{"id":"7a1c9e42-8b30-4d67-9f15-3c8e02a74b61","code":"DAMAGE","description":"Stock damaged in the warehouse","isActive":true,"requiresApproval":true,"documentTypes":["InventoryDecrease","SalesReturn"],"lastModifiedDate":"2026-05-12T09:30:00.000Z"}]`. |
| `items[].id` | string | yes | The unique identifier for the reason code. |
| `items[].code` | string | yes | The business code of the reason code, for example 'DAMAGE'. It is unique within the tenant. |
| `items[].description` | string | no | A free-form description of what the reason code means. Absent when none was given. |
| `items[].isActive` | boolean | no | Whether the reason code can be selected on new documents. When false, existing documents keep it and new ones cannot select it. |
| `items[].requiresApproval` | boolean | no | Whether documents using this reason code require approval before they take effect. |
| `items[].documentTypes` | array<any> | yes | The document types this reason code may be selected on, in a stable order. An empty array when it is linked to none. This is the reason code's full set. Filtering by documentType narrows which reason codes are returned, not the set each one reports. |
| `items[].lastModifiedDate` | date-time | no | The date and time the reason code record last changed, in UTC. Format YYYY-MM-DDTHH:mm:ss.sssZ. Adding or removing a document type does not change it. |
| `pagination` | object | yes | The pagination cursor for this page. Example: `{"hasMore":false}`. |
| `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 reason codes remain beyond this page. |

```json
{
  "data": {
    "items": [
      {
        "id": "7a1c9e42-8b30-4d67-9f15-3c8e02a74b61",
        "code": "DAMAGE",
        "description": "Stock damaged in the warehouse",
        "isActive": true,
        "requiresApproval": true,
        "documentTypes": [
          "InventoryDecrease",
          "SalesReturn"
        ],
        "lastModifiedDate": "2026-05-12T09:30:00.000Z"
      }
    ],
    "pagination": {
      "hasMore": false
    }
  },
  "diagnostics": [
    {
      "code": "<code>",
      "message": "<message>",
      "severity": "error",
      "path": [
        "<path>"
      ],
      "details": "<details>"
    }
  ]
}
```

## Statuses

- `400` — Invalid request or business failure
- `401` — The request carries no valid access token.
- `403` — Not authorized
- `404` — Not found
- `429` — Too many requests from this client address. The response has no body and no `Retry-After` header.
- `500` — Internal server error
