> For the complete documentation index, see [llms.txt](https://fredhopper.gitbook.io/product-discovery/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fredhopper.gitbook.io/product-discovery/sending-and-managing-product-data/what-is-the-items-api/working-with-items/category-tree.md).

# Category Tree

## Definition

A category tree represents a hierarchical category list. The category tree contains a principal node. This node can have multiple children. Each child is composed of the name and an array of localized names.

As the item schema, the category tree is versioned to be associated in a catalog.

Category Trees aren't mandatory unless you want to associate an item with a category.

## Structure

| Name           | Type   | Description                                                                                                                                                                                               |
| -------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name           | String | Name of the root node                                                                                                                                                                                     |
| tenant         | String | Tenant of the account                                                                                                                                                                                     |
| environment    | String | Environment to use                                                                                                                                                                                        |
| version        | Int    | The version of the category tree - manage by the API                                                                                                                                                      |
| localizedNames | List   | <p>List of objects providing available translations per locale:</p><p><code>{</code><br><code>"locale": "\<langcode\_countrycode>",</code><br><code>"name": "\<translation>"</code><br><code>}</code></p> |
| children       | List   | list of CategoryTree Category                                                                                                                                                                             |

{% hint style="danger" %}
The root name can't be 0
{% endhint %}

### Localized Name Structure

| Name   | Type   | Description                                                                                                                                                                                                                                                                                                                                    |
| ------ | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name   | String | Name of the category                                                                                                                                                                                                                                                                                                                           |
| locale | String | <p>Based on the Java locale format <em>\<languagecode>\_\<countrycode></em></p><ul><li><em>languagecode</em> is based on the <a href="https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes">ISO 639-1</a></li><li><em>countrycode</em> is defined by <a href="https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes">ISO 3166-1</a></li></ul> |

### CategoryTree Category

| Name           | Type   | Description                                                                                                                                                                                               |
| -------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name           | String | Name of the root node                                                                                                                                                                                     |
| localizedNames | List   | <p>List of objects providing available translations per locale:</p><p><code>{</code><br><code>"locale": "\<langcode\_countrycode>",</code><br><code>"name": "\<translation>"</code><br><code>}</code></p> |
| children       | List   | list of CategoryTree Category                                                                                                                                                                             |

## Example

```javascript
{
    "name": "catalog01",
    "localizedNames": [
        {
            "locale": "en_GB",
            "name": "Home"
        },
        {
            "locale": "de_DE",
            "name": "Startseite"
        }
    ],
    "tenant": "demo",
    "environment": "fas:live1",
    "children": [
        {
            "name": "dresses21",
            "localizedNames": [
                {
                    "locale": "en_GB",
                    "name": "Dresses"
                },
                {
                    "locale": "de_DE",
                    "name": "Kleider"
                }
            ],
            "children": [
                {
                    "name": "minidresses31",
                    "localizedNames": [
                        {
                            "locale": "en_GB",
                            "name": "Mini Dresses"
                        },
                        {
                            "locale": "de_DE",
                            "name": "Minikleider"
                        }
                    ]
                },
                {
                    "name": "partydresses32",
                    "localizedNames": [
                        {
                            "locale": "en_GB",
                            "name": "Party Dresses"
                        },
                        {
                            "locale": "de_DE",
                            "name": "Partykleider"
                        }
                    ]
                }
            ]
        },
        {
            "name": "shoes22",
            "localizedNames": [
                {
                    "locale": "en_GB",
                    "name": "Shoes"
                },
                {
                    "locale": "de_DE",
                    "name": "Schuhe"
                }
            ],
            "children": [
                {
                    "name": "boots33",
                    "localizedNames": [
                        {
                            "locale": "en_GB",
                            "name": "Boots"
                        },
                        {
                            "locale": "de_DE",
                            "name": "Stiefel"
                        }
                    ]
                },
                {
                    "name": "sandals34",
                    "localizedNames": [
                        {
                            "locale": "en_GB",
                            "name": "Sandals"
                        },
                        {
                            "locale": "de_DE",
                            "name": "Sandalen"
                        }
                    ]
                },
                {
                    "name": "trainers35",
                    "localizedNames": [
                        {
                            "locale": "en_GB",
                            "name": "Trainers"
                        },
                        {
                            "locale": "de_DE",
                            "name": "Sneaker"
                        }
                    ]
                }
            ]
        }
    ]
}
```

## Validation

Additional validation for category trees:

* root name should not be empty or “0”
* categories should have localized names with valid locales
* each category name should be unique

## FHR data model validation

The query parameter fhrValidation=true can be added to enforce Fredhopper specific validation to the category API. This includes the following additional checks to the schema:

* Category names (aka Category\_ids) only contain the alphanumerical characters \[A-Za-z0-9] i.e. must only contain uppercase and lowercase Latin letters: `A-Z`, `a-z`, and digits: `0-9`
