Delete a Knowledge Source - Cognigy Documentation
DELETE Knowledge Source
Endpoint
DELETE /v2.0/knowledgestores/{knowledgeStoreId}/sources/{sourceId}
Try it
Delete a Knowledge Source
Example cURL Command
curl --request DELETE \
--url https://api-trial.cognigy.ai/new/v2.0/knowledgestores/{knowledgeStoreId}/sources/{sourceId} \
--header 'X-API-Key: <api-key>'
Example Python Code
import requests
url = "https://api-trial.cognigy.ai/new/v2.0/knowledgestores/{knowledgeStoreId}/sources/{sourceId}"
headers = {"X-API-Key": "<api-key>"}
response = requests.delete(url, headers=headers)
print(response.text)
Example JavaScript Fetch
const options = {method: 'DELETE', headers: {'X-API-Key': '<api-key>'}};
fetch('https://api-trial.cognigy.ai/new/v2.0/knowledgestores/{knowledgeStoreId}/sources/{sourceId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
Example PHP Code
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-trial.cognigy.ai/new/v2.0/knowledgestores/{knowledgeStoreId}/sources/{sourceId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Example Go Code
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-trial.cognigy.ai/new/v2.0/knowledgestores/{knowledgeStoreId}/sources/{sourceId}"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("X-API-Key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}
Status Codes
- 204: Successfully deleted KnowledgeSource
- 400: Bad Request - Validation failed. Missing payload.
- 401: Unauthorized - Invalid API key.
- 403: Forbidden - Insufficient permissions.
- 404: Not Found - Resource does not exist.
- 405: Method Not Allowed - Invalid method used.
- 409: Conflict - Resource conflict.
- 413: Payload Too Large - Request exceeds acceptable limit.
- 500: Internal Server Error - Unexpected error occurred.
- 503: Service Unavailable - Service is temporarily unavailable.