# List knowledge bases

Source: [List knowledge bases](<https://docs.gptunnel.ru/en/rag/list/>)

<a id="_top"></a>
> **Note: API key access**
>
> Get an API key from your [personal or business profile](<https://docs.gptunnel.ru/en/#get-an-api-key>) and send it in the `Authorization` header.

 <a id="получить-список-баз-данных"></a>
 
`GET https://gptunnel.ru/v1/database/list`

Lists the knowledge bases owned by the API key’s owner. Two employees of the same organization may see different lists. To [add a file](<https://docs.gptunnel.ru/en/rag/file-add/>), pass the selected base’s `id` from this response as `databaseId`.

### Request headers

| Parameter | Type | Description |
| --- | --- | --- |
| `Authorization` (required) | `string` | API key |

<a id="example-request"></a>
## Example request

Write down your API key to the variable environment `GPTUNNEL_API_KEY`.

<a id="tab-panel-0-0"></a>
**Python**

```python
import json
import os
from urllib.request import Request, urlopen

request = Request(
    'https://gptunnel.ru/v1/database/list',
    headers={'Authorization': os.environ['GPTUNNEL_API_KEY']},
)
with urlopen(request, timeout=30) as response:
    print(json.load(response))
```

<a id="tab-panel-0-1"></a>
**cURL**

```bash
curl --fail-with-body \
  'https://gptunnel.ru/v1/database/list' \
  --header "Authorization: ${GPTUNNEL_API_KEY:?Set GPTUNNEL_API_KEY}"
```

<a id="tab-panel-0-2"></a>
**JavaScript (Node.js)**

```javascript
const key = process.env.GPTUNNEL_API_KEY
if (!key) throw new Error('Set GPTUNNEL_API_KEY')

const url = new URL('https://gptunnel.ru/v1/database/list')
const response = await fetch(url, { headers: { Authorization: key } })
if (!response.ok) throw new Error(await response.text())
console.log(await response.json())
```

<a id="example-response"></a>
## Example response

<a id="tab-panel-1-0"></a>
**200 OK**

```json
[
  {
    "id": "65ae53795863357cd4ea101d",
    "createDate": "2024-01-22T11:37:29.886Z",
    "name": "RAG Database #1"
  }
]
```

<a id="tab-panel-1-1"></a>
**401 Unauthorized**

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