Skip to content

Delete a file from a knowledge base

POSThttps://gptunnel.ru/v1/database/file/delete

Use the databaseId and fileId from the list of files in the knowledge base. A successful response contains success: true. Request the file list again to verify the deletion.

Request headers

ParameterTypeDescription
Authorization*stringAPI key

Request parameters

ParameterTypeDescription
databaseId*stringKnowledge base ID
fileId*stringFile ID
clearAssistantsbooleanIf true and no files with status ready remain after deletion, the API unlinks the knowledge base from its associated assistants and bots. By default, those links are preserved.

Set GPTUNNEL_API_KEY to your API key and GPTUNNEL_DATABASE_ID to the ID from the list of knowledge bases. Set GPTUNNEL_FILE_ID to the file’s id from the add file response. The cURL example requires version 8.3 or later.

import json
import os
from urllib.request import Request, urlopen
fields = {
'databaseId': os.environ['GPTUNNEL_DATABASE_ID'],
'fileId': os.environ['GPTUNNEL_FILE_ID'],
}
request = Request(
'https://gptunnel.ru/v1/database/file/delete',
headers={'Authorization': os.environ['GPTUNNEL_API_KEY'], 'Content-Type': 'application/json'},
method='POST',
data=json.dumps(fields).encode('utf-8'),
)
with urlopen(request, timeout=30) as response:
print(json.load(response))
{
"success": true
}