# Public APIs

<figure><img src="/files/j3YDEvYFE3ixqubPz3gX" alt=""><figcaption></figcaption></figure>

### Adding a data source to a knowledge base <a href="#adding-a-data-source-to-a-knowledge-base" id="adding-a-data-source-to-a-knowledge-base"></a>

`POST` `/api/v1/ai/knowledge-base/<knowledge_base_id>/upload/sources`

Using this API, you can add a data source to an existing knowledge base.

**Headers**

| Name          | Value                 |
| ------------- | --------------------- |
| Content-Type  | `multipart/form-data` |
| Authorization | `Bearer <token>`      |

**Body**

The API accepts files and text as multipart form data for upload. Each form field should be a unique key and contain either a file or text content.

**Response**

200400Copy

```
{
  "q1": [
    {
      "id": 330783,
      "type": "text",
      "name": "sample.txt",
      "status": "in-progress",
      "errors": null
    },
    {
      "id": 330784,
      "type": "text",
      "name": "sample2.txt",
      "status": "in-progress",
      "errors": null
    },
    {
      "id": 330785,
      "type": "file",
      "name": "File.pdf",
      "status": "in-progress",
      "errors": null
    }
  ],
  "d2": [
    {
      "id": 330786,
      "type": "file",
      "name": "File2.pdf",
      "status": "in-progress",
      "errors": null
    }
  ],
  "knowledge_base_id": 876,
  "ok": true
}
```

### Get training status of a data source <a href="#get-training-status-of-a-data-source" id="get-training-status-of-a-data-source"></a>

`GET` `/api/v1/ai/status/sources`

Using this API, you can fetch the status of one or more data sources in a knowledge base to know it its training is - in progress / completed / failed.

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Body**

| Name         | Type         | Description                                                               |
| ------------ | ------------ | ------------------------------------------------------------------------- |
| `source_ids` | query params | Comma-separated list of data source IDs to be passed as **query params**. |

**Response**

200 400

```
{
    "sources": [
        {
            "id": 330778,
            "name": "sample.txt",
            "status": "in-progress",
            "knowledge_base_id": 876
        }
    ],
    "ok": true
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.talkie.se/integrations/public-apis.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
