# List of files

{% hint style="info" %}
Чтобы отправлять авторизованные запросы нужно получить API ключ, как это сделать написано в разделе [**С чего начать?**](https://docs.gptunnel.ru/)
{% endhint %}

## Получить список файлов

<mark style="color:blue;">`GET`</mark> `https://gptunnel.ru/v1/database/file/list?databaseId`

Запрос на получения списка файлов в базе данных

#### Headers

| Name                                            | Type   | Description |
| ----------------------------------------------- | ------ | ----------- |
| Authorization<mark style="color:red;">\*</mark> | string | API ключ    |

#### Параметры запроса

| Name                                         | Type   | Description    |
| -------------------------------------------- | ------ | -------------- |
| databaseId<mark style="color:red;">\*</mark> | string | ID базы данных |
| fileId                                       | string | ID файла       |

{% tabs %}
{% tab title="200: OK Успешный ответ" %}
{% code fullWidth="false" %}

```json
[
  {
    "id": "66a346f64dcb57627c03d596",
    "createDate": "2024-07-26T06:49:27.430Z",
    "status": "ready",
    "name": "Split check",
    "databaseId": "669b1824c0d8dbde07d07d10",
    "chunkSize": 1024,
    "overlapSize": 0,
    "splitVariable": "|",
    "tokenCount": 6,
    "tokenCost": "0.0003",
    "error": null,
    "progress": 100,
    "chunkCount": 3
  }
]
```

{% endcode %}
{% endtab %}

{% tab title="401: Unauthorized Ошибка авторизации" %}

```json
{
  "error": {
    "message": "Unauthorized",
    "type": "unauthorized_request_error",
    "param": null,
    "code": null,
  }
}
```

{% endtab %}
{% endtabs %}

### Пример запроса

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

```typescript
import axios from 'axios'

const request = axios({
  method: 'GET',
  url: 'https://gptunnel.ru/v1/database/file/list?databaseId=669b1824c0d8dbde07d07d10',
  headers: {
    // use your API key here
    Authorization: 'YOUR_API_KEY',
  },
})

request.then((result) => {
  console.log(result)
}).catch((error) => {
  console.error(error)
})
```

{% endtab %}

{% tab title="Curl" %}

```bash
curl --request GET \
  --url https://gptunnel.ru/v1/database/file/list?databaseId=669b1824c0d8dbde07d07d10 \
  --header 'Authorization: YOUR_API_KEY'
```

{% endtab %}
{% endtabs %}

### Пример ответа

```json
[
  {
    "id": "66a346f64dcb57627c03d596",
    "createDate": "2024-07-26T06:49:27.430Z",
    "status": "ready",
    "name": "Split check",
    "databaseId": "669b1824c0d8dbde07d07d10",
    "chunkSize": 1024,
    "overlapSize": 0,
    "splitVariable": "|",
    "tokenCount": 6,
    "tokenCost": "0.0003",
    "error": null,
    "progress": 100,
    "chunkCount": 3
  }
]
```


---

# 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.gptunnel.ru/database/file-list.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.
