# Import External Content

> Import content from external sources into the Knowledge Base. These endpoints process content asynchronously.

Import content from external sources into the Knowledge Base. These endpoints process content asynchronously.

:::note[Async Processing]
All import endpoints process content asynchronously. After submitting an import request, the content is scraped and added to the Knowledge Base in the background. The Knowledge Base is automatically marked for retraining once the import completes.

To monitor progress:
1. Check `retrain_state` via [Get Knowledge Base Settings](/api-reference/knowledge-base/#get-settings) — it changes to `"to_be_retrained"` then `"in_progress"` then `"up_to_date"`
2. Use [List Articles](/api-reference/knowledge-base/articles/#list-articles) to verify imported articles appear
:::

## Scrape Website

Scrape a single webpage or an entire website and import the content.

**Scope: write_all**

`POST https://app.quickchat.ai/v1/api/knowledge_base/import_external/website`

**Request Body**

| Parameter | Description |
|-----------|-------------|
| `url` <br/> string, required | URL to scrape |
| `mode` <br/> string | `"individual"` (default), `"site_wide"`, or `"individual_with_summary"` |
| `phrases` <br/> array of strings | Key phrases to extract |
| `html_selector` <br/> string | CSS selector to target specific content |

**Shell**

```shell
curl -X POST https://app.quickchat.ai/v1/api/knowledge_base/import_external/website \
  -H 'Authorization: Bearer <API_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{
  "url": "https://example.com/docs",
  "mode": "individual"
}'
```

**Python**

```python
import requests

response = requests.post(
    url="https://app.quickchat.ai/v1/api/knowledge_base/import_external/website",
    headers={"Authorization": "Bearer <API_TOKEN>"},
    json={"url": "https://example.com/docs", "mode": "individual"},
)
data = response.json()
```

**Response** `202 Accepted`

```json
{
  "status": "success",
  "url": "https://example.com/docs",
  "article": {}
}
```

## Import YouTube Transcript

Import the transcript from a YouTube video.

**Scope: write_all**

`POST https://app.quickchat.ai/v1/api/knowledge_base/import_external/youtube`

**Request Body**

| Parameter | Description |
|-----------|-------------|
| `url` <br/> string, required | YouTube video URL |
| `toast_process_uuid` <br/> string, required | UUID v4 for tracking the import process |

**Shell**

```shell
curl -X POST https://app.quickchat.ai/v1/api/knowledge_base/import_external/youtube \
  -H 'Authorization: Bearer <API_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{
  "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "toast_process_uuid": "550e8400-e29b-41d4-a716-446655440000"
}'
```

**Python**

```python
import uuid
import requests

response = requests.post(
    url="https://app.quickchat.ai/v1/api/knowledge_base/import_external/youtube",
    headers={"Authorization": "Bearer <API_TOKEN>"},
    json={
        "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
        "toast_process_uuid": str(uuid.uuid4()),
    },
)
```

**Response** `202 Accepted` — The transcript is processed asynchronously.

## Import Sitemap

Import content from all links in an XML sitemap.

**Scope: write_all**

`POST https://app.quickchat.ai/v1/api/knowledge_base/import_external/site-map`

**Request Body**

| Parameter | Description |
|-----------|-------------|
| `site_map` <br/> string, required | URL to an XML sitemap |
| `link_filter_regex` <br/> string | Regex to filter which links to import (default: `".*"`) |
| `html_selector` <br/> string | CSS selector to target specific content |
| `summarize` <br/> boolean | Whether to summarize imported content (default: `false`) |

**Shell**

```shell
curl -X POST https://app.quickchat.ai/v1/api/knowledge_base/import_external/site-map \
  -H 'Authorization: Bearer <API_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{
  "site_map": "https://example.com/sitemap.xml"
}'
```

**Python**

```python
import requests

response = requests.post(
    url="https://app.quickchat.ai/v1/api/knowledge_base/import_external/site-map",
    headers={"Authorization": "Bearer <API_TOKEN>"},
    json={"site_map": "https://example.com/sitemap.xml"},
)
data = response.json()
```

**Response** `202 Accepted`

```json
{
  "status": "success",
  "links": ["https://example.com/page1", "https://example.com/page2"]
}
```

## Scrape List of Links

Import content from a specific list of URLs.

**Scope: write_all**

`POST https://app.quickchat.ai/v1/api/knowledge_base/import_external/scrape-list`

**Request Body**

| Parameter | Description |
|-----------|-------------|
| `links` <br/> array of strings, required | List of URLs to scrape (non-empty) |
| `tags` <br/> array of strings | Tags to apply to imported articles |
| `html_selector` <br/> string | CSS selector to target specific content |
| `summarize` <br/> boolean | Whether to summarize imported content (default: `false`) |

**Shell**

```shell
curl -X POST https://app.quickchat.ai/v1/api/knowledge_base/import_external/scrape-list \
  -H 'Authorization: Bearer <API_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{
  "links": ["https://example.com/page1", "https://example.com/page2"],
  "tags": ["imported"]
}'
```

**Python**

```python
import requests

response = requests.post(
    url="https://app.quickchat.ai/v1/api/knowledge_base/import_external/scrape-list",
    headers={"Authorization": "Bearer <API_TOKEN>"},
    json={
        "links": ["https://example.com/page1", "https://example.com/page2"],
        "tags": ["imported"],
    },
)
data = response.json()
```

**Response** `202 Accepted`

```json
{
  "status": "success",
  "links": ["https://example.com/page1", "https://example.com/page2"]
}
```

## Delete Links

Remove previously imported URL-type articles from the Knowledge Base.

**Scope: write_all**

`DELETE https://app.quickchat.ai/v1/api/knowledge_base/import_external`

**Request Body**

| Parameter | Description |
|-----------|-------------|
| `links` <br/> array of strings, required | List of URLs to remove (min 1) |

:::note
All provided URLs must exist in the Knowledge Base as URL-type articles. If any URL doesn't match an existing article, the request returns `404`.
:::

**Shell**

```shell
curl -X DELETE https://app.quickchat.ai/v1/api/knowledge_base/import_external \
  -H 'Authorization: Bearer <API_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{
  "links": ["https://example.com/page1"]
}'
```

**Python**

```python
import requests

response = requests.delete(
    url="https://app.quickchat.ai/v1/api/knowledge_base/import_external",
    headers={"Authorization": "Bearer <API_TOKEN>"},
    json={
        "links": ["https://example.com/page1"],
    },
)
```

**Response** `200 OK`

---
