> For the complete documentation index, see [llms.txt](https://api-docs.intratool.help/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://api-docs.intratool.help/api-reference/layouts/layouts.md).

# Layouts

## Introduction

`Layouts` define a row-and-column structure for a supported layoutable entity.

## Model Definition

**Alias**

`layout`

**Capabilities**

* [Translations](/introduction/resource-capabilities/translations.md) - Localizes `title`; examples use `en-US`.

**Relations**

| Key          | Relation                                            | Type     | Relation Field(s)                  |
| ------------ | --------------------------------------------------- | -------- | ---------------------------------- |
| `layoutable` | Supported layoutable entity                         | Morph to | `layoutable_type`, `layoutable_id` |
| `layoutRows` | [LayoutRows](/api-reference/layouts/layout-rows.md) | Has many | `layout_id`                        |

## List

List `Layouts`.

**Definition**

<mark style="color:green;">`GET`</mark> `/api/layouts`

**Request Keys**

| Key         | Type      | Default           | Description                          |
| ----------- | --------- | ----------------- | ------------------------------------ |
| `selects`   | `string`  | All fields        | Comma-separated fields to return.    |
| `relations` | `string`  | Default relations | Pipe-separated relations to include. |
| `limit`     | `integer` | No limit          | Maximum number of records.           |

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('GET', '/api/layouts', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
[
  {
    "id": 41,
    "title": "Main content",
    "layoutable_type": "form",
    "layoutable_id": 21,
    "lang_id": "en-US",
    "type": "default",
    "sort_number": 1
  },
  {
    "id": 42,
    "title": "Task details",
    "layoutable_type": "taskTemplate",
    "layoutable_id": 44,
    "lang_id": "en-US",
    "type": "default",
    "sort_number": 1
  }
]
```

## Show

Show one `Layout`.

**Definition**

<mark style="color:green;">`GET`</mark> `/api/layouts/{layout}`

**Route Parameters**

| Parameter | Type      | Description |
| --------- | --------- | ----------- |
| `layout`  | `integer` | Layout ID.  |

**Request Keys**

| Key         | Type     | Default           | Description                          |
| ----------- | -------- | ----------------- | ------------------------------------ |
| `selects`   | `string` | All fields        | Comma-separated fields to return.    |
| `relations` | `string` | Default relations | Pipe-separated relations to include. |

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('GET', '/api/layouts/41', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "id": 41,
  "title": "Main content",
  "layoutable_type": "form",
  "layoutable_id": 21,
  "lang_id": "en-US",
  "type": "default",
  "sort_number": 1
}
```

## Create

Create a new `Layout`.

**Definition**

<mark style="color:yellow;">`POST`</mark> `/api/layouts`

**Request Keys**

| Key                 | Type               | Default         | Description                                 |
| ------------------- | ------------------ | --------------- | ------------------------------------------- |
| `title`             | `string` \| `null` | `null`          | Layout label.                               |
| `layoutable_type`\* | `string`           | -               | Supported layoutable morph alias.           |
| `layoutable_id`\*   | `integer`          | -               | Layoutable entity ID.                       |
| `lang_id`           | `string`           | System language | Language key. Use `en-US` for this example. |
| `type`\*            | `string`           | -               | Layout type. Currently `default`.           |
| `sort_number`       | `integer`          | Auto            | Order within the layoutable entity.         |

Keys with `*` are required.

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('POST', '/api/layouts', [
    'headers' => ['Authorization' => "Bearer {accessToken}"],
    'json' => [
        'title' => 'Task details',
        'layoutable_type' => 'taskTemplate',
        'layoutable_id' => 44,
        'lang_id' => 'en-US',
        'type' => 'default',
        'sort_number' => 1
    ]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "status": "success",
  "data": {
    "id": 42,
    "title": "Task details",
    "layoutable_type": "taskTemplate",
    "layoutable_id": 44,
    "lang_id": "en-US",
    "type": "default",
    "sort_number": 1
  }
}
```

## Update

Update an existing `Layout`.

**Definition**

<mark style="color:blue;">`PUT`</mark> `/api/layouts/{layout}`

**Route Parameters**

| Parameter | Type      | Description |
| --------- | --------- | ----------- |
| `layout`  | `integer` | Layout ID.  |

**Request Keys**

| Key               | Type               | Default       | Description                 |
| ----------------- | ------------------ | ------------- | --------------------------- |
| `title`           | `string` \| `null` | Current value | Layout label.               |
| `layoutable_type` | `string`           | Current value | New layoutable morph alias. |
| `layoutable_id`   | `integer`          | Current value | New layoutable ID.          |
| `lang_id`         | `string`           | Current value | Language key.               |
| `type`            | `string`           | Current value | Layout type.                |
| `sort_number`     | `integer`          | Current value | Display order.              |

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('PUT', '/api/layouts/42', [
    'headers' => ['Authorization' => "Bearer {accessToken}"],
    'json' => [
        'title' => 'Task overview',
        'lang_id' => 'en-US',
        'sort_number' => 2
    ]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "status": "success",
  "data": {
    "id": 42,
    "title": "Task overview",
    "layoutable_type": "taskTemplate",
    "layoutable_id": 44,
    "lang_id": "en-US",
    "type": "default",
    "sort_number": 2
  }
}
```

## Delete

Delete an existing `Layout`.

**Definition**

<mark style="color:red;">`DELETE`</mark> `/api/layouts/{layout}`

**Route Parameters**

| Parameter | Type      | Description |
| --------- | --------- | ----------- |
| `layout`  | `integer` | Layout ID.  |

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('DELETE', '/api/layouts/42', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "status": "success",
  "data": null
}
```
