Endpoints
Delete source
Delete a source through a review; a trained source stays in answers until the next training removes it
delete_source deletes one source. What happens depends on whether the agent has ever trained on it:
| The source | After you apply the review |
|---|---|
| Was never trained | It's deleted at once. disposition is deleted. |
| Has been trained | It's marked Removed (pending_deletion). The agent keeps answering from it until the next training takes it out, and until then restore_source brings it back. disposition is pending_deletion. |
POST
https://api.qwryai.com/public/v1/tools/delete_sourceAuthentication
Send your API key as Authorization: Bearer YOUR_API_KEY; it needs the Change sources and training permission. See Authentication.
Body parameters
| Name | Type | Required | Description |
|---|---|---|---|
chatbotId | string | Yes | The agent's id, from list_agents. |
sourceId | string | Yes | The source's id, from list_sources. |
expectedVersion | integer | Yes | The source's current version. |
Request example
curl -X POST 'https://api.qwryai.com/public/v1/tools/delete_source' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"chatbotId": "YOUR_AGENT_ID", "sourceId": "SOURCE_ID", "expectedVersion": 2}'const headers = {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
};
const prepared = await fetch(
"https://api.qwryai.com/public/v1/tools/delete_source",
{
method: "POST",
headers,
body: JSON.stringify({ chatbotId: "YOUR_AGENT_ID", sourceId: "SOURCE_ID", expectedVersion: 2 }),
}
).then((response) => response.json());
// After a person approves prepared.data.changes:
await fetch(
`https://api.qwryai.com/public/v1/reviews/${prepared.data.reviewId}/apply`,
{ method: "POST", headers }
);import requests
headers = {"Authorization": "Bearer YOUR_API_KEY"}
review = requests.post(
"https://api.qwryai.com/public/v1/tools/delete_source",
headers=headers,
json={"chatbotId": "YOUR_AGENT_ID", "sourceId": "SOURCE_ID", "expectedVersion": 2},
).json()["data"]
applied = requests.post(
f"https://api.qwryai.com/public/v1/reviews/{review['reviewId']}/apply",
headers=headers,
).json()["data"]Response
The review
{
"success": true,
"data": {
"status": "review_required",
"reviewId": "5d0e8b3a-91c4-4f27-b6d8-3a2e1f0c9b75",
"tool": "delete_source",
"changes": [
{
"title": "Delete source: Returns FAQ",
"before": { "status": "Trained" },
"after": { "status": "Deleted" }
}
],
"unchanged": [],
"expiresAt": "2026-12-01T10:15:00.000Z",
"next": "Show these changes to the user. Call apply_change with this reviewId only after they approve; the review expires in 15 minutes."
}
}before.status is the source's training state as the dashboard words it: Not trained, Changed, Trained or Removal pending.
After you apply it
{
"success": true,
"data": {
"status": "succeeded",
"reviewId": "5d0e8b3a-91c4-4f27-b6d8-3a2e1f0c9b75",
"tool": "delete_source",
"data": {
"operationId": "<operationId>",
"sourceId": "<sourceId>",
"disposition": "pending_deletion",
"training": "not_started",
"applied": true
},
"receipt": {
"applied": true,
"matchesApprovedState": true,
"current": { "id": "<sourceId>", "name": "Returns FAQ", "desiredLifecycle": "pending_deletion", "publicationState": "removal_pending", "pendingChanges": true, "exists": true }
}
}
}The receipt is shortened here. When the source was deleted at once, disposition is deleted and receipt.current is { "exists": false }. To take a Removed source out of the agent's answers, train with train_pending_sources.
Errors
| HTTP status | code | when |
|---|---|---|
| 400 | INVALID_ARGUMENTS | sourceId isn't a valid id or expectedVersion isn't a positive whole number. |
| 400 | CHATBOT_ID_REQUIRED | chatbotId is missing or isn't a valid agent id. |
| 403 | INSUFFICIENT_PERMISSION | The key doesn't hold Change sources and training. |
| 404 | CHATBOT_NOT_FOUND | No agent with that chatbotId in your workspace. |
| 404 | SOURCE_NOT_FOUND | The agent has no source with that id. |
| 409 | SOURCE_VERSION_CONFLICT | expectedVersion isn't the source's current version. Read it again. |
| 409 | SOURCE_ALREADY_PENDING_DELETION | On apply: the source is already marked Removed. |
| 409 | SOURCE_OPERATION_IN_PROGRESS | On apply: the source is being fetched or trained. Try again when it's idle. |
| 409 | STALE_REVIEW | On apply: the source changed after the review. Call the tool again. |
| 429 | INTEGRATION_RATE_LIMIT_EXCEEDED | More than 2,000 requests in 15 minutes for this key. |
| 500 | TOOL_FAILED | The tool failed on our side. Try again. |
Authentication and plan errors are listed in Error Handling.