> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orkeia.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Knowledge Base

> Creates a new knowledge base.

**Endpoint**\
`POST https://gateway.orkeia.ai/knowledge-bases`

**Authentication**\
Requires header `authorization:  <your_token>`.

### Request body

> The service expects **a wrapper** with `knowledgeBase` and `filename`.

```json theme={null}
{
  "knowledgeBase": {
    "name": "Internal Policies",
    "description": "Official corporate documents",
    "enabled": true,
    "sectors": ["hr", "legal"],
    "content": "https://storage.orkeia.ai/kb/policies.pdf",
    "type": "file",
    "multimodal": false,
    "tags": ["compliance", "contracts"]
  },
  "filename": "policies.pdf"
}
```

> **Notes**
>
> * For `type: "file"`, send the corresponding `filename` to the stored content.
> * For `type: "url"` or `type: "text"`, `filename` can be ignored/left empty, but the field exists in the payload for endpoint consistency.
> * `content`:
>   * `file`: storage path/URL of the file (e.g., S3/Storage).
>   * `url`: public/private link to be referenced.
>   * `text`: direct textual content.

### Example (cURL)

```bash theme={null}
curl -X POST "https://gateway.orkeia.ai/knowledge-bases"   -H "Authorization: Bearer <your_token>"   -H "Content-Type: application/json"   -d '{
    "knowledgeBase": {
      "name": "Internal Policies",
      "description": "Official corporate documents",
      "enabled": true,
      "sectors": ["hr", "legal"],
      "content": "https://storage.orkeia.ai/kb/policies.pdf",
      "type": "file",
      "multimodal": false,
      "tags": ["compliance", "contracts"]
    },
    "filename": "policies.pdf",
  }'
```

### Reference Interface:

```ts theme={null}
export interface KnowledgeBase {
  id?: string;
  name: string;
  description: string;
  enabled: boolean;
  sectors: string[];
  content: string;
  type: 'file' | 'url' | 'text';
  multimodal: boolean;
  tags: string[];
}
```

| Name        | Type                      | Required | Description                                                                                 | Example                                                                                  |
| ----------- | ------------------------- | -------- | ------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| id          | string                    | No       | Unique identifier of the knowledge base (returned by the backend).                          | "KB\_123456"                                                                             |
| name        | string                    | Yes      | Name of the knowledge base.                                                                 | "Internal Policies"                                                                      |
| description | string                    | Yes      | Brief description of the content/usage.                                                     | "Official corporate documents"                                                           |
| enabled     | boolean                   | Yes      | Indicates whether the base will be active in the environment.                               | true                                                                                     |
| sectors     | string\[]                 | Yes      | Sectors that can consume this base (access governance).                                     | \["hr", "legal"]                                                                         |
| content     | string                    | Yes      | Source of the content: file path/URL, external link, or literal text (according to `type`). | "[https://storage.orkeia.ai/kb/policies.pdf](https://storage.orkeia.ai/kb/policies.pdf)" |
| type        | "file" \| "url" \| "text" | Yes      | Type of the content.                                                                        | "file"                                                                                   |
| multimodal  | boolean                   | Yes      | Whether the base contains modalities beyond text (images/audio/video).                      | false                                                                                    |
| tags        | string\[]                 | Yes      | Metadata/tags for search and organization.                                                  | \["compliance","contracts"]                                                              |

## Responses

### Response - Success

```json response theme={null}
{
  "status": "OK",
  "data": { "id": "KB_123456" }
}
```

### 500 — Bad Request

```json theme={null}
{
  "status": "ERROR",
  "code": "server/error",
  "data": null
}
```

### 400 — Client Error

```json theme={null}
{
  "status": "ERROR",
  "code": "client/error",
  "data": null
}
```
