# Update source > Rename a source, change a website's crawl options, or replace the text of a Plain Text or Q&A document `update_source` changes a source's name, its description, or a website's advanced options. `update_source_content` replaces the text of one document in a **Plain Text** or **Q&A Pairs** source. Both return a review; nothing changes until you apply it. Every edit names the `version` you read, as `expectedVersion`, so it never overwrites a change someone made after you read the source. ```http POST https://api.qwryai.com/public/v1/tools/update_source ``` Content edits use `POST https://api.qwryai.com/public/v1/tools/update_source_content`. ## Authentication Send your API key as `Authorization: Bearer YOUR_API_KEY`; it needs the **Change sources and training** permission. See [Authentication](/docs/api-reference/v2/authentication). ## Body parameters > [tab] Name and options > > `update_source` works on every source type. Send only what you want to change. > > | Name | Type | Required | Description | > | - | - | - | - | > | `chatbotId` | `string` | Yes | The agent's id, from `list_agents`. | > | `sourceId` | `string` | Yes | The source's `id`, from `list_sources`. | > | `expectedVersion` | `integer` | Yes | The source's current `version`. | > | `name` | `string` | No | A new name, 1 to 100 characters. | > | `description` | `string` | No | A new description, up to 2,000 characters. | > | `website` | `object` | No | A website's advanced options: `include_paths`, `exclude_paths`, `include_query_parameters`, `slow_scraping`, `load_in_browser` and `scraping_location`, as in [Create source](/docs/api-reference/v2/sources/create-source). Options you leave out keep their value; they apply at the next fetch. | > [tab] Content > > `update_source_content` replaces one document of a Plain Text or Q&A Pairs source. Read it in full with `read_source_document` first, then send the whole new text. > > | Name | Type | Required | Description | > | - | - | - | - | > | `chatbotId` | `string` | Yes | The agent's id, from `list_agents`. | > | `sourceId` | `string` | Yes | The source's `id`. | > | `expectedVersion` | `integer` | Yes | The source's current `version`. | > | `documentId` | `string` | Yes | The document's `id`, from `get_source_content`. | > | `title` | `string` | Yes | The document's title, 1 to 100 characters. For Q&A, the question as listed. | > | `content` | `string` | Yes | The complete new text or answer, 1 to 10,000 characters. | > | `contentType` | `string` | Yes | `text` or `qa`, matching the document. | > | `questions` | `array` | No | Q&A only: up to 10 phrasings of the question, each up to 1,000 characters. Left out, the current ones stay. | A website's address can't be changed. To point at another address, add a new website source and delete the old one. ## Request example > [tab] cURL > > ```bash > curl -X POST 'https://api.qwryai.com/public/v1/tools/update_source' \ > -H 'Authorization: Bearer YOUR_API_KEY' \ > -H 'Content-Type: application/json' \ > -d '{ > "chatbotId": "YOUR_AGENT_ID", > "sourceId": "SOURCE_ID", > "expectedVersion": 3, > "name": "Help center (EN)", > "website": { "exclude_paths": [{ "operator": "contains", "value": "/fr/" }] } > }' > ``` > [tab] JavaScript > > ```javascript > const response = await fetch( > "https://api.qwryai.com/public/v1/tools/update_source_content", > { > method: "POST", > headers: { > Authorization: "Bearer YOUR_API_KEY", > "Content-Type": "application/json", > }, > body: JSON.stringify({ > chatbotId: "YOUR_AGENT_ID", > sourceId: "SOURCE_ID", > expectedVersion: 1, > documentId: "DOCUMENT_ID", > title: "Do you ship to Canada?", > content: "Yes, orders to Canada arrive in 4 to 6 business days.", > contentType: "qa", > }), > } > ); > const { data: review } = await response.json(); > ``` > [tab] Python > > ```python > import requests > > response = requests.post( > "https://api.qwryai.com/public/v1/tools/update_source", > headers={"Authorization": "Bearer YOUR_API_KEY"}, > json={ > "chatbotId": "YOUR_AGENT_ID", > "sourceId": "SOURCE_ID", > "expectedVersion": 3, > "description": "English help articles only", > }, > ) > review = response.json()["data"] > ``` ## Response ### The review ```json { "success": true, "data": { "status": "review_required", "reviewId": "c4a81e2d-5f37-4b90-8e6a-1d2b3c4d5e6f", "tool": "update_source", "changes": [ { "title": "Update source: Help center", "before": { "name": "Help center", "description": null, "website": { "include_paths": ["starts_with /help"], "exclude_paths": [], "include_query_parameters": false, "slow_scraping": false, "load_in_browser": false, "scraping_location": "us" } }, "after": { "name": "Help center (EN)", "description": null, "website": { "include_paths": ["starts_with /help"], "exclude_paths": ["contains /fr/"], "include_query_parameters": false, "slow_scraping": false, "load_in_browser": false, "scraping_location": "us" } } } ], "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." } } ``` A content review shows the document's `title` and `content` (and `questions` for Q&A) before and after. ### Apply it ```bash curl -X POST 'https://api.qwryai.com/public/v1/reviews/REVIEW_ID/apply' \ -H 'Authorization: Bearer YOUR_API_KEY' ``` ```json { "success": true, "data": { "status": "succeeded", "reviewId": "c4a81e2d-5f37-4b90-8e6a-1d2b3c4d5e6f", "tool": "update_source", "data": { "operationId": "", "sourceId": "", "disposition": "saved", "training": "not_started", "applied": true }, "receipt": { "applied": true, "matchesApprovedState": true, "current": { "id": "", "name": "Help center (EN)", "version": 4, "publicationState": "changed", "pendingChanges": true, "exists": true } } } } ``` The `receipt` is shortened here. A content edit leaves the source **Changed**: the agent keeps answering from the trained version until you train it again with `start_training` or `train_pending_sources`. ## Errors | HTTP status | code | when | | - | - | - | | 400 | `INVALID_ARGUMENTS` | An argument failed the schema, or `contentType` doesn't match the document. `issues` or `message` says which. | | 400 | `WEBSITE_SETTINGS_INVALID` | A path rule can't be used. | | 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. | | 409 | `SOURCE_VERSION_CONFLICT` | `expectedVersion` isn't the source's current version. Read it again. | | 409 | `SOURCE_PENDING_DELETION` | On apply: the source is marked **Removed**. Restore it first. | | 409 | `SOURCE_OPERATION_IN_PROGRESS` | On apply: the source is being fetched or trained. Try again when it's idle. | | 409 | `STALE_REVIEW` | On apply: the source changed after the review. Call the tool again. | | 422 | `SOURCE_SIZE_LIMIT_EXCEEDED` | On apply: the new content would take the agent over its training data allowance. | | 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](/docs/api-reference/v2/error-handling).