# Delete file from RAG

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

## Удаление файла из RAG

<mark style="color:green;">`POST`</mark> `https://gptunnel.ru/v1/database/file/delete`

Запрос на удалени файла

#### Headers

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

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

| Name                                         | Type    | Description                                                                               |
| -------------------------------------------- | ------- | ----------------------------------------------------------------------------------------- |
| databaseId<mark style="color:red;">\*</mark> | string  | ID базы данных                                                                            |
| fileId<mark style="color:red;">\*</mark>     | string  | Текст файла                                                                               |
| clearAssistants                              | boolean | Если true и удален последний файл - база будет отключена от всех ассистентов и интеграций |

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

```json
{
  "success": true 
}
```

{% 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: 'POST',
  url: 'https://gptunnel.ru/v1/database/file/delete',
  headers: {
    // use your API key here
    Authorization: 'YOUR_API_KEY',
  },
  data: {
    databaseId: "669b1824c0d8dbde07d07d10",
    fileId: "669b1828c0d8dbde07d07d11"
  }
})

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

{% endtab %}

{% tab title="Curl" %}

```bash
curl --request POST \
  --url https://gptunnel.ru/v1/database/file/delete \
  --header 'Authorization: YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "databaseId": "669b1824c0d8dbde07d07d10",
    "fileId": "669b1828c0d8dbde07d07d11"
}'
```

{% endtab %}
{% endtabs %}

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

```json
{
  "success": true 
}
```
