---
title: "Create a test sample"
method: POST
path: "/public/v1/assemblies/create_test_sample"
tags: ["Assembly"]
---

# Create a test sample

`POST /public/v1/assemblies/create_test_sample`

Pull a quantity from an existing Metrc package into a new test sample package, ready to be
sent to a testing lab.

Creates one already-completed assembly with a single input (the quantity drawn from the
source package) and a single test sample output — the assembly renders with
`creation_source: LAB_TESTING` and its output with `is_test_sample: true`. The drawn quantity is consumed from the
source package's inventory immediately, and the sample package is produced into inventory at
`location_id`. On success the sample is queued for creation in Metrc as a testing package and
synced asynchronously — the Metrc package identifiers are not present in the immediate
response, and the source and sample packages are briefly flagged as syncing. Poll
`GET /public/v1/assemblies/{id}` to observe the synced result.

Metrc licenses only, and the license's Metrc facility must be allowed to create test sample
packages. The whole operation is atomic: if anything is rejected, nothing is changed.

Required permission: `assemblies_permissions_create`.

## Request body

- CreateTestSampleRequest — A Metrc source package and the test sample package to create from it
  - `batch_number` string — Distru batch number stored on the sample package. When omitted, copies the source package's batch number; pass null explicitly to leave the sample without one.
  - `compliance_label` string, required — The Metrc tag for the sample package. Must be an available tag in the source package's license.
  - `expiration_date` string — Expiration date reported to Metrc, e.g. "2027-08-19". When omitted, copies the source package's expiration date; pass null explicitly to leave the sample without one.
  - `input_compliance_quantity` number, required — Amount drawn from the source package, in the source package's compliance unit. Must be > 0.
  - `lab_test_batches` string[] — The Metrc lab test batches to assign to the sample, by exact name. Valid names depend on the license and the sample item's Metrc product category — list them with [GET /public/v1/metrc/lab-test-batches](#get-metrc-lab-test-batches), which groups them by item category and marks the ones Metrc requires. Every `required: true` batch must be included; an unknown or disallowed name is rejected. Omit entirely when the license's facility does not use package sample lab test batches. At most 200 items.
  - `location_id` string — The location ID the sample package is produced into. Must be in the same Metrc license as the source package. Defaults to the source package's location when omitted or null.
  - `metrc_item_id` integer — The Metrc item id for the sample. Required unless use_same_item is true, and must be omitted when it is. Must exist in the source package's Metrc license.
  - `metrc_location_id` integer — The Metrc ID of the Metrc location the sample package will be created in. Only applicable if the license uses Metrc locations. Defaults to the source package's Metrc location when omitted or null.
  - `metrc_notes` string — Notes sent to Metrc as the sample package's note when it is created (max 255 characters).
  - `output_compliance_quantity` number — Size of the test sample package, in the sample's compliance unit (the source unit when use_same_item is true, otherwise the unit of metrc_item_id). Must be > 0. Defaults to input_compliance_quantity when omitted or null.
  - `package_date` string — The sample package's packaged date. Defaults to today when omitted.
  - `product_id` string — The sample's product ID. Must be package-tracked. Defaults to the source package's product when omitted or null.
  - `source_package_id` string, required — The package to pull the sample from. Must be package-tracked and in a Metrc license. An ID that doesn't exist for your company returns 404.
  - `use_same_item` boolean — When true, the sample package reuses the source package's Metrc item and metrc_item_id must be omitted.

## Response `201`

The created assembly

## Other responses

- `400` — Invalid parameters
- `401` — Missing or invalid API token
- `403` — The API token lacks the required permission
- `404` — Not Found

## Changes

- **2026-09-04** `f8930b2c2924` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/distru/apis/distru-api/changes/public/v1/assemblies/create_test_sample/post.md)

---

[API](https://skmtc.dev/distru/apis/distru-api.md) · [All operations](https://skmtc.dev/distru/apis/distru-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/distru/distru-api/revisions/f8930b2c2924/schema)
