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

# Manage compliance categories

> Create and maintain the compliance categories that classify certificates and standards by product type — such as Fibres, Textiles, and Footwear.

<Info>
  **When to use this.** Compliance categories are admin reference data that sit behind the
  Compliance module. You create them once in Admin, and they then appear as a dropdown choice
  whenever a user creates a certificate or compliance standard. Set these up before you start
  creating certificates. Categories classify by **product type** (e.g. Textiles, Footwear),
  while groups classify by **purpose** (e.g. Sustainability, Chain of Custody) — they are
  separate resources.
</Info>

## The workflow

Compliance categories are prerequisites for the Compliance module. The typical path is to create
your category vocabulary, optionally assign user-defined IDs for import/export alignment, and
then reference categories from certificates and standards.

<Steps>
  <Step title="Create the categories">
    `POST /api/compliance-categories` with an array of one or more categories. Each category
    needs only a `name`; add a `userDefinedId` if you need to match against an external system.
  </Step>

  <Step title="List and verify">
    `GET /api/compliance-categories` to confirm all categories are in place. Filter by `State`,
    `Names`, or `Search` if you have a large vocabulary.
  </Step>

  <Step title="Retrieve a single category">
    `GET /api/compliance-categories/{id}` to inspect `usedInStandard` and
    `usedInCertificates` — these counters tell you whether a category is safe to delete.
  </Step>

  <Step title="Retire or remove">
    `PUT /api/compliance-categories/{id}` with `state: "inactive"` to stop offering the
    category to new certificates without losing history, or `DELETE /api/compliance-categories/{id}`
    to hard-delete it (blocked if `usedInStandard > 0` or `usedInCertificates > 0`).
  </Step>
</Steps>

```mermaid theme={"dark"}
sequenceDiagram
  participant A as API consumer
  participant API as Delogue API
  A->>API: POST /api/compliance-categories (name, userDefinedId, state)
  API-->>A: id, name, state, usedInStandard, usedInCertificates
  A->>API: GET /api/compliance-categories (list / filter)
  API-->>A: paginated category list
  A->>API: GET /api/compliance-categories/{id}
  API-->>A: single category with usage counts
  A->>API: DELETE /api/compliance-categories/{id}
  API-->>A: 200 (or 409 if in use)
```

## Walkthrough

Create a compliance category for Footwear. The body is an array — one or many categories are
created in a single all-or-nothing transaction.

<CodeGroup>
  ```bash cURL theme={"dark"}
  curl -X POST "https://service.my.delogue.com/api/compliance-categories" \
    -H "Accept: application/json" \
    -H "X-Auth-Token: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '[
    {
      "name": "Footwear",
      "userDefinedId": "FW-01",
      "state": "active"
    }
  ]'
  ```

  ```js JavaScript theme={"dark"}
  const res = await fetch("https://service.my.delogue.com/api/compliance-categories", {
    method: "POST",
    headers: {
      "Accept": "application/json",
      "X-Auth-Token": "Bearer YOUR_API_KEY",
      "Content-Type": "application/json",
    },
    body: JSON.stringify([
    {
      "name": "Footwear",
      "userDefinedId": "FW-01",
      "state": "active"
    }
  ]),
  });
  const { data } = await res.json();
  ```
</CodeGroup>

```json theme={"dark"}
{
  "status": "success",
  "code": "compliance_categorys_created",
  "data": [
    {
      "id": 120,
      "name": "Footwear",
      "state": "active",
      "usedInStandard": 0,
      "usedInCertificates": 0,
      "userDefinedId": "FW-01",
      "properties": []
    }
  ]
}
```

The response wraps the created categories in the standard envelope. Hold onto each `id` — you
will need it when updating or deleting individual categories.

## Field reference

| Field           | What it means at Delogue                                                                                                             |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `name`          | Display name of the compliance category. Required. Must be unique within the organisation.                                           |
| `state`         | Initial lifecycle state for the category. Defaults to active. The value deleted is rejected on creation — use DELETE after creating. |
| `userDefinedId` | Optional customer-defined identifier. Must be unique within the organisation when provided.                                          |

## Roles & permissions

Managing compliance categories requires the **`CompanyAdmin`** and **`Compliance Admin`** roles
on a **designer (brand)** account. Supplier accounts do not manage a brand's compliance
vocabulary. The Compliance module itself requires a **Professional license** subscription.

## When things go wrong

Errors use the standard envelope (`status: "error"`, a `code`, and `error.details[]`). Key
cases to handle:

* **409 Conflict** — `DELETE` is rejected when `usedInStandard > 0` or
  `usedInCertificates > 0`. Check the counts with `GET /api/compliance-categories/{id}` first,
  then reassign or remove the references before deleting.
* **400 validation\_error** — `name` is required; `state: "deleted"` is rejected on `POST` and
  single-item `PUT`.
* **404 resource\_error** — the `id` does not exist within your organisation.

See [Errors & responses](/concepts/errors) for the full list of codes and how to resolve them.

## What to call next

<CardGroup cols={2}>
  <Card title="Style categories" href="/guides/style-categories">
    A parallel category vocabulary that organises styles — set these up alongside compliance
    categories for a consistent admin structure.
  </Card>

  <Card title="Item categories" href="/guides/item-categories">
    Category classification for items (materials, fabrics, trims).
  </Card>

  <Card title="Groups" href="/guides/groups">
    Compliance groups organise certificates and standards by purpose, e.g. Sustainability or
    Chain of Custody — the sibling resource to categories.
  </Card>

  <Card title="Size ranges" href="/guides/size-ranges">
    Another admin reference dataset needed before product data can be created.
  </Card>
</CardGroup>
