> For the complete documentation index, see [llms.txt](https://api.qvalia.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://api.qvalia.io/api-documentation/apis/enrichment-api/product-categorisation.md). Agents can also search and read this documentation through its [MCP server](https://api.qvalia.io/~gitbook/mcp).

# Product categorisation

Categorise products against the UNSPSC taxonomy, restrict the categories used and get the full category tree.

The categorisation endpoint classifies your products into the [UNSPSC](https://www.unspsc.org/) taxonomy. Send a list of product names (with optional codes, descriptions and supplier details) and get back a UNSPSC code and name for each product.

{% hint style="info" %}
Product categorisation is part of the Enrichment API, which is billed separately. Contact [Qvalia Helpdesk](https://qvalia.com/help/) to enable `unspsc` for your account.
{% endhint %}

## How it works

Categorisation is asynchronous:

{% stepper %}
{% step %}

### Send the products

`POST /enrichment/{accountRegNo}/categorisation` with up to 55 products. The response is `202 Accepted` with a `pollingId` and a `Location` header.
{% endstep %}

{% step %}

### Poll for the result

`GET /enrichment/{accountRegNo}/{pollingId}` returns `202` while processing and `200` when the result is ready. Every poll counts toward your account's [rate limit](https://api.qvalia.io/qvalia-developer-tools/api.md#rate-limit), so pace your polling with the `RateLimit-Remaining` and `RateLimit-Reset` response headers.
{% endstep %}

{% step %}

### Read the categories

The result is under `data.unspsc.result.ProductClassifications`, one entry per product, matched on your `id`.
{% endstep %}
{% endstepper %}

## Send products

```http
POST /enrichment/{accountRegNo}/categorisation
Authorization: <api key>
Content-Type: application/json
```

```json
{
  "enrichmentTypes": "unspsc",
  "products": [
    { "id": "1", "product_name": "fire alarm" },
    {
      "id": "2",
      "product_name": "Dell Latitude 5440",
      "product_code": "LAT-5440-I5",
      "product_description": "14 inch business laptop, Intel Core i5, 16 GB RAM"
    }
  ]
}
```

Response:

```json
{
  "status": "success",
  "data": { "pollingId": "0b6f7c1e-4f0a-4c56-9a3e-2d8f5b7a91c4" }
}
```

### Request fields

| Field                               | Type    | Required | Notes                                                                                                                                      |
| ----------------------------------- | ------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `enrichmentTypes`                   | string  | Yes      | Must be `unspsc`. Can also be sent as the query parameter `?enrichmentTypes=unspsc`.                                                       |
| `products`                          | array   | Yes      | 1–55 products.                                                                                                                             |
| `products[].id`                     | string  | Yes      | Your identifier, 1–100 characters, echoed back in the result. **Must be unique within the request.** Send it as a string (`"1"`, not `1`). |
| `products[].product_name`           | string  | Yes      | Product name as it appears on the invoice, order or catalogue.                                                                             |
| `products[].product_code`           | string  | No       | Supplier's article number or product code.                                                                                                 |
| `products[].product_description`    | string  | No       | Longer free-text description. May be empty.                                                                                                |
| `supplier`                          | object  | No       | Supplier of the products. See [Add supplier context](#add-supplier-context).                                                               |
| `parameters.unspsc.showFullTree`    | boolean | No       | Default `false`. See [Get the full category tree](#get-the-full-category-tree).                                                            |
| `parameters.unspsc.categoryFilters` | object  | No       | `allowedTrees` and `blockedTrees`. See [Include or exclude categories](#include-or-exclude-categories).                                    |

{% hint style="warning" %}
**Always send a unique `id` for each product.** Results are returned per `id` — it is the only way to match a category back to your product. If two products in the same request share an `id`, only one of them is categorised and returned, and the other is lost from the result.

Use something that is unique per product line, such as the invoice line number or your article number. If the same article appears on several lines, give each line its own `id` (for example `"1001-1"`, `"1001-2"`).
{% endhint %}

Products accept only the four fields above — any other field returns `400 Bad Request`. Leading and trailing whitespace is removed, and `product_name`, `product_code` and `product_description` are truncated to 200 characters.

{% hint style="success" %}
More detail gives better results. A product code and a short description help most when the product name is short or ambiguous. Products in other languages (for example Swedish) are supported.
{% endhint %}

## Add supplier context

Send the supplier of the products to give the categorisation context about the supplier's line of business. This helps with short or ambiguous names — for example, "Mouse" from an IT reseller and "Mouse" from a pet shop belong in different categories.

```json
{
  "enrichmentTypes": "unspsc",
  "supplier": {
    "name": "Acme Office Supplies AB",
    "country_code": "SE",
    "organization_id": "5560004755"
  },
  "products": [
    { "id": "ART-1001", "product_name": "Kopieringspapper A4 80g", "product_code": "1001" }
  ]
}
```

| Field                      | Type   | Required | Notes                                        |
| -------------------------- | ------ | -------- | -------------------------------------------- |
| `supplier.name`            | string | Yes      | Supplier's legal or trading name.            |
| `supplier.country_code`    | string | Yes      | ISO 3166-1 alpha-2 country code, e.g. `SE`.  |
| `supplier.organization_id` | string | No       | Organisation number, e.g. a Swedish org. no. |

The supplier applies to every product in the request. To categorise products from different suppliers, send one request per supplier.

## Include or exclude categories

Use `parameters.unspsc.categoryFilters` to control which parts of the UNSPSC taxonomy products can be classified into:

* **`allowedTrees`** (include) — only categories under these codes are used.
* **`blockedTrees`** (exclude) — categories under these codes are never used.

Each code covers itself and every category below it. When both are set, the categories used are `allowedTrees` minus `blockedTrees`. An empty list is the same as not setting it.

**Example** — categorise only into IT equipment (segment `43000000`), but never into software (family `43230000`):

```json
{
  "enrichmentTypes": "unspsc",
  "products": [
    { "id": "1", "product_name": "Dell Latitude 5440", "product_description": "14 inch business laptop" }
  ],
  "parameters": {
    "unspsc": {
      "categoryFilters": {
        "allowedTrees": ["43000000"],
        "blockedTrees": ["43230000"]
      }
    }
  }
}
```

{% hint style="warning" %}
Use **segment** codes (the top level of UNSPSC, `XX000000` — e.g. `43000000`, `44000000`) in `allowedTrees`. Categorisation starts at segment level, so an `allowedTrees` holding only family, class or commodity codes matches nothing and every product returns `"unspsc": null`. To narrow down inside a segment, allow the segment and block the parts you don't want.

`blockedTrees` accepts codes at any level.
{% endhint %}

If no allowed category fits a product, the product returns `"unspsc": null`.

## Get the full category tree

UNSPSC has four levels: segment, family, class and commodity. By default, each product gets only its predicted category. Set `showFullTree` to `true` to also get the whole path from the segment down to the predicted category:

```json
{
  "enrichmentTypes": "unspsc",
  "products": [
    { "id": "1", "product_name": "Dell Latitude 5440" }
  ],
  "parameters": {
    "unspsc": {
      "showFullTree": true
    }
  }
}
```

Each classified product then has a `full_tree` array next to `unspsc`, ordered from the top level down. The last item is the same as `unspsc`:

```json
{
  "id": "1",
  "unspsc": { "code": "43211503", "name": "Notebook computers" },
  "full_tree": [
    { "code": "43000000", "name": "Information Technology Broadcasting and Telecommunications" },
    { "code": "43210000", "name": "Computer Equipment and Accessories" },
    { "code": "43211500", "name": "Computers" },
    { "code": "43211503", "name": "Notebook computers" }
  ]
}
```

`full_tree` is left out for products that could not be categorised.

`showFullTree` and `categoryFilters` can be combined in the same request.

## Poll for the result

```http
GET /enrichment/{accountRegNo}/{pollingId}
```

While processing, the response is `202`:

```json
{ "status": "pending", "data": {} }
```

When complete, the response is `200`:

```json
{
  "status": "success",
  "data": {
    "unspsc": {
      "result": {
        "ProductClassifications": [
          { "id": "1", "unspsc": { "code": "46191501", "name": "Smoke detectors" } },
          { "id": "2", "unspsc": { "code": "43211503", "name": "Notebook computers" } },
          { "id": "3", "unspsc": null }
        ]
      },
      "errors": [],
      "warnings": []
    }
  }
}
```

You can also get only the categorisation result with `GET /enrichment/{accountRegNo}/{pollingId}/unspsc`. It returns the same `result`, `errors` and `warnings` directly under `data`.

### Result fields

| Field         | Type           | Notes                                                                                                           |
| ------------- | -------------- | --------------------------------------------------------------------------------------------------------------- |
| `id`          | string         | The `id` you sent. Match results to your products on this — don't rely on the order. One entry per unique `id`. |
| `unspsc`      | object \| null | The predicted category, or `null` if the product could not be categorised.                                      |
| `unspsc.code` | string         | 8-digit UNSPSC code.                                                                                            |
| `unspsc.name` | string         | English UNSPSC category name.                                                                                   |
| `full_tree`   | array          | Only with `showFullTree: true`. Path from segment to the predicted category; each item has `code` and `name`.   |

The predicted category is the most specific level that could be determined confidently. Most products get a commodity code (e.g. `43211503`), but a vague product name may give a class, family or segment code (e.g. `43211500` or `43000000`).

A product gets `"unspsc": null` when there is not enough information to categorise it, or when no category matches your `categoryFilters`.

## Limits and errors

| Situation                                                                                                                                                                    | Response                                                                                  |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| `products` missing or empty, an unknown field, or an invalid `enrichmentTypes`                                                                                               | `400` with `type: E_BAD_REQUEST`; `metadata.details` describes the problem.               |
| `unspsc` not enabled for the account                                                                                                                                         | `401` with `data: "Unauthorized for service unspsc"`.                                     |
| Over the account's [rate limit](https://api.qvalia.io/qvalia-developer-tools/api.md#rate-limit) (200 requests a minute by default, 800 for partners). Polls count toward it. | `429` — wait for `Retry-After` seconds (the time left in the current minute).             |
| Unknown polling ID                                                                                                                                                           | `404` with `type: E_MISSING`.                                                             |
| Two or more products with the same `id`                                                                                                                                      | Only one of them is categorised and returned. Send a unique `id` per product.             |
| Processing failed (for example more than 55 products, or a numeric `id`)                                                                                                     | The poll returns `200`, but `data.unspsc` holds only an `errors` message and no `result`. |

Example `400`:

```json
{
  "status": "error",
  "type": "E_BAD_REQUEST",
  "data": "Bad Request",
  "metadata": {
    "description": "Request is invalid",
    "details": "Product validation failed: Unknown field 'price' is not allowed in product object. Allowed fields are: id, product_name, product_code, product_description"
  }
}
```

Example failed processing:

```json
{
  "status": "success",
  "data": {
    "unspsc": {
      "errors": "products: List should have at most 55 items after validation, not 60"
    }
  }
}
```

To categorise more than 55 products, split them into several requests.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://api.qvalia.io/api-documentation/apis/enrichment-api/product-categorisation.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
