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 principal do site",
"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 é necessário para este tipo de documento.",
"errors": {
"file": [
"Um arquivo é necessário para este tipo de documento."
]
}
}
{
"error": "Falha ao criar documento. Por favor, tente novamente."
}
Knowledgebases
Criar documento
Adicione 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 principal do site",
"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 é necessário para este tipo de documento.",
"errors": {
"file": [
"Um arquivo é necessário para este tipo de documento."
]
}
}
{
"error": "Falha ao criar documento. Por favor, 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 a ser extraída. Necessária se
links não for fornecido.array
Array de URLs específicas a serem extraídas. Necessária se
url não for fornecido.Show propriedades de links
Show propriedades de links
string
required
Uma URL válida a ser incluída no documento
integer
default:"10"
Número máximo de links relativos a seguir ao extrair (1-50)
Documentos de Arquivo (PDF, TXT, DOCX)
file
required
O arquivo a ser enviado (máx. 20MB). Use codificação
multipart/form-data.Resposta
string
Mensagem de sucesso
object
O objeto do documento criado
Show propriedades de dados
Show propriedades de dados
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 por humanos
string
Status do processamento (será
processing inicialmente)string
Rótulo de status legível por humanos
string
Timestamp ISO 8601 de criação
{
"message": "Documento criado com sucesso. O processamento começará em breve.",
"data": {
"id": 1,
"name": "Website da Empresa",
"description": "Conteúdo principal do site",
"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 é necessário para este tipo de documento.",
"errors": {
"file": [
"Um arquivo é necessário para este tipo de documento."
]
}
}
{
"error": "Falha ao criar documento. Por favor, tente novamente."
}
Tipos de Documento
| Tipo | Descrição | Entrada |
|---|---|---|
website | Extrai páginas da web e 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 do 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 principal do site",
"type": "website",
"url": "https://example.com",
"relative_links_limit": 20
}'
Exemplo: Enviando 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 do documento é assíncrono. Consulte o endpoint obter documento para verificar quando o processamento estiver completo.

