Criar documento
curl --request POST \
--url https://suasofia.online/api/user/knowledgebases/{knowledgebaseId}/documents \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"description": "<string>",
"type": "<string>",
"url": "<string>",
"links": [
{
"link": "<string>"
}
],
"relative_links_limit": 123
}
'import requests
url = "https://suasofia.online/api/user/knowledgebases/{knowledgebaseId}/documents"
payload = {
"name": "<string>",
"description": "<string>",
"type": "<string>",
"url": "<string>",
"links": [{ "link": "<string>" }],
"relative_links_limit": 123
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
description: '<string>',
type: '<string>',
url: '<string>',
links: [{link: '<string>'}],
relative_links_limit: 123
})
};
fetch('https://suasofia.online/api/user/knowledgebases/{knowledgebaseId}/documents', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://suasofia.online/api/user/knowledgebases/{knowledgebaseId}/documents",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'description' => '<string>',
'type' => '<string>',
'url' => '<string>',
'links' => [
[
'link' => '<string>'
]
],
'relative_links_limit' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://suasofia.online/api/user/knowledgebases/{knowledgebaseId}/documents"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"type\": \"<string>\",\n \"url\": \"<string>\",\n \"links\": [\n {\n \"link\": \"<string>\"\n }\n ],\n \"relative_links_limit\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://suasofia.online/api/user/knowledgebases/{knowledgebaseId}/documents")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"type\": \"<string>\",\n \"url\": \"<string>\",\n \"links\": [\n {\n \"link\": \"<string>\"\n }\n ],\n \"relative_links_limit\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://suasofia.online/api/user/knowledgebases/{knowledgebaseId}/documents")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"type\": \"<string>\",\n \"url\": \"<string>\",\n \"links\": [\n {\n \"link\": \"<string>\"\n }\n ],\n \"relative_links_limit\": 123\n}"
response = http.request(request)
puts response.read_body{
"message": "Documento criado com sucesso. O processamento começará em breve.",
"data": {
"id": 1,
"name": "Website da Empresa",
"description": "Conteúdo do website principal",
"type": "website",
"type_label": "Website",
"status": "processing",
"status_label": "Processando",
"created_at": "2025-01-08T10:30:00.000000Z"
}
}
{
"message": "Documento criado com sucesso. O processamento começará em breve.",
"data": {
"id": 2,
"name": "Manual do Produto",
"description": "Guia do usuário para nosso produto",
"type": "pdf",
"type_label": "PDF",
"status": "processing",
"status_label": "Processando",
"created_at": "2025-01-08T10:35:00.000000Z"
}
}
{
"error": "Base de conhecimento não encontrada."
}
{
"message": "Um arquivo é obrigatório para este tipo de documento.",
"errors": {
"file": [
"Um arquivo é obrigatório para este tipo de documento."
]
}
}
{
"error": "Falha ao criar documento. Tente novamente."
}
Bases de Conhecimento
Criar documento
Adicionar um novo documento a uma base de conhecimento
POST
/
user
/
knowledgebases
/
{knowledgebaseId}
/
documents
Criar documento
curl --request POST \
--url https://suasofia.online/api/user/knowledgebases/{knowledgebaseId}/documents \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"description": "<string>",
"type": "<string>",
"url": "<string>",
"links": [
{
"link": "<string>"
}
],
"relative_links_limit": 123
}
'import requests
url = "https://suasofia.online/api/user/knowledgebases/{knowledgebaseId}/documents"
payload = {
"name": "<string>",
"description": "<string>",
"type": "<string>",
"url": "<string>",
"links": [{ "link": "<string>" }],
"relative_links_limit": 123
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
description: '<string>',
type: '<string>',
url: '<string>',
links: [{link: '<string>'}],
relative_links_limit: 123
})
};
fetch('https://suasofia.online/api/user/knowledgebases/{knowledgebaseId}/documents', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://suasofia.online/api/user/knowledgebases/{knowledgebaseId}/documents",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'description' => '<string>',
'type' => '<string>',
'url' => '<string>',
'links' => [
[
'link' => '<string>'
]
],
'relative_links_limit' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://suasofia.online/api/user/knowledgebases/{knowledgebaseId}/documents"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"type\": \"<string>\",\n \"url\": \"<string>\",\n \"links\": [\n {\n \"link\": \"<string>\"\n }\n ],\n \"relative_links_limit\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://suasofia.online/api/user/knowledgebases/{knowledgebaseId}/documents")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"type\": \"<string>\",\n \"url\": \"<string>\",\n \"links\": [\n {\n \"link\": \"<string>\"\n }\n ],\n \"relative_links_limit\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://suasofia.online/api/user/knowledgebases/{knowledgebaseId}/documents")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"type\": \"<string>\",\n \"url\": \"<string>\",\n \"links\": [\n {\n \"link\": \"<string>\"\n }\n ],\n \"relative_links_limit\": 123\n}"
response = http.request(request)
puts response.read_body{
"message": "Documento criado com sucesso. O processamento começará em breve.",
"data": {
"id": 1,
"name": "Website da Empresa",
"description": "Conteúdo do website principal",
"type": "website",
"type_label": "Website",
"status": "processing",
"status_label": "Processando",
"created_at": "2025-01-08T10:30:00.000000Z"
}
}
{
"message": "Documento criado com sucesso. O processamento começará em breve.",
"data": {
"id": 2,
"name": "Manual do Produto",
"description": "Guia do usuário para nosso produto",
"type": "pdf",
"type_label": "PDF",
"status": "processing",
"status_label": "Processando",
"created_at": "2025-01-08T10:35:00.000000Z"
}
}
{
"error": "Base de conhecimento não encontrada."
}
{
"message": "Um arquivo é obrigatório para este tipo de documento.",
"errors": {
"file": [
"Um arquivo é obrigatório para este tipo de documento."
]
}
}
{
"error": "Falha ao criar documento. Tente novamente."
}
Este endpoint cria um novo documento em uma base de conhecimento. Os documentos são processados de forma assíncrona - o endpoint retorna imediatamente enquanto o processamento continua em segundo plano.
Parâmetros de Caminho
integer
required
O identificador único da base de conhecimento
Corpo da Requisição
string
required
O nome do documento (máx. 255 caracteres)
string
Descrição opcional do documento (máx. 255 caracteres)
string
required
Tipo de documento:
website, pdf, txt ou docxDocumentos de Website
string
A URL principal para fazer scraping. Obrigatório se
links não for fornecido.array
Array de URLs específicas para fazer scraping. Obrigatório se
url não for fornecido.Show links properties
Show links properties
string
required
Uma URL válida para incluir no documento
integer
default:"10"
Número máximo de links relativos a seguir durante o scraping (1-50)
Documentos de Arquivo (PDF, TXT, DOCX)
file
required
O arquivo para upload (máx. 20MB). Use codificação
multipart/form-data.Resposta
string
Mensagem de sucesso
object
O objeto de documento criado
Show data properties
Show data properties
integer
O identificador único do documento
string
O nome do documento
string
Descrição do documento
string
Tipo de documento
string
Rótulo de tipo legível para humanos
string
Status de processamento (será
processing inicialmente)string
Rótulo de status legível para humanos
string
Timestamp ISO 8601 da criação
{
"message": "Documento criado com sucesso. O processamento começará em breve.",
"data": {
"id": 1,
"name": "Website da Empresa",
"description": "Conteúdo do website principal",
"type": "website",
"type_label": "Website",
"status": "processing",
"status_label": "Processando",
"created_at": "2025-01-08T10:30:00.000000Z"
}
}
{
"message": "Documento criado com sucesso. O processamento começará em breve.",
"data": {
"id": 2,
"name": "Manual do Produto",
"description": "Guia do usuário para nosso produto",
"type": "pdf",
"type_label": "PDF",
"status": "processing",
"status_label": "Processando",
"created_at": "2025-01-08T10:35:00.000000Z"
}
}
{
"error": "Base de conhecimento não encontrada."
}
{
"message": "Um arquivo é obrigatório para este tipo de documento.",
"errors": {
"file": [
"Um arquivo é obrigatório para este tipo de documento."
]
}
}
{
"error": "Falha ao criar documento. Tente novamente."
}
Tipos de Documento
| Tipo | Descrição | Entrada |
|---|---|---|
website | Faz scraping de páginas web e extrai conteúdo de texto | URL ou lista de URLs |
pdf | Extrai texto de arquivos PDF | Upload de arquivo PDF |
txt | Conteúdo de texto simples | Upload de arquivo TXT |
docx | Extrai texto de documentos Word | Upload de arquivo DOCX |
Exemplo: Criando um Documento de Website
curl -X POST https://suasofia.online/api/user/knowledgebases/1/documents \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Website da Empresa",
"description": "Conteúdo do website principal",
"type": "website",
"url": "https://example.com",
"relative_links_limit": 20
}'
Exemplo: Fazendo Upload de um Documento PDF
curl -X POST https://suasofia.online/api/user/knowledgebases/1/documents \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "name=Manual do Produto" \
-F "description=Guia do usuário para nosso produto" \
-F "type=pdf" \
-F "file=@/caminho/para/documento.pdf"
O processamento de documentos é assíncrono. Consulte o endpoint get document para verificar quando o processamento estiver completo.
⌘I

