Search batches
distru-search-batchesReadSearches inventory batches — the lot a batch-tracked product's stock belongs to; only batches of batch-tracked products are returned.
Inputs
Every tool also takes the common inputs.
| Field | Type | Required | Description |
|---|---|---|---|
| limit | integer | No | Default: 10 |
| cursor | string | No | nextCursor of the previous call; keep the other arguments unchanged. |
| ids | string[] | No | Batch IDs. |
| productIds | string[] | No | Resolve via distru-search-products. |
| productCategoryIds | string[] | No | Product category of the batches. ORed with productSubcategoryIds; a listed subcategory of a listed category narrows that category to it. Resolve via distru-search-lookups (type PRODUCT_CATEGORY). |
| productSubcategoryIds | string[] | No | Product subcategory of the batches. See productCategoryIds. Resolve via distru-search-lookups (type PRODUCT_CATEGORY, each row's subcategories). |
| productTagIds | string[] | No | Any of these tags on the product. Resolve via distru-search-lookups (type PRODUCT_TAG). |
| vendorIds | string[] | No | The vendor set on the product, not the company an order was placed with. Resolve via distru-search-companies. |
| brandIds | string[] | No | Product brand of the batches, itself a company. Resolve via distru-search-companies, or read it on a distru-search-products row. |
| productGroupIds | string[] | No | Resolve via distru-search-lookups (type PRODUCT_GROUP). |
| productStatus | enumACTIVEANYINACTIVE | No | The product's active state, not the batch's. Default ACTIVE. |
| search | string | No | Case-insensitive substring of batch name, batch number, product name or SKU. Ranks by batch-name similarity; sortBy ignored. |
| customFields | object[] | No | Set one of contains, anyOf or onOrAfter/onOrBefore per entry. Records with no value for the field never match. |
| customFields[]. | string | Yes | Resolve via distru-search-custom-fields. |
| customFields[]. | string | No | TEXT: case-insensitive substring. |
| customFields[]. | string[] | No | DROPDOWN, CHECKBOX: any of these options, case-sensitive. |
| customFields[]. | string | No | DATE: YYYY-MM-DD, company timezone. |
| customFields[]. | string | No | DATE: YYYY-MM-DD, company timezone. |
| thcPercentageTotal | object | No | Filter batches by primaryTestResult.thcPercentageTotal, the total THC percentage on their primary test result, e.g. {min: 28} for 28% and up. Records without a primary test result, or whose total THC is not recorded, never match. |
| thcPercentageTotal. | string or number | No | Lowest total THC percentage to keep, inclusive. |
| thcPercentageTotal. | string or number | No | Highest total THC percentage to keep, inclusive. |
| sortBy | object | No | Default: most recently updated first. Ignored when search is set. |
| sortBy. | enumASCDESC | Yes | |
| sortBy. | enumBATCH_NUMBERINSERTED_ATUPDATED_AT | Yes | BATCH_NUMBER puts batches without one last, both directions. |
Output
Presence on a nested field assumes its parent exists.
| Field | Type | Presence |
|---|---|---|
| hasMore | boolean | Always |
| nextCursor | string | Can be absent |
| totalCount | integer | Can be absent |
| items | object[] | Always |
| items[]. | string | Always |
| items[]. | object[] | Always |
| items[]. | object | Always |
| items[]. | string | Always |
| items[]. | string | Always |
| items[]. | enumCHECKBOXDATEDROPDOWNTEXT | Always |
| items[]. | string | Can be null |
| items[]. | string | Always |
| items[]. | string | Can be null |
| items[]. | string | Always |
| items[]. | string | Can be null |
| items[]. | string | Can be null |
| items[]. | string | Always |
| items[]. | string | Can be null |
| items[]. | object | Always |
| items[]. | string | Always |
| items[]. | string | Always |
| items[]. | string | Always |
| items[]. | boolean | Always |
| items[]. | object | Always |
| items[]. | string | Always |
| items[]. | string | Always |
| items[]. | object[] | Always |
| items[]. | object | Always |
| items[]. | string | Always |
| items[]. | string | Always |
| items[]. | string | Always |
| items[]. | object | Can be null |
| items[]. | string | Always |
| items[]. | string | Always |
| items[]. | string | Can be null |
| items[]. | string | Can be null |
| items[]. | string | Can be null |
| items[]. | string | Can be null |
| items[]. | string | Can be null |
| items[]. | string | Can be null |
What the AI reads
Searches inventory batches — the lot a batch-tracked product's stock belongs to; only batches of batch-tracked products are returned. One row per batch with its dates, active quantity across every inventory source and per location, active quantity cost, primary test result potency and product. Use it to resolve a batchId, e.g. for a batch-tracked line on distru-create-assembly; for package-tracked stock use distru-search-packages, and for one batch's cost breakdown use distru-get-batch. Deleted batches are never returned. To narrow by what kind of product, filter on the product's category, subcategory, tags, vendor, brand or group directly instead of resolving productIds first. Quantities are in the product's unit type. activeQuantityCost is the total cost of the active quantity, not per unit; null when none is recorded or the caller cannot view costs.