Skip to content
QwryAI
Documentation
Pages

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 sourceAfter you apply the review
Was never trainedIt's deleted at once. disposition is deleted.
Has been trainedIt'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.
POSThttps://api.qwryai.com/public/v1/tools/delete_source

Authentication

Send your API key as Authorization: Bearer YOUR_API_KEY; it needs the Change sources and training permission. See Authentication.

Body parameters

NameTypeRequiredDescription
chatbotIdstringYesThe agent's id, from list_agents.
sourceIdstringYesThe source's id, from list_sources.
expectedVersionintegerYesThe source's current version.

Request example

Bash
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}'

Response

The review

JSON
{
  "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

JSON
{
  "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 statuscodewhen
400INVALID_ARGUMENTSsourceId isn't a valid id or expectedVersion isn't a positive whole number.
400CHATBOT_ID_REQUIREDchatbotId is missing or isn't a valid agent id.
403INSUFFICIENT_PERMISSIONThe key doesn't hold Change sources and training.
404CHATBOT_NOT_FOUNDNo agent with that chatbotId in your workspace.
404SOURCE_NOT_FOUNDThe agent has no source with that id.
409SOURCE_VERSION_CONFLICTexpectedVersion isn't the source's current version. Read it again.
409SOURCE_ALREADY_PENDING_DELETIONOn apply: the source is already marked Removed.
409SOURCE_OPERATION_IN_PROGRESSOn apply: the source is being fetched or trained. Try again when it's idle.
409STALE_REVIEWOn apply: the source changed after the review. Call the tool again.
429INTEGRATION_RATE_LIMIT_EXCEEDEDMore than 2,000 requests in 15 minutes for this key.
500TOOL_FAILEDThe tool failed on our side. Try again.

Authentication and plan errors are listed in Error Handling.

Explore the documentation