> ## 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.

# Criar Base de Conhecimento

> Cria uma nova base de conhecimento.

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

**Autenticação**\
Requer cabeçalho `authorization:  <seu_token>`.

### Request body

> O serviço espera **um wrapper** com `knowledgeBase` e `filename`.

```json theme={null}
{
  "knowledgeBase": {
    "name": "Políticas Internas",
    "description": "Documentos corporativos oficiais",
    "enabled": true,
    "sectors": ["hr", "legal"],
    "content": "https://storage.orkeia.ai/kb/policies.pdf",
    "type": "file",
    "multimodal": false,
    "tags": ["compliance", "contracts"]
  },
  "filename": "policies.pdf"
}
```

> **Notas**
>
> * Para `type: "file"`, envie `filename` correspondente ao conteúdo armazenado.
> * Para `type: "url"` ou `type: "text"`, `filename` pode ser ignorado/ficar vazio, mas o campo existe no payload por consistência do endpoint.
> * `content`:
>   * `file`: caminho/URL de armazenamento do arquivo (ex.: S3/Storage).
>   * `url`: link público/privado a ser referenciado.
>   * `text`: conteúdo textual direto.

### Exemplo (cURL)

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

\###Interface de referência:

```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[];
}
```

| Nome        | Tipo                      | Obrigatório | Descrição                                                                                    | Exemplo                                                                                  |
| ----------- | ------------------------- | ----------- | -------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| id          | string                    | Não         | Identificador único da base de conhecimento (retornado pelo backend).                        | "KB\_123456"                                                                             |
| name        | string                    | Sim         | Nome da base de conhecimento.                                                                | "Políticas Internas"                                                                     |
| description | string                    | Sim         | Descrição breve do conteúdo/uso.                                                             | "Documentos corporativos oficiais"                                                       |
| enabled     | boolean                   | Sim         | Indica se a base estará ativa no ambiente.                                                   | true                                                                                     |
| sectors     | string\[]                 | Sim         | Setores que podem consumir essa base (governança de acesso).                                 | \["hr", "legal"]                                                                         |
| content     | string                    | Sim         | Fonte do conteúdo: caminho/URL do arquivo, link externo, ou texto literal (conforme `type`). | "[https://storage.orkeia.ai/kb/policies.pdf](https://storage.orkeia.ai/kb/policies.pdf)" |
| type        | "file" \| "url" \| "text" | Sim         | Tipo do conteúdo.                                                                            | "file"                                                                                   |
| multimodal  | boolean                   | Sim         | Se a base contém modalidades além de texto (imagens/áudio/vídeo).                            | false                                                                                    |
| tags        | string\[]                 | Sim         | Metadados/etiquetas para busca e organização.                                                | \["compliance","contracts"]                                                              |

## Respostas

### 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
}
```
