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

# Folders

## List

Get a list of all `Folders`.

**Definition**

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

**Example Request**

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

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

{% endtab %}
{% endtabs %}

**Example Response**

```json
[
  {
    "id": 1,
    "parent_folder_id": null,
    "type": "form",
    "name": "Folder 1",
    "sort_number": 1,
    "created_at": "2019-01-25 10:56:16",
    "updated_at": "2019-01-25 10:56:16",
    "folder": null
  },
  {
    "id": 2,
    "parent_folder_id": null,
    "type": "form",
    "name": "Folder 2",
    "sort_number": 2,
    "created_at": "2019-01-25 10:56:18",
    "updated_at": "2019-01-25 10:56:18",
    "folder": null
  }
]
```

## List by type

Get a list of all `Folders` by `type`.

**Definition**

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

**Example Request**

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

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

{% endtab %}
{% endtabs %}

**Example Response**

```json
[
  {
    "id": 1,
    "parent_folder_id": null,
    "type": "form",
    "name": "Folder 1",
    "sort_number": 1,
    "created_at": "2019-01-25 10:56:16",
    "updated_at": "2019-01-25 10:56:16",
    "folder": null
  },
  {
    "id": 2,
    "parent_folder_id": null,
    "type": "form",
    "name": "Folder 2",
    "sort_number": 2,
    "created_at": "2019-01-25 10:56:18",
    "updated_at": "2019-01-25 10:56:18",
    "folder": null
  }
]
```

## Create

Create a new `Folder`.

**Definition**

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

**Request Keys**

| Key                |   Type  | Default | Description                                 |
| ------------------ | :-----: | :-----: | ------------------------------------------- |
| `parent_folder_id` | integer |  `null` | Related parent `Folder`                     |
| `type` \*          |  string |    -    | Relation type of the `Folder` (e.g. `form`) |
| `name` \*          |  string |    -    | Name of the `Folder`                        |

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/folders', [
    'headers' => ['Authorization' => "Bearer {accessToken}"],
    'json' => [
        'type' => 'form',
        'name' => 'Folder 3'
    ]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "id": 3,
  "parent_folder_id": null,
  "type": "form",
  "name": "Folder 3",
  "sort_number": 3,
  "created_at": "2019-01-25 11:25:42",
  "updated_at": "2019-01-25 11:25:42",
  "folder": null
}
```

## Update

Update an existing `Folder` by `id`.

**Definition**

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

**Request Keys**

| Key                |   Type  | Description             |
| ------------------ | :-----: | ----------------------- |
| `parent_folder_id` | integer | Related parent `Folder` |
| `name`             |  string | Name of the `Folder`    |

**Example Request**

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

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

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "id": 3,
  "parent_folder_id": null,
  "type": "form",
  "name": "Folder3",
  "sort_number": 3,
  "created_at": "2019-01-25 11:25:42",
  "updated_at": "2019-01-25 11:26:05",
  "folder": null
}
```

## Delete

Delete an existing `Folder` by `id`.

**Definition**

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

**Example Request**

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

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

{% endtab %}
{% endtabs %}

**Example Response**

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