> 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/files.md).

# Files

## Introduction

The Files endpoints return stored content, short-lived content URLs, and directory archives for [FilemanagerFiles](/api-reference/filemanager/filemanager-files.md) and [FilemanagerDirectories](/api-reference/filemanager/filemanager-directories.md).

Use the content URLs returned by the API instead of constructing encoded storage paths manually. Access is checked against the resolved file or directory. [SharedItems](/api-reference/shared-items.md) provide access-controlled links when content must be shared beyond its regular assignments.

## Show Content by Encoded Path

Show file content addressed by an encoded path.

**Definition**

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

**Route Parameters**

| Parameter | Type     | Description                                                     |
| --------- | -------- | --------------------------------------------------------------- |
| `path`    | `string` | Encoded storage directory followed by the URL-encoded filename. |

**Behavior**

* The response streams the stored content or redirects to a temporary storage URL, depending on the configured filesystem.
* `Content-Type` and `Content-Disposition` are derived from the stored file and resolved filename.

**Example Request**

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

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

{% endtab %}
{% endtabs %}

**Example Response**

```http
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline; filename="path-preview.txt"

path based preview
```

## Create Temporary Content URL

Create a temporary URL for file content addressed by an encoded path.

**Definition**

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

**Route Parameters**

| Parameter | Type     | Description                                                     |
| --------- | -------- | --------------------------------------------------------------- |
| `path`    | `string` | Encoded storage directory followed by the URL-encoded filename. |

**Behavior**

The returned storage URL is URL-encoded and expires after 10 seconds. It is intended for short-lived handoff to third-party viewers.

**Example Request**

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

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

{% endtab %}
{% endtabs %}

**Example Response**

```json
"https%3A%2F%2Ffiles.example.test%2Ffilemanager%2Ftemp%2Freport.pdf%3FX-Amz-Expires%3D10"
```

## Download Directory

Download one `FilemanagerDirectory` as an archive.

**Definition**

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

**Route Parameters**

| Parameter              | Type              | Description                                                                               |
| ---------------------- | ----------------- | ----------------------------------------------------------------------------------------- |
| `filemanagerDirectory` | `integer or hash` | [FilemanagerDirectory](/api-reference/filemanager/filemanager-directories.md) ID or hash. |

**Request Keys**

| Key      | Type      | Default            | Description                                      |
| -------- | --------- | ------------------ | ------------------------------------------------ |
| `filter` | `object`  | No filters         | Filters applied to recursively selected files.   |
| `sort`   | `string`  | Repository default | File ordering used while building the archive.   |
| `limit`  | `integer` | No limit           | Maximum number of files included in the archive. |

**Behavior**

The endpoint streams a ZIP archive. Only files visible to the current user and matching the supplied result controls are included.

**Example Request**

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

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

{% endtab %}
{% endtabs %}

**Example Response**

```http
HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Disposition: attachment; filename="reports.zip"

<binary ZIP data containing reports/alpha-report.pdf and reports/beta-report.pdf>
```
