# CLI Sources > Add, list, update, train and remove a QwryAI agent's knowledge sources from the terminal Use the source tools to manage an agent's knowledge: plain text, Q&A pairs and websites. Each one takes the agent's id as `chatbotId`; see [CLI Agents](/docs/cli/agents) to get it into `$AGENT`. Tools that change a source are reviewed, so run `qwryai-cli apply ` after checking each one. See [CLI API](/docs/cli/api). ## Add sources Plain text, up to 10,000 characters: ```bash qwryai-cli tools:call upload_text_source --args "{\"chatbotId\":\"$AGENT\",\"name\":\"Holiday opening hours\",\"content\":\"Our stores are closed on 25 and 26 December and open 10am to 4pm on 31 December.\"}" ``` ```json { "success": true, "data": { "status": "review_required", "reviewId": "", "tool": "upload_text_source", "changes": [ { "title": "Add source: Holiday opening hours", "before": null, "after": { "name": "Holiday opening hours", "content": "Our stores are closed on 25 and 26 December and open 10am to 4pm on 31 December." } } ], "unchanged": [], "expiresAt": "2026-12-01T18:36:47.205Z", "next": "Show these changes to the user. Call apply_change with this reviewId only after they approve; the review expires in 15 minutes." } } ``` A website, crawled from a starting page: ```bash qwryai-cli tools:call add_url_source --args "{\"chatbotId\":\"$AGENT\",\"name\":\"Help center\",\"url\":\"https://www.yourstore.com/help\",\"mode\":\"crawl\"}" ``` `mode` is `crawl`, `sitemap` (a sitemap.xml address) or `individual` (one page). Add a `website` object for the advanced options: `include_paths`, `exclude_paths`, `include_query_parameters`, `slow_scraping`, `load_in_browser` and `scraping_location`. Q&A pairs, up to three in one source: ```bash qwryai-cli tools:call add_qna_pairs --args "{\"chatbotId\":\"$AGENT\",\"name\":\"Shipping to Canada\",\"pairs\":[{\"question\":\"Do you ship to Canada?\",\"answer\":\"Yes. Orders to Canada arrive in 7 to 14 business days.\"}]}" ``` > [!NOTE] > > Upload documents such as PDFs on the **Data sources** page in QwryAI. The CLI adds text, Q&A and website sources. ## List and inspect List the agent's sources, twenty per page, with their type, version and training state: ```bash qwryai-cli tools:call list_sources --args "{\"chatbotId\":\"$AGENT\",\"page\":1}" ``` ```json { "success": true, "data": { "items": [ { "id": "", "name": "Shipping, late orders and missing parcels policy", "type": "text", "version": 1, "desiredLifecycle": "active", "processingState": "idle", "publicationState": "published", "publishedCount": 1, "health": "healthy", "warning": null, "operation": { "status": "succeeded", "phase": "embedding", "progress": 100 }, "pendingChanges": false, "updatedAt": "2026-10-10T04:33:22.670Z", "autoRetrain": false } ], "pagination": { "page": 1, "limit": 20, "total": 21, "pages": 2 } } } ``` Add `search` to match names, or `type` (`url`, `text`, `qa`, `file`, `csv`, `excel` or `notion`) for one kind. Show one source's training state, health and pending changes: ```bash qwryai-cli tools:call check_training_status --args "{\"chatbotId\":\"$AGENT\",\"sourceId\":\"\"}" ``` Read what's inside it with `get_source_content` (ten document excerpts per page) and `read_source_document` (one document in full). For a website, `list_source_pages` lists its pages. View the totals by type and how much of your training quota is used: ```bash qwryai-cli tools:call get_sources_summary --args "{\"chatbotId\":\"$AGENT\"}" ``` ```json { "success": true, "data": { "total": 21, "active": 4, "pendingDeletion": 17, "pendingChanges": 19, "processing": 0, "totalBillableBytes": 825140, "byType": [ { "type": "url", "sources": 1, "documents": 2, "bytes": 9996 }, { "type": "qa", "sources": 1, "documents": 1, "bytes": 53 }, { "type": "text", "sources": 1, "documents": 1, "bytes": 2658 } ], "trainingQuota": { "usedBytes": 840860, "desiredBytes": 840860, "limitBytes": 41943040, "exceeded": false } } } ``` ## Update and delete Rename a source, change its description, or change a website's crawl options for its next fetch: ```bash qwryai-cli tools:call update_source --args "{\"chatbotId\":\"$AGENT\",\"sourceId\":\"\",\"expectedVersion\":1,\"name\":\"Shipping policy\"}" ``` Replace the text or answer in a text or Q&A source with `update_source_content`, which takes the `documentId` from `get_source_content`, a `title`, the new `content` and `contentType` (`text` or `qa`). Delete a source: ```bash qwryai-cli tools:call delete_source --args "{\"chatbotId\":\"$AGENT\",\"sourceId\":\"\",\"expectedVersion\":1}" ``` A deleted source is marked **Removed** and leaves the agent's knowledge at the next training. Until then, `restore_source` brings it back. Every update tool asks for `expectedVersion`, the source's current `version` from `list_sources`. If the source changed since you read it, the call is refused and you read it again. ## Train your changes New and changed sources don't reach your agent until they're trained. Find what's waiting: ```bash qwryai-cli tools:call find_sources_by_status --args "{\"chatbotId\":\"$AGENT\",\"statuses\":[\"new\",\"changed\",\"failed\"],\"page\":1}" ``` Then train them all, as **Retrain agent** does on the **Data sources** page. This also removes every source marked **Removed**: ```bash qwryai-cli tools:call train_pending_sources --args "{\"chatbotId\":\"$AGENT\"}" ``` To train one source only, use `start_training` with its `sourceId` and `expectedVersion`. Applying either review queues the training; follow it with `check_training_status`. Training quotas from your plan apply. > [!TIP] > > Statuses match the **Data sources** page: `new`, `changed`, `training`, `trained`, `failed`, `removed` and `partly_trained` (a website with pages still to train). See [CLI Agents](/docs/cli/agents) for weekly auto-retraining of websites. ## Commands | Tool | Purpose | | - | - | | `upload_text_source` | Add a plain text source (reviewed) | | `add_qna_pairs` | Add up to three Q&A pairs as a source (reviewed) | | `add_url_source` | Add a website, sitemap or single page (reviewed) | | `list_sources` | List an agent's sources | | `check_training_status` | Show one source's training state and health | | `get_source_content` / `read_source_document` | Read what's inside a source | | `list_source_pages` / `set_source_page_included` | List a website's pages, and include or exclude one (reviewed) | | `get_sources_summary` | Show totals by type and training quota | | `update_source` / `update_source_content` | Change a source's details or its text (reviewed) | | `delete_source` / `restore_source` | Mark a source Removed, or bring it back (reviewed) | | `find_sources_by_status` | Find sources by their Data sources status | | `train_pending_sources` / `start_training` | Train every pending source, or one source (reviewed) | > [!NOTE] > > These tools need the **Change sources and training** permission to make changes and **Read agent settings** to read.