Delete a file from a knowledge base
POST
https://gptunnel.ru/v1/database/file/deleteUse 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
| Parameter | Type | Description |
|---|---|---|
Authorization* | string | API key |
Request parameters
| Parameter | Type | Description |
|---|---|---|
databaseId* | string | Knowledge base ID |
fileId* | string | File ID |
clearAssistants | boolean | If 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. |
Example request
Section titled “Example request”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 jsonimport osfrom 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))curl --fail-with-body \ 'https://gptunnel.ru/v1/database/file/delete' \ --header "Authorization: ${GPTUNNEL_API_KEY:?Set GPTUNNEL_API_KEY}" \ --variable '%GPTUNNEL_DATABASE_ID' \ --variable '%GPTUNNEL_FILE_ID' \ --header 'Content-Type: application/json' \ --expand-data '{"databaseId": "{{GPTUNNEL_DATABASE_ID:json}}", "fileId": "{{GPTUNNEL_FILE_ID:json}}"}'const key = process.env.GPTUNNEL_API_KEYif (!key) throw new Error('Set GPTUNNEL_API_KEY')const databaseId = process.env.GPTUNNEL_DATABASE_IDif (!databaseId) throw new Error('Set GPTUNNEL_DATABASE_ID')const fileId = process.env.GPTUNNEL_FILE_IDif (!fileId) throw new Error('Set GPTUNNEL_FILE_ID')
const url = new URL('https://gptunnel.ru/v1/database/file/delete')const response = await fetch(url, { method: 'POST', headers: { Authorization: key, 'Content-Type': 'application/json' }, body: JSON.stringify({ databaseId, fileId, }),})if (!response.ok) throw new Error(await response.text())console.log(await response.json())Example response
Section titled “Example response”{ "success": true}{ "error": { "message": "Unauthorized", "type": "unauthorized_request_error", "param": null, "code": null }}