Skip to content
QwryAI
Documentation
Pages

Guides

Sources

Read and manage the websites, text and Q&A your agent learns from, then train it

The source tools give your code the same control as Data sources in the dashboard: list sources and their training state, read what's inside them, add text, Q&A pairs and websites, rename or delete them, and start training. Reading needs Read agent settings; changes need Change sources and training.

Every change goes through a review that you apply, and training is its own step. Adding a source saves it as New; it isn't used in answers until you train.

Source types

Typetype valueList and readAddEditDelete and restore
Websiteurl✓✓ add_url_source✓ name, description, crawl options, pages✓
Plain Texttext✓✓ upload_text_source✓ content✓
Q&A Pairsqa✓✓ add_qna_pairs✓ content✓
Documentfile, csv, excel✓✗✓ name and description✓
Notionnotion✓✗✓ name and description✓

Once added, the API lists, reads, renames, trains and deletes them like any other source.

Source status

list_sources returns each source's lifecycle fields. find_sources_by_status also adds the single status the Data sources page shows:

statusMeaning
newSaved but never trained. Not used in answers yet.
changedEdited since it last trained. The previous version still answers.
trainingTraining now.
trainedLive: the agent answers from it.
failedThe last training didn't finish. Any earlier trained version still answers.
partly_trainedA website with pages still left to train.
removedDeleted, waiting for the next training to take it out of the agent.
Bash
curl -X POST 'https://api.qwryai.com/public/v1/tools/find_sources_by_status' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{"chatbotId": "YOUR_AGENT_ID", "statuses": ["new", "changed", "failed"], "page": 1}'

get_sources_summary returns the totals: how many sources of each kind, what's waiting to train, and how much of the plan's training quota is used. check_training_status follows one source.

Training is a separate step

A new, edited or deleted source changes nothing in the agent's answers until you train:

ToolDoes
train_pending_sourcesWhat Retrain agent does on the Data sources page: trains every new, changed and failed source and removes every removed one, up to 20 per review.
start_trainingTrains one source at the expectedVersion you read.
toggle_auto_retrainTurns weekly retraining on or off for a website source, on plans that include it.

Applying a training review queues the training; it doesn't wait for it to finish. Poll find_sources_by_status or check_training_status until the source reads trained or failed.

Editing a source

Each edit names the version you read, as expectedVersion. If someone changed the source after you read it, the review is refused and you read it again. To replace text or Q&A content, read the document in full with read_source_document first, then send the whole new content to update_source_content.

Deletes wait for training

delete_source deletes a source that was never trained at once. A trained source is marked Removed instead: the agent keeps answering from it until the next training removes it, and until then restore_source brings it back. After that training, the delete can't be undone.

Endpoints

Error codes

Source-specific error codes beyond the standard authentication and rate-limiting errors:

CodeHTTPDescription
INVALID_ARGUMENTS400An argument failed the tool's schema, such as text over 10,000 characters or more than 3 Q&A pairs in one call.
CHATBOT_NOT_FOUND404No agent with that chatbotId in your workspace.
NOTHING_TO_CHANGE409The source already has the values you sent.
STALE_REVIEW409The source changed after the review. Read it again and call the tool again.
TOO_MANY_CHANGES400More than 20 changes in one review.
INSUFFICIENT_PERMISSION403Reading needs Read agent settings; changes need Change sources and training.

Explore the documentation