Create, update, complete or delete an assembly

distru-mutate-assemblyWriteMetrc

Creates, updates, completes or deletes one manufacturing assembly. Completing a Metrc output creates its package in Metrc; a Metrc processing job is created in Metrc, adjusted when its inputs change and finished when the assembly completes.

Inputs

Every tool also takes the common inputs.

FieldTypeRequiredDescription
actionenum
CREATEUPDATEDELETE
Yes
idstringNoRequired for UPDATE and DELETE. Resolve via distru-search-assemblies.
statusenum
PENDINGCOMPLETED
NoCREATE defaults to PENDING. COMPLETED completes every output and input: consumes the inputs and makes each output's package (in Metrc, with its tag, for a Metrc product) or batch; on a processing job it needs metrcProcessingJob.notes and finishes the job in Metrc. Can't go back to PENDING.
descriptionstringNo
colorenum or null
18 values
REDLIGHT_REDORANGELIGHT_ORANGEGOLDYELLOWGREENLIGHT_GREENBLUELIGHT_BLUECYANLIGHT_CYANINDIGOLIGHT_INDIGOPURPLELIGHT_PURPLEGRAYLIGHT_GRAY
NoCalendar color. Null, or omitted when creating, gives the company's default assembly color. Set only when the user asks for one.
estimatedStartDatetimestringNoPlanned start; Distru records no actual start. ISO 8601 with a UTC offset, e.g. "2026-09-01T00:00:00-07:00"; the company timezone is on distru-get-me.
estimatedWorkMinutesintegerNo
ownerIdstringNoDefaults to the caller. Resolve via distru-search-users.
outputLocationIdstringNoWhere outputs without their own locationId are made; their location's license is the assembly's. Not stored: on UPDATE a new output needs it again or its own locationId. Resolve via distru-search-locations.
metrcProcessingJobobjectNoMakes the assembly a Metrc processing job; only on a license that records them. It is created in Metrc, adjusted when its inputs change and finished with its waste when the assembly completes.
metrcProcessingJob.namestringNoUnique on the license. Set with typeId; frozen once set. Metrc text: ASCII letters, digits, spaces and .,:?'!@#$%^&*()[]/\|>+-_ only, and never the sequence ().
metrcProcessingJob.typeIdstringNoMetrc processing job type. Set with name; frozen once set. Resolve via distru-search-metrc-processing-job-types (licenseId).
metrcProcessingJob.notesstringNoRequired to complete the assembly. Metrc text: ASCII letters, digits, spaces and .,:?'!@#$%^&*()[]/\|>+-_ only, and never the sequence ().
metrcProcessingJob.wasteobjectNoReported to Metrc when the job finishes; editable only while PENDING. Each quantity goes with its Metrc unit name (e.g. Grams) and stays below what the inputs total in that kind of unit.
metrcProcessingJob.waste.countQuantitystring or numberNo
metrcProcessingJob.waste.countUnitNamestringNo
metrcProcessingJob.waste.volumeQuantitystring or numberNo
metrcProcessingJob.waste.volumeUnitNamestringNo
metrcProcessingJob.waste.weightQuantitystring or numberNo
metrcProcessingJob.waste.weightUnitNamestringNo
outputsobject[] or nullNoRequired for CREATE. On UPDATE the complete list: stored outputs left out are deleted with their inputs; send a stored output with just its id to keep it unchanged. Omitted or null leaves the outputs as they are. Read current rows with distru-get-assembly first (includeAssemblyLines); packages there is output only.
outputs[].idstringNoUPDATE only: an output line already on the assembly; only the fields sent change, and a grouped line stands for all its packages. Omit to add one.
outputs[].productIdstringNoRequired to add an output. Resolve via distru-search-products.
outputs[].quantitystring or numberNoIn the product's unit type. Required to add an output, unless each of its packages has its own. On a group, each package's, except those that send their own.
outputs[].locationIdstringNoWhere this output is made; overrides outputLocationId. Resolve via distru-search-locations.
outputs[].statusenum
PENDINGCOMPLETED
NoOnly on a Metrc processing job, for a package-tracked output: COMPLETED creates this output's packages in Metrc now (with their tags) and consumes its inputs while the assembly stays PENDING. Every other output completes with the assembly: set the assembly's status instead. Can't be undone.
outputs[].batchIdstringNoExisting batch the output joins (batch-tracked products); omitted: a new batch (batch-tracked) or the product's default batch. Resolve via distru-search-batches.
outputs[].batchNumberstringNoThe package's free-text batch number, not a Distru batch.
outputs[].expirationDatestringNoUse-by date of the package. ISO 8601 with a UTC offset, e.g. "2026-09-01T00:00:00-07:00"; the company timezone is on distru-get-me.
outputs[].packageDatestringNoWithin 360 days of today; defaults to today.
outputs[].manufacturedDatestringNoPackage-tracked products only, not in the future. Omitted: with useSameItem and no productionBatchNumber, the oldest input package's; else today, or packageDate when earlier.
outputs[].metrcLabelstringNoAn unused Metrc package tag on the license of the output's location. Required to complete a Metrc output; may be set while PENDING to reserve it. Resolve via distru-search-available-metrc-tags (licenseId). Not on a group: its tags go on packages.
outputs[].metrcItemIdstringNoThe Metrc item the package gets. A Metrc output takes exactly one of metrcItemId, pendingMetrcItemId or useSameItem; others take none. Resolve via distru-search-metrc-items (licenseId).
outputs[].pendingMetrcItemIdstringNoA Metrc item Distru has queued but Metrc hasn't created yet. Resolve via distru-search-pending-metrc-items.
outputs[].useSameItembooleanNoThe package takes its input package's Metrc item; for repackaging the same product.
outputs[].metrcLocationIdstringNoMetrc room for the package. Only on a license whose Metrc facility can assign locations to packages; any other license refuses it (must be blank), and omitting it is never refused. A location's metrcLocation from distru-search-locations is no reason to send it: send it only when the user names a Metrc room. Resolve via distru-search-metrc-locations (licenseId).
outputs[].metrcNotesstringNoPackage note sent to Metrc.
outputs[].productionBatchNumberstring or nullNoMarks the output a Metrc production batch (lab-testing and traceability consequences), so set it only when it is one. Required on every output of a processing job; on a license that records processing jobs, allowed only on one. null clears. Metrc text: ASCII letters, digits, spaces and .,:?'!@#$%^&*()[]/\|>+-_ only, and never the sequence ().
outputs[].isFinishedGoodbooleanNoMetrc finished good (states that use it); count-based units only.
outputs[].isTradeSamplebooleanNoMetrc trade sample.
outputs[].packagesobject[]NoMakes a group of Metrc packages (package-tracked Metrc products) from this line, one entry per package with its tag and, when they differ, its size; it comes back as one line with packages[]. When the packages are the same size, each consumes this line's inputs and costs as sent: an input quantity of 3.5 with 50 packages takes 175 from its package. When they differ, each input's and cost's quantity is the group's total, which Distru splits between the packages by size. On UPDATE the complete list for the group: each package kept by its id (with only what changes), new ones without; packages left out are deleted with their share of inputs and costs. Can't add a package once one of the group is completed, nor drop a completed one. New sizes keep the totals of the inputs and costs not sent or sent by id alone, and a call that resizes packages that already differ takes the new totals too. Only a call that turns same-size packages into different sizes, or back, can't also carry input or cost quantities, as their meaning changes with it: that change alone first, then the quantities. An assembly holds at most 300 packages, 2,000 inputs and 1,000 costs, each package's counted.
outputs[].packages[].idstringNoUPDATE only: a package already in this line's group (its packages[].id in distru-get-assembly); only the fields sent change. Omit to add a package.
outputs[].packages[].metrcLabelstringNoThis package's unused Metrc tag, on the license of the output's location. Required to complete it. Resolve via distru-search-available-metrc-tags (licenseId).
outputs[].packages[].quantitystring or numberNoThis package's size, in the product's unit type. Omitted: the line's quantity, else (a stored package) its own. A new package needs it when the line sends no quantity and its group's packages differ in size.
outputs[].packageCountintegerNoIn place of packages while their tags aren't known: makes this many packages of the line's quantity. On UPDATE a larger number adds packages, a smaller one drops the last ones. Send packages, each with its metrcLabel, to complete them.
outputs[].inputsobject[] or nullNoWhat this output consumes; on a group, what each package consumes (the group's totals when its packages differ in size). Required to add an output: every output consumes at least one input. On UPDATE the complete list for this output: stored inputs left out are deleted and their stock released; send a stored input with just its id to keep it. Omitted or null leaves them as they are. Read current rows with distru-get-assembly first (includeAssemblyLines).
outputs[].inputs[].idstringNoUPDATE only: an input already on this output; only the fields sent change. Omit to add one.
outputs[].inputs[].packageIdstringNoConsume from this package (package-tracked products); its product, batch and location follow. Resolve via distru-search-packages.
outputs[].inputs[].batchIdstringNoConsume from this batch (batch- and product-tracked products); its product follows. Resolve via distru-search-batches.
outputs[].inputs[].productIdstringNoA new input takes one of packageId, batchId or productId. Alone: a DRAFT input, or stock of a product-tracked product at locationId. Resolve via distru-search-products.
outputs[].inputs[].quantitystring or numberNoIn the input product's unit type (convert a bill of materials' anyProductMatching quantity from its unitType): what this output consumes in total; on a group (packages), what each package consumes, or, when its packages differ in size, the group's total, split by size. Required to add an input.
outputs[].inputs[].locationIdstringNoWhere the stock is taken from. Omitted on a package input: the package's; required otherwise. Resolve via distru-search-locations.
outputs[].inputs[].statusenum
PENDINGDRAFT
NoPENDING (default) claims the stock now, so the input needs its package or batch and enough stock. DRAFT plans a quantity of productId at locationId, claiming none; before the assembly completes, send it by id with its packageId or batchId and status PENDING. Never DRAFT when the stock should be claimed.
outputs[].costsobject[] or nullNoCosts added on this output (labor, packaging, every cost of its product's bill of materials), carried into what it makes when it completes; on a group, each package's (the group's totals when its packages differ in size). On UPDATE the complete list for this output: stored costs left out are deleted; send a stored cost with just its id to keep it. Omitted or null leaves them as they are. Needs the permission to apply costs to assemblies. Read current costs with distru-get-assembly (includeOutputAddedCosts).
outputs[].costs[].idstringNoUPDATE only: a cost already on this output (its addedCosts[].id); only the fields sent change. Omit to add one.
outputs[].costs[].costTypeIdstringNoRequired to add a cost. Resolve via distru-search-lookups (type COST_TYPE).
outputs[].costs[].quantitystring or numberNoIn the cost type's unit type, e.g. hours of labor: the total for this output; on a group (packages), each package's, or, when its packages differ in size, the group's total, split by size. A bill of materials gives it per unit. Required to add a cost.
outputs[].costs[].costPerUnitstring or numberNoDefaults to the cost type's; only a cost type that allows inline edits takes another.
outputs[].costs[].descriptionstringNo
customFieldsobject[]NoOnly the fields listed change. Required custom fields must be set, on update too, while still blank.
customFields[].customFieldIdstringYesResolve via distru-search-custom-fields (entityType ASSEMBLY).
customFields[].valuestring or string[]YesTEXT: the text. DROPDOWN: the option name. CHECKBOX: an array of option names. DATE: YYYY-MM-DD, company timezone. "" or [] clears the field.

Output

This tool returns one of 2 shapes, depending on its inputs.

Presence on a nested field assumes its parent exists.

Result with assembly

FieldTypePresenceDescription
assemblyobjectAlways
assembly.idstringAlways
assembly.customFieldsobject[]Always
assembly.customFields[].customFieldobjectAlways
assembly.customFields[].customField.idstringAlways
assembly.customFields[].customField.namestringAlways
assembly.customFields[].customField.fieldTypeenum
CHECKBOXDATEDROPDOWNTEXT
Always
assembly.customFields[].valuestringCan be null
assembly.numberstringAlways
assembly.colorenum
18 values
REDLIGHT_REDORANGELIGHT_ORANGEGOLDYELLOWGREENLIGHT_GREENBLUELIGHT_BLUECYANLIGHT_CYANINDIGOLIGHT_INDIGOPURPLELIGHT_PURPLEGRAYLIGHT_GRAY
Can be nullCalendar color. A record saved without one shows the company's default.
assembly.statusenum
COMPLETEDPENDING
Always
assembly.complianceTypeenum
BIOTRACKMETRCNONE
Always
assembly.descriptionstringCan be null
assembly.coststringCan be null
assembly.estimatedStartDatestringCan be null
assembly.estimatedWorkMinutesnumberCan be null
assembly.completedAtstringCan be null
assembly.createdDatestringAlways
assembly.updatedDatestringAlways
assembly.licenseobjectCan be null
assembly.license.idstringAlways
assembly.license.licenseNumberstringAlways
assembly.ownerobjectCan be null
assembly.owner.idstringAlways
assembly.owner.emailstringAlways
assembly.owner.profileobjectAlways
assembly.owner.profile.fullNamestringAlways
assembly.kindenum
MANUFACTURINGPACKAGE_SPLITTEST_SAMPLESALES_ORDER_REPACKAGE
Always
assembly.metrcProcessingJobobjectCan be null
assembly.metrcProcessingJob.namestringCan be null
assembly.metrcProcessingJob.typeIdstringCan be null
assembly.metrcProcessingJob.typeobjectCan be null
assembly.metrcProcessingJob.type.idstringAlways
assembly.metrcProcessingJob.type.namestringAlways
assembly.metrcProcessingJob.metrcIdstringCan be null
assembly.metrcProcessingJob.notesstringCan be null
assembly.metrcProcessingJob.wasteobjectAlways
assembly.metrcProcessingJob.waste.countQuantitystringCan be null
assembly.metrcProcessingJob.waste.countUnitNamestringCan be null
assembly.metrcProcessingJob.waste.volumeQuantitystringCan be null
assembly.metrcProcessingJob.waste.volumeUnitNamestringCan be null
assembly.metrcProcessingJob.waste.weightQuantitystringCan be null
assembly.metrcProcessingJob.waste.weightUnitNamestringCan be null
assembly.assemblyOutputsobject[]Always
assembly.assemblyOutputs[].idstringAlways
assembly.assemblyOutputs[].statusenum
COMPLETEDPENDING
Always
assembly.assemblyOutputs[].quantitystringCan be nullIn the product's unit type; for an output group, each package's. Null when the group's packages differ in size: read each one's in packages[].
assembly.assemblyOutputs[].metrcLabelstringCan be null
assembly.assemblyOutputs[].batchNumberstringCan be null
assembly.assemblyOutputs[].expirationDatestringCan be null
assembly.assemblyOutputs[].packageDatestringCan be null
assembly.assemblyOutputs[].manufacturedDatestringCan be null
assembly.assemblyOutputs[].productionBatchNumberstringCan be null
assembly.assemblyOutputs[].useSameItembooleanAlways
assembly.assemblyOutputs[].isFinishedGoodbooleanAlways
assembly.assemblyOutputs[].isTradeSamplebooleanCan be null
assembly.assemblyOutputs[].metrcItemobjectCan be null
assembly.assemblyOutputs[].metrcItem.idstringAlways
assembly.assemblyOutputs[].metrcItem.namestringAlways
assembly.assemblyOutputs[].pendingMetrcItemobjectCan be null
assembly.assemblyOutputs[].pendingMetrcItem.idstringAlways
assembly.assemblyOutputs[].pendingMetrcItem.namestringAlways
assembly.assemblyOutputs[].productobjectAlways
assembly.assemblyOutputs[].product.idstringAlways
assembly.assemblyOutputs[].product.namestringAlways
assembly.assemblyOutputs[].product.unitTypeobjectAlways
assembly.assemblyOutputs[].product.unitType.idstringAlways
assembly.assemblyOutputs[].product.unitType.namestringAlways
assembly.assemblyOutputs[].batchobjectCan be null
assembly.assemblyOutputs[].batch.idstringAlways
assembly.assemblyOutputs[].batch.namestringAlways
assembly.assemblyOutputs[].locationobjectCan be null
assembly.assemblyOutputs[].location.idstringAlways
assembly.assemblyOutputs[].location.namestringAlways
assembly.assemblyOutputs[].packageobjectCan be null
assembly.assemblyOutputs[].package.idstringAlways
assembly.assemblyOutputs[].package.metrcLabelstringAlways
assembly.assemblyOutputs[].packageUnitTypeobjectCan be null
assembly.assemblyOutputs[].packageUnitType.idstringAlways
assembly.assemblyOutputs[].packageUnitType.namestringAlways
assembly.assemblyOutputs[].complianceQuantitystringCan be nullIn the output's packageUnitType, as tracked in Metrc; null when complianceType is NONE or the group's packages differ in size.
assembly.assemblyOutputs[].packageCountintegerAlwaysPackages this line makes: more than 1 for an output group. When its packages are the same size, quantity, assemblyInputs and addedCosts are per package (multiply by packageCount for the group's total). When they differ (quantity null), sizes are in packages[], and assemblyInputs and addedCosts are the group's totals, split between the packages by size; their ids are the first package's.
assembly.assemblyOutputs[].packagesobject[]Can be nullEach package of an output group, lowest ID first; null for a single package.
assembly.assemblyOutputs[].packages[].idstringAlways
assembly.assemblyOutputs[].packages[].statusenum
COMPLETEDPENDING
Always
assembly.assemblyOutputs[].packages[].metrcLabelstringCan be null
assembly.assemblyOutputs[].packages[].quantitystringAlways
assembly.assemblyOutputs[].packages[].complianceQuantitystringCan be null
assembly.assemblyOutputs[].packages[].packageobjectCan be null
assembly.assemblyOutputs[].packages[].package.idstringAlways
assembly.assemblyOutputs[].packages[].package.metrcLabelstringAlways
assembly.assemblyOutputs[].assemblyInputsobject[]Can be absent
assembly.assemblyOutputs[].assemblyInputs[].idstringAlways
assembly.assemblyOutputs[].assemblyInputs[].statusenum
COMPLETEDDRAFTPENDING
Always
assembly.assemblyOutputs[].assemblyInputs[].quantitystringAlways
assembly.assemblyOutputs[].assemblyInputs[].productobjectAlways
assembly.assemblyOutputs[].assemblyInputs[].product.idstringAlways
assembly.assemblyOutputs[].assemblyInputs[].product.namestringAlways
assembly.assemblyOutputs[].assemblyInputs[].product.unitTypeobjectAlways
assembly.assemblyOutputs[].assemblyInputs[].product.unitType.idstringAlways
assembly.assemblyOutputs[].assemblyInputs[].product.unitType.namestringAlways
assembly.assemblyOutputs[].assemblyInputs[].batchobjectCan be null
assembly.assemblyOutputs[].assemblyInputs[].batch.idstringAlways
assembly.assemblyOutputs[].assemblyInputs[].batch.namestringAlways
assembly.assemblyOutputs[].assemblyInputs[].locationobjectCan be null
assembly.assemblyOutputs[].assemblyInputs[].location.idstringAlways
assembly.assemblyOutputs[].assemblyInputs[].location.namestringAlways
assembly.assemblyOutputs[].assemblyInputs[].packageobjectCan be null
assembly.assemblyOutputs[].assemblyInputs[].package.idstringAlways
assembly.assemblyOutputs[].assemblyInputs[].package.metrcLabelstringAlways
assembly.assemblyOutputs[].assemblyInputs[].package.unitTypeobjectAlways
assembly.assemblyOutputs[].assemblyInputs[].package.unitType.idstringAlways
assembly.assemblyOutputs[].assemblyInputs[].package.unitType.namestringAlways
assembly.assemblyOutputs[].assemblyInputs[].complianceQuantitystringCan be null
assembly.assemblyOutputs[].addedCostsobject[]Can be absent
assembly.assemblyOutputs[].addedCosts[].idstringAlways
assembly.assemblyOutputs[].addedCosts[].namestringAlways
assembly.assemblyOutputs[].addedCosts[].descriptionstringCan be null
assembly.assemblyOutputs[].addedCosts[].costTypeobjectCan be null
assembly.assemblyOutputs[].addedCosts[].costType.idstringAlways
assembly.assemblyOutputs[].addedCosts[].costType.namestringAlways
assembly.assemblyOutputs[].addedCosts[].insertedAtstringAlways
assembly.assemblyOutputs[].addedCosts[].quantitystringAlways
assembly.assemblyOutputs[].addedCosts[].unitTypeobjectAlways
assembly.assemblyOutputs[].addedCosts[].unitType.idstringAlways
assembly.assemblyOutputs[].addedCosts[].unitType.namestringAlways
assembly.assemblyOutputs[].addedCosts[].costPerUnitstringCan be null
assembly.assemblyOutputs[].addedCosts[].totalCoststringCan be null

Result with id

FieldTypePresence
idstringAlways
What the AI reads

Creates, updates, completes or deletes one manufacturing assembly: a job that consumes inputs (packages, batches or products) and makes outputs, each output with the inputs it consumes. While PENDING, inputs claim their stock (a DRAFT input only plans a quantity). Completing the assembly (status COMPLETED) completes every output and input: it consumes the inputs and makes each output's package (created in Metrc with its tag, for a Metrc product) or batch. Completion can't be undone, and a completed assembly can't be deleted or changed beyond its description, color, owner, estimatedWorkMinutes and custom fields. Several Metrc packages from one output: packages, one entry per package with its tag (and its size when they differ); they come back as one output line with packages[]. To split one package into packages of the same product use distru-split-package. A Metrc processing job (metrcProcessingJob) is finished in Metrc with its waste when the assembly completes; its package outputs may complete one at a time before that. Unless the user names the inputs, read each output product's bill of materials first (distru-get-product includeBillOfMaterials) and send all of it, inputs and costs; its quantities are per unit, so multiply by the output's quantity. DELETE removes a pending assembly with no completed output for good and releases what its inputs claimed. CREATE and UPDATE return the assembly as distru-get-assembly does with includeAssemblyLines and includeOutputAddedCosts; DELETE returns its id. Sparse update: on UPDATE only the fields passed change; outputs, and inputs and costs on an output, replace the whole list when passed — read the assembly with distru-get-assembly first and resend every row you keep.