Alterar ID externo
curl --request POST \
--url http://api.gu1.ai/entities/change-external-id \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"entityId": {},
"externalId": "<string>",
"taxId": "<string>",
"newExternalId": "<string>",
"reason": "<string>"
}
'import requests
url = "http://api.gu1.ai/entities/change-external-id"
payload = {
"entityId": {},
"externalId": "<string>",
"taxId": "<string>",
"newExternalId": "<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>',
newExternalId: '<string>',
reason: '<string>'
})
};
fetch('http://api.gu1.ai/entities/change-external-id', 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-external-id",
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>',
'newExternalId' => '<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-external-id"
payload := strings.NewReader("{\n \"entityId\": {},\n \"externalId\": \"<string>\",\n \"taxId\": \"<string>\",\n \"newExternalId\": \"<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-external-id")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"entityId\": {},\n \"externalId\": \"<string>\",\n \"taxId\": \"<string>\",\n \"newExternalId\": \"<string>\",\n \"reason\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://api.gu1.ai/entities/change-external-id")
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 \"newExternalId\": \"<string>\",\n \"reason\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyReferência API
Alterar ID externo de uma empresa
Define um novo identificador externo para uma empresa no gu1 com motivo obrigatório de auditoria; atualiza referências desnormalizadas em transações.
POST
/
entities
/
change-external-id
Alterar ID externo
curl --request POST \
--url http://api.gu1.ai/entities/change-external-id \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"entityId": {},
"externalId": "<string>",
"taxId": "<string>",
"newExternalId": "<string>",
"reason": "<string>"
}
'import requests
url = "http://api.gu1.ai/entities/change-external-id"
payload = {
"entityId": {},
"externalId": "<string>",
"taxId": "<string>",
"newExternalId": "<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>',
newExternalId: '<string>',
reason: '<string>'
})
};
fetch('http://api.gu1.ai/entities/change-external-id', 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-external-id",
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>',
'newExternalId' => '<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-external-id"
payload := strings.NewReader("{\n \"entityId\": {},\n \"externalId\": \"<string>\",\n \"taxId\": \"<string>\",\n \"newExternalId\": \"<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-external-id")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"entityId\": {},\n \"externalId\": \"<string>\",\n \"taxId\": \"<string>\",\n \"newExternalId\": \"<string>\",\n \"reason\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://api.gu1.ai/entities/change-external-id")
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 \"newExternalId\": \"<string>\",\n \"reason\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyVisão geral
Use este endpoint para alterar o external ID de uma entidade. Não é possível fazer isso viaPATCH /entities/:id, PATCH /entities/by-external-id/:externalId ou PATCH /entities/by-tax-id/:taxId — essas rotas ignoram externalId no corpo.
- Valida unicidade do novo ID na organização.
- Atualiza a entidade.
- Se o ID anterior não era vazio e mudou, reescreve referências em transações e user events na mesma transação do banco.
externalIdChangeReason, source: change_external_id_endpoint).
Endpoint
POST https://api.gu1.ai/entities/change-external-id
Corpo da requisição
Envie exatamente um campo de localização, mais o novo valor e o motivo.string (uuid)
UUID interno da entidade na gu1.
string
Apenas busca: o ID externo atual da entidade (não o novo).
string
Apenas busca: tax ID de uma entidade que já tenha tax ID salvo e não vazio. Várias correspondências →
409 AMBIGUOUS_TAX_ID_LOOKUP; use entityId ou externalId.string
required
Novo identificador externo (trim no servidor). Não pode estar em uso por outra entidade.
string
required
Motivo de auditoria: mínimo 5 caracteres, máximo 4000.
Resposta
success: booleanchanged:falsese o novo valor for igual ao atualentity: objeto da entidade após a operação
Exemplo
{
"entityId": "550e8400-e29b-41d4-a716-446655440000",
"newExternalId": "crm_cliente_8842",
"reason": "Migração CRM — alinhar com ID do sistema de origem"
}
Was this page helpful?