Search batches

distru-search-batchesRead

Searches 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.

FieldTypeRequiredDescription
limitintegerNoDefault: 10
cursorstringNonextCursor of the previous call; keep the other arguments unchanged.
idsstring[]NoBatch IDs.
productIdsstring[]NoResolve via distru-search-products.
productCategoryIdsstring[]NoProduct 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).
productSubcategoryIdsstring[]NoProduct subcategory of the batches. See productCategoryIds. Resolve via distru-search-lookups (type PRODUCT_CATEGORY, each row's subcategories).
productTagIdsstring[]NoAny of these tags on the product. Resolve via distru-search-lookups (type PRODUCT_TAG).
vendorIdsstring[]NoThe vendor set on the product, not the company an order was placed with. Resolve via distru-search-companies.
brandIdsstring[]NoProduct brand of the batches, itself a company. Resolve via distru-search-companies, or read it on a distru-search-products row.
productGroupIdsstring[]NoResolve via distru-search-lookups (type PRODUCT_GROUP).
productStatusenum
ACTIVEANYINACTIVE
NoThe product's active state, not the batch's. Default ACTIVE.
searchstringNoCase-insensitive substring of batch name, batch number, product name or SKU. Ranks by batch-name similarity; sortBy ignored.
customFieldsobject[]NoSet one of contains, anyOf or onOrAfter/onOrBefore per entry. Records with no value for the field never match.
customFields[].customFieldIdstringYesResolve via distru-search-custom-fields.
customFields[].containsstringNoTEXT: case-insensitive substring.
customFields[].anyOfstring[]NoDROPDOWN, CHECKBOX: any of these options, case-sensitive.
customFields[].onOrAfterstringNoDATE: YYYY-MM-DD, company timezone.
customFields[].onOrBeforestringNoDATE: YYYY-MM-DD, company timezone.
thcPercentageTotalobjectNoFilter 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.minstring or numberNoLowest total THC percentage to keep, inclusive.
thcPercentageTotal.maxstring or numberNoHighest total THC percentage to keep, inclusive.
sortByobjectNoDefault: most recently updated first. Ignored when search is set.
sortBy.directionenum
ASCDESC
Yes
sortBy.fieldenum
BATCH_NUMBERINSERTED_ATUPDATED_AT
YesBATCH_NUMBER puts batches without one last, both directions.

Output

Presence on a nested field assumes its parent exists.

FieldTypePresence
hasMorebooleanAlways
nextCursorstringCan be absent
totalCountintegerCan be absent
itemsobject[]Always
items[].idstringAlways
items[].customFieldsobject[]Always
items[].customFields[].customFieldobjectAlways
items[].customFields[].customField.idstringAlways
items[].customFields[].customField.namestringAlways
items[].customFields[].customField.fieldTypeenum
CHECKBOXDATEDROPDOWNTEXT
Always
items[].customFields[].valuestringCan be null
items[].namestringAlways
items[].batchNumberstringCan be null
items[].manufacturedDatestringAlways
items[].harvestDatestringCan be null
items[].expirationDatestringCan be null
items[].quantitystringAlways
items[].activeQuantityCoststringCan be null
items[].productobjectAlways
items[].product.idstringAlways
items[].product.namestringAlways
items[].product.skustringAlways
items[].product.inactivebooleanAlways
items[].product.unitTypeobjectAlways
items[].product.unitType.idstringAlways
items[].product.unitType.namestringAlways
items[].activeQuantitiesByLocationobject[]Always
items[].activeQuantitiesByLocation[].locationobjectAlways
items[].activeQuantitiesByLocation[].location.idstringAlways
items[].activeQuantitiesByLocation[].location.namestringAlways
items[].activeQuantitiesByLocation[].quantitystringAlways
items[].primaryTestResultobjectCan be null
items[].primaryTestResult.idstringAlways
items[].primaryTestResult.namestringAlways
items[].primaryTestResult.labNamestringCan be null
items[].primaryTestResult.releaseDatestringCan be null
items[].primaryTestResult.thcPercentagestringCan be null
items[].primaryTestResult.thcPercentageTotalstringCan be null
items[].primaryTestResult.cbdPercentagestringCan be null
items[].primaryTestResult.cbdPercentageTotalstringCan 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.