Search packages

distru-search-packagesRead

Searches inventory packages — the physical containers stock is held in, each carrying its compliance tag where the product is package-tracked.

Inputs

Every tool also takes the common inputs.

FieldTypeRequiredDescription
limitintegerNoDefault: 10
cursorstringNonextCursor of the previous call; keep the other arguments unchanged.
idsstring[]NoPackage IDs.
licenseIdsstring[]NoResolve via distru-search-licenses.
locationIdsstring[]NoResolve via distru-search-locations.
productIdsstring[]NoResolve via distru-search-products.
productCategoryIdsstring[]NoProduct category of the packages. 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 packages. 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 packages, 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).
searchstringNoCase-insensitive substring of Metrc label or product name/SKU, plus fuzzy match on product name. A full-length Metrc label is looked up exactly. Ranks label matches first, then by product-name similarity; sortBy ignored.
statusenum
ACTIVEANYINACTIVE
NoDefault ACTIVE, or ANY when ids is set. INACTIVE = hidden in Distru via distru-bulk-update-packages isActive; still active in Metrc.
distruStatusesenum[]
ACTIVEASSEMBLINGDESTROYEDDISCONTINUEDFINISHEDON_HOLDRETURNINGSELLINGSOLDTRANSFERRED
NoACTIVE = sellable on-hand; ASSEMBLING, SELLING, RETURNING = committed to work in progress; DESTROYED, FINISHED, SOLD, TRANSFERRED, DISCONTINUED = gone. SOLD and TRANSFERRED keep the quantity they left with, so they match withQuantity true, not false.
withQuantitybooleanNoHas quantity > 0, whatever its Distru status; false = quantity 0 (emptied by use, not SOLD or TRANSFERRED, which keep their last quantity). Default true, except no quantity filter when ids is set or search looks like a full compliance tag (16+ letters/digits, no spaces).
isTestSamplebooleanNotrue: only lab test sample packages; false: excludes them.
hasTestResultbooleanNotrue: packages with a test result, primary or not, own or inherited; false: packages with none.
labTestingStatesenum[]
FAILEDNOT_TESTEDPASSEDPENDING
NoPASSED = test or retest passed; FAILED = test or retest failed; NOT_TESTED = not sampled or testing not required, and every package not tracked in Metrc; PENDING = anything else: sampled and awaiting results, remediated and awaiting a retest, or only R&D tests done.
isFinishedGoodbooleanNoMetrc's finished-good flag. Packages on licenses that can't set it are left out either way.
syncingbooleanNoHas a change still being sent to Metrc. For why, use distru-get-package.
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 packages 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_NUMBERCOMPLIANCE_LABELEXPIRATION_DATEINSERTED_ATQUANTITYUPDATED_AT
YesBATCH_NUMBER = the package's own grouping label, not the linked Distru batch. BATCH_NUMBER and EXPIRATION_DATE put packages 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[].metrcLabelstringAlways
items[].complianceTypeenum
BIOTRACKMETRCNONE
Always
items[].metrcIdnumberCan be null
items[].complianceProductNamestringCan be null
items[].complianceStrainNamestringCan be null
items[].distruStatusenum
ACTIVEASSEMBLINGDESTROYEDDISCONTINUEDFINISHEDON_HOLDRETURNINGSELLINGSOLDTRANSFERRED
Always
items[].isActivebooleanAlways
items[].syncingbooleanAlways
items[].batchNumberstringCan be null
items[].compliancePackagedDatestringCan be null
items[].harvestDatestringCan be null
items[].expirationDatestringCan be null
items[].finishedAtstringCan be null
items[].insertedAtstringAlways
items[].updatedAtstringAlways
items[].isTestSamplebooleanAlways
items[].isTradeSamplebooleanAlways
items[].isFinishedGoodbooleanCan be null
items[].labTestingStateenum
FAILEDNOT_TESTEDPASSEDPENDING
Always
items[].labTestingStateDatestringCan be null
items[].quantitystringAlways
items[].quantityActivestringAlways
items[].quantityAssemblingstringAlways
items[].quantityInMetrcstringCan be null
items[].quantityCoststringCan be null
items[].unitTypeobjectAlways
items[].unitType.idstringAlways
items[].unitType.namestringAlways
items[].productobjectAlways
items[].product.idstringAlways
items[].product.namestringAlways
items[].product.skustringAlways
items[].batchobjectAlways
items[].batch.idstringAlways
items[].batch.namestringAlways
items[].locationobjectAlways
items[].location.idstringAlways
items[].location.namestringAlways
items[].licenseobjectAlways
items[].license.idstringAlways
items[].license.licenseNumberstringAlways
items[].activeSalesOrderobjectCan be null
items[].activeSalesOrder.idstringAlways
items[].activeSalesOrder.orderNumberstringAlways
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 packages — the physical containers stock is held in, each carrying its compliance tag where the product is package-tracked. One row per package with its compliance identity, Distru status, lab testing and potency, quantities and quantity cost, and the product, batch, location and license it belongs to. primaryTestResult includes results inherited from the packages it was made from, so skip distru-search-test-results for those. isFinishedGood is Metrc's finished-good flag, null where the package's license can't set it. Use it to resolve a packageId for a package-tracked assembly input and to see where a product actually holds stock; for what one package's quantityCost is made of, use distru-get-package. To narrow by kind of product, filter on its category, subcategory, tags, vendor, brand or group instead of resolving productIds first. Quantities are in the package's unit type: quantity is what the package holds (for a sold or transferred package, what it left with); quantityAssembling is held by pending assemblies; quantityActive is the rest, 0 while the package's stock is selling, returning, sold or transferred. quantityActive does not deduct a sales order until it starts selling the package: activeSalesOrder is the non-canceled, non-merged sales order the package is on, null when there is none or the caller cannot see it. quantityCost is the total cost of the package's current quantity whatever its status, not per unit; null when none is recorded or the caller cannot view costs. metrcId and quantityInMetrc (Metrc's quantity at last sync, in Metrc's unit, may be negative) are null outside Metrc. batchNumber is the package's own free-text grouping label, not the linked Distru batch — which batch a package belongs to is batch.name. A null expirationDate means expiry isn't tracked, not that the package won't expire, so never conclude from nulls that nothing is expiring. isActive false = hidden in Distru only, not a Distru status. Packages of deleted or inactive products are never returned.