Skip to main content
POST
/
api
/
openapi
/
v1
/
documents
Fazer Upload de Documento
curl --request POST \
  --url http://localhost:3000/api/openapi/v1/documents \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: multipart/form-data' \
  --form file='@example-file' \
  --form team_id=3c90c3cc-0d44-4b50-8888-8dd25736052a \
  --form chars=5000
import requests

url = "http://localhost:3000/api/openapi/v1/documents"

files = { "file": ("example-file", open("example-file", "rb")) }
payload = {
"team_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"chars": "5000"
}
headers = {"Authorization": "Bearer <token>"}

response = requests.post(url, data=payload, files=files, headers=headers)

print(response.text)
const form = new FormData();
form.append('file', '<string>');
form.append('team_id', '3c90c3cc-0d44-4b50-8888-8dd25736052a');
form.append('chars', '5000');

const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

options.body = form;

fetch('http://localhost:3000/api/openapi/v1/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_PORT => "3000",
CURLOPT_URL => "http://localhost:3000/api/openapi/v1/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 => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"team_id\"\r\n\r\n3c90c3cc-0d44-4b50-8888-8dd25736052a\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chars\"\r\n\r\n5000\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data"
],
]);

$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 := "http://localhost:3000/api/openapi/v1/documents"

payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"team_id\"\r\n\r\n3c90c3cc-0d44-4b50-8888-8dd25736052a\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chars\"\r\n\r\n5000\r\n-----011000010111000001101001--")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("http://localhost:3000/api/openapi/v1/documents")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"team_id\"\r\n\r\n3c90c3cc-0d44-4b50-8888-8dd25736052a\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chars\"\r\n\r\n5000\r\n-----011000010111000001101001--")
.asString();
require 'uri'
require 'net/http'

url = URI("http://localhost:3000/api/openapi/v1/documents")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"team_id\"\r\n\r\n3c90c3cc-0d44-4b50-8888-8dd25736052a\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"chars\"\r\n\r\n5000\r\n-----011000010111000001101001--"

response = http.request(request)
puts response.read_body
{
  "success": true,
  "data": {
    "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "team_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "name": "contrato.pdf",
    "type": "pdf",
    "size": 1024000,
    "openai_id": "file-abc123",
    "file_url": "550e8400-e29b-41d4-a716-446655440000/file-abc123.pdf",
    "chars": 5000,
    "created_at": "2023-11-07T05:31:56Z",
    "updated_at": "2023-11-07T05:31:56Z"
  }
}
{
"success": false,
"error": "Corpo da requisição inválido",
"code": "BAD_REQUEST"
}

Authorizations

Authorization
string
header
required

Token JWT obtido do endpoint /api/openapi/auth/token

Body

multipart/form-data
file
file
required

Arquivo para upload (pdf, txt, docx, doc)

team_id
string<uuid>
required

ID da Equipe

chars
integer

Contagem de caracteres (opcional, padrão 0)

Example:

5000

Response

Documento enviado com sucesso

success
boolean
Example:

true

data
object