# Create source > Add a Plain Text, Q&A Pairs or Website source to an agent through a review you apply Each kind of source has its own tool: `upload_text_source` for **Plain Text**, `add_qna_pairs` for **Q&A Pairs** and `add_url_source` for a **Website**. The call returns a review; nothing is saved until you apply it. Once applied, the source appears on the **Data sources** page as **New**. It isn't used in answers until you train it, so follow up with `train_pending_sources` or `start_training`. ```http POST https://api.qwryai.com/public/v1/tools/upload_text_source ``` The other two tools use the same URL with their own name: `POST https://api.qwryai.com/public/v1/tools/add_qna_pairs` and `POST https://api.qwryai.com/public/v1/tools/add_url_source`. > [!NOTE] > > Files and Notion pages can't be added through the API. Upload documents under **Data sources › Document** and connect Notion in the dashboard; the API lists, renames, trains and deletes them once they're there. ## 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] Plain Text > > `upload_text_source` > > | Name | Type | Required | Description | > | - | - | - | - | > | `chatbotId` | `string` | Yes | The agent's id, from `list_agents`. | > | `name` | `string` | Yes | The source's name, 1 to 100 characters. | > | `content` | `string` | Yes | The text, 1 to 10,000 characters. | > [tab] Q&A Pairs > > `add_qna_pairs` > > | Name | Type | Required | Description | > | - | - | - | - | > | `chatbotId` | `string` | Yes | The agent's id, from `list_agents`. | > | `name` | `string` | Yes | The source's name, 1 to 100 characters. | > | `pairs` | `array` | Yes | 1 to 3 pairs per call, each `{ "question", "answer" }`. A question is up to 1,000 characters, an answer up to 4,000. | > [tab] Website > > `add_url_source` > > | Name | Type | Required | Description | > | - | - | - | - | > | `chatbotId` | `string` | Yes | The agent's id, from `list_agents`. | > | `name` | `string` | Yes | The source's name, 1 to 100 characters. | > | `url` | `string` | Yes | A public `http` or `https` address, up to 2,000 characters. | > | `mode` | `string` | Yes | `individual` (this page only), `crawl` (follow links from it) or `sitemap` (read the sitemap at this address). | > | `website` | `object` | No | The website form's advanced options, below. | > > | `website` field | Type | Description | > | - | - | - | > | `include_paths` | `array` | **Only include paths**: fetch only pages matching one rule. Up to 100 rules. | > | `exclude_paths` | `array` | **Exclude paths**: skip pages matching a rule. Up to 100 rules. | > | `include_query_parameters` | `boolean` | Treat addresses that differ only after `?` as different pages. | > | `slow_scraping` | `boolean` | Fetch slowly, for sites that block fast crawling. | > | `load_in_browser` | `boolean` | Render pages in a browser first, for sites built with JavaScript. | > | `scraping_location` | `string` | The country pages are fetched from, such as `us`. | > > Each path rule is `{ "operator", "value" }`. `operator` is `starts_with`, `ends_with`, `contains`, `exact_match` or `wildcard`; `value` is up to 500 characters. ## Request example > [tab] cURL > > ```bash > curl -X POST 'https://api.qwryai.com/public/v1/tools/upload_text_source' \ > -H 'Authorization: Bearer YOUR_API_KEY' \ > -H 'Content-Type: application/json' \ > -d '{ > "chatbotId": "YOUR_AGENT_ID", > "name": "Shipping policy", > "content": "We ship to the US and Canada. Orders leave our warehouse within 2 business days." > }' > ``` > [tab] JavaScript > > ```javascript > const response = await fetch( > "https://api.qwryai.com/public/v1/tools/add_qna_pairs", > { > method: "POST", > headers: { > Authorization: "Bearer YOUR_API_KEY", > "Content-Type": "application/json", > }, > body: JSON.stringify({ > chatbotId: "YOUR_AGENT_ID", > name: "Shipping to Canada", > pairs: [ > { > question: "Do you ship to Canada?", > answer: "Yes, orders to Canada arrive in 5 to 7 business days.", > }, > ], > }), > } > ); > const { data: review } = await response.json(); > ``` > [tab] Python > > ```python > import requests > > response = requests.post( > "https://api.qwryai.com/public/v1/tools/add_url_source", > headers={"Authorization": "Bearer YOUR_API_KEY"}, > json={ > "chatbotId": "YOUR_AGENT_ID", > "name": "Help center", > "url": "https://www.example.com/help", > "mode": "crawl", > "website": { > "include_paths": [{"operator": "starts_with", "value": "/help"}], > "exclude_paths": [{"operator": "contains", "value": "/archive"}], > }, > }, > ) > review = response.json()["data"] > ``` ## Response ### The review ```json { "success": true, "data": { "status": "review_required", "reviewId": "9b2f4c71-3e8a-4d5b-a1c6-7f0e2d9b8a34", "tool": "add_qna_pairs", "changes": [ { "title": "Add source: Shipping to Canada", "before": null, "after": { "name": "Shipping to Canada", "pairs": [ { "question": "Do you ship to Canada?", "answer": "Yes, orders to Canada arrive in 5 to 7 business days." } ] } } ], "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." } } ``` ### Apply it Send `POST https://api.qwryai.com/public/v1/reviews/{reviewId}/apply` within 15 minutes, with the same key: ```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": "9b2f4c71-3e8a-4d5b-a1c6-7f0e2d9b8a34", "tool": "add_qna_pairs", "data": { "operationId": "", "sourceId": "", "disposition": "saved", "training": "not_started", "applied": true }, "receipt": { "applied": true, "operation": { "id": "", "type": "create", "status": "succeeded", "sourceId": "", "createdAt": "2026-12-01T10:02:11.402Z", "updatedAt": "2026-12-01T10:02:11.402Z" }, "matchesApprovedState": true, "current": { "id": "", "name": "Shipping to Canada", "type": "qa", "version": 1, "publicationState": "never_published", "pendingChanges": true, "exists": true } } } } ``` The `receipt` is shortened here; it also carries `available`, `observedAt`, `coverage` and the rest of the source's fields. `data.data.sourceId` is the new source's id. `training` is `not_started`: train the source next, then poll `check_training_status` until it reads `published`. A website is saved first and fetched during training. ## Errors | HTTP status | code | when | | - | - | - | | 400 | `INVALID_ARGUMENTS` | An argument failed the schema: a name over 100 characters, text over 10,000 characters, more than 3 Q&A pairs, an unknown `mode`, or an unknown field. `issues` names each one. | | 400 | `SOURCE_URL_INVALID` | The website address doesn't resolve to a public `http` or `https` address. | | 400 | `WEBSITE_SETTINGS_INVALID` | A path rule can't be used. `message` says which. | | 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 | `REVIEW_NOT_FOUND` | On apply: no review with that id for this key. | | 409 | `SOURCE_DUPLICATE` | On apply: the agent already has a website source for this address. | | 409 | `REVIEW_ALREADY_USED` / `REVIEW_EXPIRED` | On apply: the review was used already, or more than 15 minutes passed. Call the tool again. | | 422 | `SOURCE_SIZE_LIMIT_EXCEEDED` | On apply: the agent would go over its plan's 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).