Alterar o tipo de uma pessoa
curl --request POST \
--url http://api.gu1.ai/entities/change-type \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"entityId": {},
"externalId": "<string>",
"taxId": "<string>",
"type": "<string>",
"reason": "<string>"
}
'import requests
url = "http://api.gu1.ai/entities/change-type"
payload = {
"entityId": {},
"externalId": "<string>",
"taxId": "<string>",
"type": "<string>",
"reason": "<string>"
}
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({
entityId: {},
externalId: '<string>',
taxId: '<string>',
type: '<string>',
reason: '<string>'
})
};
fetch('http://api.gu1.ai/entities/change-type', 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 => "http://api.gu1.ai/entities/change-type",
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([
'entityId' => [
],
'externalId' => '<string>',
'taxId' => '<string>',
'type' => '<string>',
'reason' => '<string>'
]),
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 := "http://api.gu1.ai/entities/change-type"
payload := strings.NewReader("{\n \"entityId\": {},\n \"externalId\": \"<string>\",\n \"taxId\": \"<string>\",\n \"type\": \"<string>\",\n \"reason\": \"<string>\"\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("http://api.gu1.ai/entities/change-type")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"entityId\": {},\n \"externalId\": \"<string>\",\n \"taxId\": \"<string>\",\n \"type\": \"<string>\",\n \"reason\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://api.gu1.ai/entities/change-type")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"entityId\": {},\n \"externalId\": \"<string>\",\n \"taxId\": \"<string>\",\n \"type\": \"<string>\",\n \"reason\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"changed": true,
"entity": {},
"riskMatrixExecuted": true
}Referência API
Alterar o tipo de uma pessoa
Reclassificar uma pessoa como empresa, ou uma empresa como pessoa. O motivo é opcional e, se enviado, fica na auditoria. A matriz de risco não é reexecutada.
POST
/
entities
/
change-type
Alterar o tipo de uma pessoa
curl --request POST \
--url http://api.gu1.ai/entities/change-type \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"entityId": {},
"externalId": "<string>",
"taxId": "<string>",
"type": "<string>",
"reason": "<string>"
}
'import requests
url = "http://api.gu1.ai/entities/change-type"
payload = {
"entityId": {},
"externalId": "<string>",
"taxId": "<string>",
"type": "<string>",
"reason": "<string>"
}
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({
entityId: {},
externalId: '<string>',
taxId: '<string>',
type: '<string>',
reason: '<string>'
})
};
fetch('http://api.gu1.ai/entities/change-type', 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 => "http://api.gu1.ai/entities/change-type",
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([
'entityId' => [
],
'externalId' => '<string>',
'taxId' => '<string>',
'type' => '<string>',
'reason' => '<string>'
]),
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 := "http://api.gu1.ai/entities/change-type"
payload := strings.NewReader("{\n \"entityId\": {},\n \"externalId\": \"<string>\",\n \"taxId\": \"<string>\",\n \"type\": \"<string>\",\n \"reason\": \"<string>\"\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("http://api.gu1.ai/entities/change-type")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"entityId\": {},\n \"externalId\": \"<string>\",\n \"taxId\": \"<string>\",\n \"type\": \"<string>\",\n \"reason\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://api.gu1.ai/entities/change-type")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"entityId\": {},\n \"externalId\": \"<string>\",\n \"taxId\": \"<string>\",\n \"type\": \"<string>\",\n \"reason\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"changed": true,
"entity": {},
"riskMatrixExecuted": true
}Visão geral
Use este endpoint para mudar uma entidade entre person e company.PATCH /entities/:id, PATCH /entities/by-external-id/:externalId e PATCH /entities/by-tax-id/:taxId ignoram type no corpo.
A operação:
- Atualiza só
type. - Mantém o nome, o documento fiscal, os sócios, os enrichments e o restante da ficha.
- Não reexecuta a matriz de risco. A próxima avaliação usa o tipo novo. Se o tipo mudou, a resposta inclui
riskMatrixExecuted: false.
changed: false). Tipos diferentes de person e company não podem ser alterados (409 ENTITY_TYPE_NOT_CHANGEABLE).
reason é opcional. Se for enviado, a auditoria unificada guarda o texto como typeChangeReason, junto com previousType, newType e source: change_entity_type_endpoint. O webhook entity.updated é disparado com changes.type.
Endpoint
POST https://api.gu1.ai/entities/change-type
Autenticação
Authorization: Bearer YOUR_API_KEY
Corpo
Envie exatamente um campo de busca e o tipo de destino.reason é opcional.
Somente busca: documento fiscal de uma entidade que já tem um valor não vazio. A comparação ignora a pontuação. Se mais de uma entidade corresponder, a API responde
409 AMBIGUOUS_TAX_ID_LOOKUP.Motivo de auditoria opcional, no máximo 4000 caracteres (depois do trim). Se não for enviado, não é guardado.
Resposta
Erros
| HTTP | Código | Significado |
|---|---|---|
| 400 | VALIDATION_ERROR, INVALID_LOOKUP | Nenhum ou mais de um campo de busca, ou type inválido |
| 403 | ENTITY_ARCHIVED | A entidade está arquivada |
| 404 | NOT_FOUND | Nenhuma entidade corresponde à busca |
| 409 | AMBIGUOUS_TAX_ID_LOOKUP | Várias entidades compartilham o documento fiscal normalizado |
| 409 | ENTITY_TYPE_NOT_CHANGEABLE | O tipo atual não é person nem company |
Exemplo
curl -X POST "https://api.gu1.ai/entities/change-type" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"entityId": "550e8400-e29b-41d4-a716-446655440000",
"type": "company",
"reason": "O onboarding carregou um comércio individual como pessoa"
}'
{
"externalId": "crm_customer_8842",
"type": "person",
"reason": "O registro mostra uma pessoa física, não uma empresa"
}
{
"taxId": "20-12345678-9",
"type": "person",
"reason": "O documento é de uma pessoa; a ficha foi criada como empresa"
}
Was this page helpful?