Delete Source
Requests deletion of a source and returns the deletion job.
For what happens to a deleted source’s documents, see Delete Documents and Sources.
curl --request DELETE \
--url https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"expectedRevision": 8
}
'import requests
url = "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}"
payload = { "expectedRevision": 8 }
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.delete(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'DELETE',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({expectedRevision: 8})
};
fetch('https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_POSTFIELDS => json_encode([
'expectedRevision' => 8
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}"
payload := strings.NewReader("{\n \"expectedRevision\": 8\n}")
req, _ := http.NewRequest("DELETE", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"expectedRevision\": 8\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"expectedRevision\": 8\n}"
response = http.request(request)
puts response.read_body{
"document_title": null,
"job": {
"checkpoint": "requested",
"completed_at": null,
"created_at": "2026-09-06T02:00:00Z",
"error": null,
"id": "b2f1d3e4-5c6a-4b7d-8e9f-0a1b2c3d4e5f",
"knowledge_space_id": "0a9d3c2e-5b6f-4e1a-8c7d-2f3e4a5b6c7d",
"mode": "keep",
"progress": null,
"retry_at": null,
"run_state": "dispatch_pending",
"target_id": "6f1c2b0e-3d0b-4a5e-9f4c-1c0e6a7b8d90",
"target_type": "source",
"updated_at": "2026-09-06T02:00:00Z"
},
"status_url": "https://api.example.com/v1/knowledge-fs/spaces/8d2c6a1e-5b3f-4c7d-9e01-2a3b4c5d6e7f/deletion-jobs/b2f1d3e4-5c6a-4b7d-8e9f-0a1b2c3d4e5f"
}Authorizations
Every request authenticates with an API key: Authorization: Bearer {API_KEY}. App endpoints take an app API key; knowledge endpoints take a knowledge base API key (Get Started).
Keep keys server-side; never embed them in client code. Requests with a missing or invalid key fail with HTTP 401 (unauthorized).
Headers
Repeating the same key and request with the same API key returns the original job with 202. Reusing the key for a different request, or from another API key, answers 409. Use printable ASCII characters without leading or trailing whitespace.
8 - 255Path Parameters
Knowledge base ID: the last segment of the Service API endpoint shown in the knowledge base's API Access dialog (…/knowledge-fs/spaces/<knowledge base ID>), and the segment after /datasets/new/ in the address bar.
Source ID. From List Sources.
Query Parameters
cascade also deletes the documents the source produced. keep keeps them: they are hidden while the deletion job runs and come back when it completes, with source_id set to null and no longer refreshed.
Before deleting with keep, save the IDs of files with this source_id from List Document Files: their source_id becomes null once the deletion completes.
cascade, keep Body
The source's current version from List Sources or Get Source. A stale value answers 409 and nothing changes.
x >= 1Response
Deletion accepted. job describes the background deletion.
Get Source answers 404 from the moment the deletion is accepted. To confirm that it finished, poll Get Deletion Job (the status_url) until run_state is completed or failed.
Always null for source deletions.
The deletion job. target_type is source, and mode echoes documents.
Show child attributes
Show child attributes
URL of the deletion job in this API: absolute when the deployment sets SERVICE_API_URL, otherwise a path that starts with /v1/. The same value is sent in the Location response header.
Was this page helpful?
curl --request DELETE \
--url https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"expectedRevision": 8
}
'import requests
url = "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}"
payload = { "expectedRevision": 8 }
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.delete(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'DELETE',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({expectedRevision: 8})
};
fetch('https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_POSTFIELDS => json_encode([
'expectedRevision' => 8
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}"
payload := strings.NewReader("{\n \"expectedRevision\": 8\n}")
req, _ := http.NewRequest("DELETE", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"expectedRevision\": 8\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"expectedRevision\": 8\n}"
response = http.request(request)
puts response.read_body{
"document_title": null,
"job": {
"checkpoint": "requested",
"completed_at": null,
"created_at": "2026-09-06T02:00:00Z",
"error": null,
"id": "b2f1d3e4-5c6a-4b7d-8e9f-0a1b2c3d4e5f",
"knowledge_space_id": "0a9d3c2e-5b6f-4e1a-8c7d-2f3e4a5b6c7d",
"mode": "keep",
"progress": null,
"retry_at": null,
"run_state": "dispatch_pending",
"target_id": "6f1c2b0e-3d0b-4a5e-9f4c-1c0e6a7b8d90",
"target_type": "source",
"updated_at": "2026-09-06T02:00:00Z"
},
"status_url": "https://api.example.com/v1/knowledge-fs/spaces/8d2c6a1e-5b3f-4c7d-9e01-2a3b4c5d6e7f/deletion-jobs/b2f1d3e4-5c6a-4b7d-8e9f-0a1b2c3d4e5f"
}