Skip to main content
POST
/
reports
cURL
curl --request POST \
  --url https://api.base39.com.br/v2/reports \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "target": {
    "document": "12345678901"
  },
  "template": "tpl_abc123def456"
}
'
import requests

url = "https://api.base39.com.br/v2/reports"

payload = {
"target": { "document": "12345678901" },
"template": "tpl_abc123def456"
}
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({target: {document: '12345678901'}, template: 'tpl_abc123def456'})
};

fetch('https://api.base39.com.br/v2/reports', 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://api.base39.com.br/v2/reports",
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([
'target' => [
'document' => '12345678901'
],
'template' => 'tpl_abc123def456'
]),
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://api.base39.com.br/v2/reports"

payload := strings.NewReader("{\n \"target\": {\n \"document\": \"12345678901\"\n },\n \"template\": \"tpl_abc123def456\"\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://api.base39.com.br/v2/reports")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"target\": {\n \"document\": \"12345678901\"\n },\n \"template\": \"tpl_abc123def456\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.base39.com.br/v2/reports")

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 \"target\": {\n \"document\": \"12345678901\"\n },\n \"template\": \"tpl_abc123def456\"\n}"

response = http.request(request)
puts response.read_body
{
  "id": "rep_xyz789",
  "uploadUrl": "https://s3.amazonaws.com/bucket/file.pdf?signature=...",
  "status": "pending",
  "target": {
    "document": "12345678901",
    "name": "Empresa Exemplo LTDA",
    "alternativeName": "Exemplo Corp"
  },
  "template": "tpl_abc123def456",
  "sections": [
    {
      "id": "sec_abc123",
      "title": "Resumo Executivo",
      "status": "queued",
      "order": 1,
      "content": null
    },
    {
      "id": "sec_def456",
      "title": "Análise Detalhada",
      "status": "queued",
      "order": 2,
      "content": null
    }
  ],
  "createdAt": "2025-01-15T10:30:00Z",
  "updatedAt": "2025-01-15T10:30:00Z",
  "createdBy": "usr_123",
  "updatedBy": "usr_123"
}

Authorizations

Authorization
string
header
required

The access token received from the authorization server in the OAuth 2.0 flow.

Body

application/json

Dados do relatório a ser criado

target
object
required
template
string
required

ID do template no formato tpl_$nanoid

Pattern: ^tpl_[a-zA-Z0-9_-]+$
Example:

"tpl_abc123def456"

Response

200 - application/json

Relatório criado com sucesso

id
string

ID do relatório

uploadUrl
string

URL S3 assinada para upload

status
enum<string>

Status do relatório

Available options:
pending,
processing,
completed,
error
target
object
template
string
sections
object[]

Seções do relatório com conteúdo estruturado

Example:
[
{
"id": "sec_abc123",
"title": "Resumo Executivo",
"status": "done",
"order": 1,
"content": "Este relatório apresenta uma análise completa..."
},
{
"id": "sec_def456",
"title": "Análise Detalhada",
"status": "processing",
"order": 2,
"content": null
}
]
createdAt
string<date-time>
updatedAt
string<date-time>
createdBy
string
updatedBy
string