> ## Documentation Index
> Fetch the complete documentation index at: https://docs.closient.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Manage Product Packaging Hierarchy

> Add, update, list, and remove a product's packaging hierarchy (the units in a case, the cases on a pallet) with each child's quantity and GDSN packaging level -- the programmatic equivalent of the dashboard's packaging hierarchy page.

Programmatic equivalent of the dashboard's `products/<gtin>/packaging-hierarchy/` page.

## When to use

* A brand owner wants Closient to know what a case, inner pack or pallet GTIN contains, so a
  scan of the case can be traced to the units inside it.
* A pack configuration changed (a case went from 12 to 24 units) or a link was recorded at the
  wrong level.

## Auth

`X-API-Key` header or OAuth token. Writing takes membership of the parent product's
organization with the contribute role (Editor or Manager). A read-only key is refused with
`403`; a parent product another organization owns answers `404`, so the API never confirms
it exists.

## Flow

```
GET    /products/api/v1/products/{gtin}/hierarchy
GET    /products/api/v1/products/hierarchy/{hierarchy_id}
POST   /products/api/v1/products/{gtin}/hierarchy
PATCH  /products/api/v1/products/hierarchy/{hierarchy_id}
DELETE /products/api/v1/products/hierarchy/{hierarchy_id}
```

* **List** -- every child link of the product in `{gtin}`, with each link's `id`, the child's
  GTIN and name, the `quantity` and the `hierarchy_level`.
* **Create** -- the body is `child_gtin`, `quantity` (at least 1) and `hierarchy_level`
  (`UNIT`, `INNER_PACK`, `CASE` or `PALLET`); fields are listed in the OpenAPI document at
  `/products/api/v1/openapi.json`. Only the parent must belong to your organization: the
  child can be any product in the catalog, as a retailer's case can hold other brands' items.
  An unknown child GTIN answers `404`, and a product cannot be its own child (`422`).
* **Re-link** -- a product links each child once. A `POST` naming a child that is already
  linked replaces that link's `quantity` and `hierarchy_level`, so it is how a link's level is
  corrected.
* **Update** -- `PATCH` with `quantity` only, addressed by the link's `id`.
* **Delete** -- removes the link permanently; neither product is touched.
* **Read back** -- every create and update returns the saved link; list again to confirm.

Returns `403` for a read-only key, `404` for a parent product or link the caller cannot see,
and `422` for an invalid value.

## Notes

Record a link only when the brand publishes the pack configuration or holds it (a spec sheet,
a case label, a GDSN record). A child whose own owner's facts Closient withholds (an
unverified or disputed claim, a suspended owner) is left out of the list for anyone outside
that child's organization.

The fields a brand writes on a link are defined once on the model
(`ProductGroup.BRAND_EDITABLE_FIELDS`); both API schemas and the dashboard form are pinned to
that set.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.