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.
https://api.qwryai.com/public/v1/tools/restore_sourceOnly 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
| Name | Type | Required | Description |
|---|---|---|---|
chatbotId | string | Yes | The agent's id, from list_agents. |
sourceId | string | Yes | The source's id. Find Removed sources with find_sources_by_status and ["removed"]. |
expectedVersion | integer | Yes | The source's current version. |
Request example
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}'const response = await fetch(
"https://api.qwryai.com/public/v1/tools/restore_source",
{
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({ chatbotId: "YOUR_AGENT_ID", sourceId: "SOURCE_ID", expectedVersion: 3 }),
}
);
const { data: review } = await response.json();import requests
review = requests.post(
"https://api.qwryai.com/public/v1/tools/restore_source",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"chatbotId": "YOUR_AGENT_ID", "sourceId": "SOURCE_ID", "expectedVersion": 3},
).json()["data"]Response
The review
{
"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:
{
"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 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, or its removal has already been trained. |
| 409 | SOURCE_NOT_RESTORABLE | The source isn't Removed, or training is removing it right now. |
| 409 | SOURCE_VERSION_CONFLICT | expectedVersion isn't the source's current version. Read it again. |
| 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.