Skip to content
QwryAI
Documentation
Pages

Endpoints

Restore source

Bring back a source marked Removed before the next training takes it out of the agent

restore_source undoes a delete that hasn't trained yet. Deleting a trained source marks it Removed, and the agent keeps answering from it until the next training. Until that training runs, this tool sets the source back to active, as if it had never been deleted. It's a live tool, not deprecated, and it returns a review that you apply.

POSThttps://api.qwryai.com/public/v1/tools/restore_source

Only a source that is Removed and idle can be restored. A never-trained source is deleted at once and can't be restored, and neither can one whose removal has been trained. See 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. Find Removed sources with find_sources_by_status and ["removed"].
expectedVersionintegerYesThe source's current version.

Request example

Bash
curl -X POST 'https://api.qwryai.com/public/v1/tools/restore_source' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{"chatbotId": "YOUR_AGENT_ID", "sourceId": "SOURCE_ID", "expectedVersion": 3}'

Response

The review

JSON
{
  "success": true,
  "data": {
    "status": "review_required",
    "reviewId": "e7a3c2b1-0d4f-4e8a-9b6c-5f1d2e3a4b70",
    "tool": "restore_source",
    "changes": [
      {
        "title": "Restore source: Returns FAQ",
        "before": { "status": "Pending deletion" },
        "after": { "status": "Restored" }
      }
    ],
    "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."
  }
}

After you apply it

Apply with POST https://api.qwryai.com/public/v1/reviews/{reviewId}/apply:

JSON
{
  "success": true,
  "data": {
    "status": "succeeded",
    "reviewId": "e7a3c2b1-0d4f-4e8a-9b6c-5f1d2e3a4b70",
    "tool": "restore_source",
    "data": {
      "operationId": "<operationId>",
      "sourceId": "<sourceId>",
      "disposition": "restored",
      "training": "not_started",
      "applied": true
    },
    "receipt": {
      "applied": true,
      "matchesApprovedState": true,
      "current": { "id": "<sourceId>", "name": "Returns FAQ", "desiredLifecycle": "active", "exists": true }
    }
  }
}

The receipt is shortened here. The source keeps the trained version it had before the delete; no new training is needed.

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, or its removal has already been trained.
409SOURCE_NOT_RESTORABLEThe source isn't Removed, or training is removing it right now.
409SOURCE_VERSION_CONFLICTexpectedVersion isn't the source's current version. Read it again.
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