> ## 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 Families

> Create product families, add and remove a product's variants, set the default variant and reorder the variants (sizes, flavours, colours, scents of one product) -- the programmatic equivalent of the dashboard's variants and families page.

Programmatic equivalent of the dashboard's `products/<gtin>/families/` page.

## When to use

* A brand sells one product in several sizes, flavours, colours or scents, each with its own
  GTIN, and wants a shopper who scans one to see the others.
* A variant was added or discontinued, the family's default variant changed, or a variant's
  type or value was recorded wrong.

## Auth

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

## Flow

```
GET    /products/api/v1/families?gtin={gtin}
GET    /products/api/v1/families?organization_id={id}
POST   /products/api/v1/families
GET    /products/api/v1/families/{family_id}
PATCH  /products/api/v1/families/{family_id}
DELETE /products/api/v1/families/{family_id}
GET    /products/api/v1/families/{family_id}/members
POST   /products/api/v1/families/{family_id}/members
POST   /products/api/v1/families/{family_id}/members/reorder
GET    /products/api/v1/families/{family_id}/members/{member_id}
PATCH  /products/api/v1/families/{family_id}/members/{member_id}
DELETE /products/api/v1/families/{family_id}/members/{member_id}
```

* **Find** -- `?gtin=` returns the one family a product is in (a product is a variant in at
  most one family); `?organization_id=` lists your organization's families. List with
  `?external_ref=` to find a family again on a re-run.
* **Create a family** -- the body is `organization_id`, `name` and optionally `brand`,
  `description`, `external_ref`, `owning_brand_id`, `category_id`, `country_of_origin` and
  `axes`; fields are listed in the OpenAPI document at `/products/api/v1/openapi.json`. `409`
  if `external_ref` is already used in the organization.
* **Add a variant** -- `POST .../members` with the product's `gtin`, `variant_type`,
  `variant_value` and optionally `is_default`, `position` and `axis_values`. The product must
  be owned by the family's organization (`404` otherwise); `409` if it is already a variant in
  this or another family.
* **Set the default** -- `PATCH` the member with `is_default: true`; the previous default is
  cleared in the same write, so a family has at most one.
* **Update a variant** -- `PATCH` the member with only the fields you change
  (`variant_type`, `variant_value`, `is_default`, `position`, `axis_values`).
* **Reorder** -- `POST .../members/reorder` with every member id in the new order, applied in
  one transaction.
* **Remove a variant** -- `DELETE` the member; the product itself is untouched. Deleting the
  family removes every membership and no product.
* **Read back** -- every create and update returns the saved row; list again to confirm.

Returns `403` for a read-only key, `404` for a family, member or product the caller cannot
see, `409` for a conflict, and `422` for an invalid value.

## Notes

Record a family only when the brand sells the products as variants of one another, as its own
website, packaging or catalog shows.

The fields a brand writes are defined once on each model (`ProductFamily.BRAND_EDITABLE_FIELDS`
and `ProductFamilyMember.BRAND_EDITABLE_FIELDS`); the API schemas and the dashboard form are
pinned to those sets.


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