# FilemanagerDirectories

## Introduction

`FilemanagerDirectories` represent a folder on the filesystem. The `path` of a folder describes how to retrieve it when it's displayed.

There is no direct relation to [FilemanagerFiles](/api-reference/filemanager/filemanager-files.md). The resolution of files and directories is done by their `path` property.

## Model Definition

**Alias**

`filemanagerDirectory`

**Relations**

| Relation                                     | Key           | Type            | Relation Field(s)  |
| -------------------------------------------- | ------------- | --------------- | ------------------ |
| [User](/api-reference/users.md)              | `user`        | Belongs to      | `user_id`          |
| [Users](/api-reference/users.md)             | `users`       | Belongs to many | Intermediate table |
| [Departments](/api-reference/departments.md) | `departments` | Belongs to many | Intermediate table |

**Computed Properties**

* `name` - The basename of the `FilemanagerDirectory`

**Traits**

* `SoftDeletes`

## List

Get a list of all `FilemanagerDirectories` the current authenticated [User](/api-reference/users.md) is allowed to view.

{% hint style="warning" %}
You can use the filters `matches_path` and `matches_path_recursive` on routes of this module. However, the response time of the list action can be considerably high because of recursive permission handling. You might want to use the [list by path action](#list-by-path) for tasks regarding a specific path.
{% endhint %}

**Definition**

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

**Example Request**

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

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

{% endtab %}
{% endtabs %}

**Example Response**

```json
[
  {
    "id": 1,
    "user_id": 3,
    "path": "/Lorem ipsum/",
    "created_at": "2018-12-21 13:13:26",
    "updated_at": "2018-12-21 13:13:26",
    "deleted_at": null,
    "name": "Lorem ipsum"
  },
  {
    "id": 2,
    "user_id": 3,
    "path": "/Dolor sit amet/",
    "created_at": "2018-12-21 13:28:46",
    "updated_at": "2018-12-21 13:28:46",
    "deleted_at": null,
    "name": "Dolor sit amet"
  }
]
```

## List by path

Get a list of all `FilemanagerDirectories` by given `{path}` the current authenticated [User](/api-reference/users.md) is allowed to view.

If you don't pass a value for `{path}` a call to the root folder will be assumed.

**Definition**

<mark style="color:green;">`GET`</mark> `/api/filemanager/directories/path/{path}`

**Example Request**

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

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

{% endtab %}
{% endtabs %}

**Example Response**

```json
[
  {
    "id": 1,
    "user_id": 3,
    "path": "/Lorem Ipsum/Dolor-mit",
    "created_at": "2018-12-21 13:13:26",
    "updated_at": "2018-12-21 13:13:26",
    "deleted_at": null,
    "name": "Lorem ipsum"
  },
  {
    "id": 2,
    "user_id": 3,
    "path": "/Lorem Ipsum/Dolor-sit",
    "created_at": "2018-12-21 13:28:46",
    "updated_at": "2018-12-21 13:28:46",
    "deleted_at": null,
    "name": "Dolor sit amet"
  }
]
```

## Count

Get the count of all `FilemanagerDirectories` the current authenticated [User](/api-reference/users.md) is allowed to view.

**Definition**

<mark style="color:green;">`GET`</mark> `/api/filemanager/directories/count`

**Example Request**

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

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

{% endtab %}
{% endtabs %}

**Example Response**

```json
2
```

## Show

Show a single `FilemanagerDirectory` by `id`.

**Definition**

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

**Example Request**

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

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

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "id": 1,
  "user_id": 3,
  "path": "/Lorem ipsum/",
  "created_at": "2018-12-21 13:13:26",
  "updated_at": "2018-12-21 13:13:26",
  "deleted_at": null,
  "name": "Lorem ipsum"
}
```

## Show information

Show information about a `FilemanagerDirectory` by `id`.

**Definition**

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

**Example Request**

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

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

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "files": 2,
  "size": 274843
}
```

## Download

Download a ZIP of a `FilemanagerDirectory` by `id`.

**Definition**

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

**Example Request**

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

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

{% endtab %}
{% endtabs %}

## Create

Create a new `FilemanagerDirectory`.

**Definition**

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

**Request Keys**

| Key              |  Type  | Default | Description                                                                                                               |
| ---------------- | :----: | :-----: | ------------------------------------------------------------------------------------------------------------------------- |
| `path` \*        | string |    -    | Relative path of the `FilemanagerDirectory` (normalized to include leading and trailing `/`)                              |
| `department_ids` | string |  `null` | The [Departments](/api-reference/departments.md) that are allowed to see the `FilemanagerDirectory` (separated by commas) |
| `user_ids`       | string |  `null` | The [Users](/api-reference/users.md) that are allowed to see the `FilemanagerDirectory` (separated by commas)             |

Keys with `*` are required.

{% hint style="warning" %}
When `department_ids` and `user_ids` are present, `department_ids` get preferred.

If both are empty, the `FilemanagerDirectory` will be public.
{% endhint %}

**Example Request**

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

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('POST', '/api/filemanager/directories', [
    'headers' => ['Authorization' => "Bearer {accessToken}"],
    'json' => [
        'path' => 'Lorem ipsum',
        'department_ids' => '1,2,3'
    ]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "status": "success",
  "data": {
    "id": 3,
    "user_id": 3,
    "path": "/Lorem ipsum/",
    "created_at": "2018-12-21 13:32:55",
    "updated_at": "2018-12-21 13:32:55",
    "deleted_at": null,
    "name": "Lorem ipsum"
  }
}
```

## Update

Update an existing `FilemanagerDirectory` by `id`.

**Definition**

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

**Request Keys**

| Key              |  Type  | Description                                                                                                               |
| ---------------- | :----: | ------------------------------------------------------------------------------------------------------------------------- |
| `path`           | string | Relative path of the `FilemanagerDirectory` (normalized to include leading and trailing `/`)                              |
| `department_ids` | string | The [Departments](/api-reference/departments.md) that are allowed to see the `FilemanagerDirectory` (separated by commas) |
| `user_ids`       | string | The [Users](/api-reference/users.md) that are allowed to see the `FilemanagerDirectory` (separated by commas)             |

**Example Request**

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

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('PUT', '/api/filemanager/directories/3', [
    'headers' => ['Authorization' => "Bearer {accessToken}"],
    'json' => [
        'path' => 'Dolor sit amet',
        'user_ids' => '1,2'
    ]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "status": "success",
  "data": {
    "id": 3,
    "user_id": 3,
    "path": "/Dolor sit amet/",
    "created_at": "2018-12-21 13:32:55",
    "updated_at": "2018-12-21 13:34:11",
    "deleted_at": null,
    "name": "Dolor sit amet"
  }
}
```

## Delete

Delete an existing `FilemanagerDirectory` by `id`.

**Definition**

<mark style="color:red;">`DELETE`</mark> `/api/filemanager/directories/{id}`

**Example Request**

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

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

{% endtab %}
{% endtabs %}

**Example Response**

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


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.api.intratool.de/api-reference/filemanager/filemanager-directories.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
