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

# Relations

> Read, write, and expand CMS relation fields.

Relation fields connect one CMS entry to another entry, or to supported Plato records such as menu products and menu categories.

## Write Relation Values

Single relation:

```json theme={null}
{
  "values": {
    "category": "entry_category_1"
  }
}
```

Multi relation:

```json theme={null}
{
  "values": {
    "relatedProducts": ["entry_1", "entry_2"]
  }
}
```

Plato validates relation ids before saving.

If an id does not exist in the API key workspace, the request fails:

```json theme={null}
{
  "message": "Invalid relation value for field 'category'."
}
```

## Read Relation IDs

If you select a relation field without nested fields, Plato returns the stored id or ids.

```text theme={null}
?fields=id,name,category
```

Response:

```json theme={null}
{
  "id": "entry_123",
  "name": {
    "en": "Classic Burger"
  },
  "category": "entry_category_1"
}
```

## Expand Relations

Use nested selection to expand related CMS entries.

```text theme={null}
?fields=id,name,category(id,name)
```

Response:

```json theme={null}
{
  "id": "entry_123",
  "name": {
    "en": "Classic Burger"
  },
  "category": {
    "id": "entry_category_1",
    "name": {
      "en": "Burgers"
    }
  }
}
```

## Relation Depth

`maxDepth` controls how far nested relations can expand.

```text theme={null}
?fields=id,name,category(id,name,parent(id,name))&maxDepth=2
```

Default depth is `3`. Maximum depth is `6`.

Keep depth low for public pages.

## Supported System Relation Targets

CMS relation fields can also target supported Plato records.

Currently supported system relation targets include:

* `MenuProduct`
* `MenuCategory`

When expanded, system records return:

```json theme={null}
{
  "id": "menu_product_id",
  "name": {
    "en": "Classic Burger"
  }
}
```
