Tem eventos? (por entidade)
curl --request GET \
--url http://api.gu1.ai/events/user/entity/has-events \
--header 'Authorization: Bearer <token>'import requests
url = "http://api.gu1.ai/events/user/entity/has-events"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('http://api.gu1.ai/events/user/entity/has-events', 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/events/user/entity/has-events",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://api.gu1.ai/events/user/entity/has-events"
req, _ := http.NewRequest("GET", url, nil)
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.get("http://api.gu1.ai/events/user/entity/has-events")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("http://api.gu1.ai/events/user/entity/has-events")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"success": true,
"hasEvents": true,
"entityId": "<string>"
}Referência API
Tem eventos? (por entidade)
Verificação booleana rápida se uma entidade tem eventos de usuário vinculados — mesmo escopo de listar por entidade, sem retornar linhas ou totais.
GET
/
events
/
user
/
entity
/
has-events
Tem eventos? (por entidade)
curl --request GET \
--url http://api.gu1.ai/events/user/entity/has-events \
--header 'Authorization: Bearer <token>'import requests
url = "http://api.gu1.ai/events/user/entity/has-events"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('http://api.gu1.ai/events/user/entity/has-events', 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/events/user/entity/has-events",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://api.gu1.ai/events/user/entity/has-events"
req, _ := http.NewRequest("GET", url, nil)
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.get("http://api.gu1.ai/events/user/entity/has-events")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("http://api.gu1.ai/events/user/entity/has-events")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"success": true,
"hasEvents": true,
"entityId": "<string>"
}Visão geral
Use este endpoint quando você só precisa saber se uma entidade tem eventos de usuário (badges na UI, visibilidade de abas, pré-checagens), não a linha do tempo completa. Usa o mesmo escopo de vínculo que Listar por entidade:entity_id, entity_external_id ou tax_id na sua organização.
Prefira este endpoint em vez de listar com
limit=1 quando só precisar de sim/não — evita COUNT(*), ordenação e serializar payloads de eventos.Identificadores de entidade: você pode consultar por query param sem o UUID interno. Prioridade de busca:
entity_id → entity_external_id → tax_id (se enviar mais de um, vence o de maior prioridade). Para tax_id, a comparação no DB normaliza caracteres não alfanuméricos (ex.: 20-24245549-6 e 20242455496).A rota legada GET …/entity/{entityId}/has-events continua disponível quando você já tem o UUID.Desempenho
Projetado para baixa latência:| Aspecto | Comportamento |
|---|---|
| Consultas | Duas idas: lookup da entidade + uma sonda LIMIT 1 em user_events |
| Não faz | COUNT(*), ORDER BY, paginação nem colunas completas de evento/metadata |
| Índices | organization_id + entity_id usa idx_user_events_organization_entity_id; entity_external_id e tax_id têm índices dedicados nas ramas do OR |
Endpoint
GET https://api.gu1.ai/events/user/entity/has-events
Autenticação
Requer API key válida no header Authorization:Authorization: Bearer YOUR_API_KEY
Parâmetros de consulta
Pelo menos um é obrigatório. Se enviar vários, a prioridade éentity_id → entity_external_id → tax_id.
string
UUID da entidade (maior prioridade)Exemplo:
?entity_id=550e8400-e29b-41d4-a716-446655440000string
Identificador externo da entidade no seu sistemaExemplo:
?entity_external_id=user_12345string
Documento fiscal (CUIT/CUIL/CPF/CNPJ, etc.). Comparação exata e normalizada (somente alfanuméricos)Exemplo:
?tax_id=20242455496Resposta
boolean
Indica se a requisição foi bem-sucedida
boolean
true se existir pelo menos um evento vinculado (mesmo escopo de listar por entidade); caso contrário falsestring
UUID interno da entidade resolvida (útil quando consultou por
entity_external_id ou tax_id)Exemplo — com eventos
{
"success": true,
"hasEvents": true,
"entityId": "550e8400-e29b-41d4-a716-446655440000"
}
Exemplo — sem eventos
{
"success": true,
"hasEvents": false,
"entityId": "550e8400-e29b-41d4-a716-446655440000"
}
Erros
| Estado | Código | Quando |
|---|---|---|
| 400 | — | Falta qualquer identificador de entidade na query |
| 404 | ENTITY_NOT_FOUND | A entidade não existe na org ou está excluída (soft delete) |
| 401 | — | API key ausente ou inválida |
| 403 | — | Permissões insuficientes (events:read) |
Exemplos
# Por external ID (caso típico sem UUID interno)
curl "https://api.gu1.ai/events/user/entity/has-events?entity_external_id=user_12345" \
-H "Authorization: Bearer YOUR_API_KEY"
# Por tax ID
curl "https://api.gu1.ai/events/user/entity/has-events?tax_id=20242455496" \
-H "Authorization: Bearer YOUR_API_KEY"
# Legado: UUID no path
curl "https://api.gu1.ai/events/user/entity/550e8400-e29b-41d4-a716-446655440000/has-events" \
-H "Authorization: Bearer YOUR_API_KEY"
const res = await fetch(
'https://api.gu1.ai/events/user/entity/has-events?entity_external_id=user_12345',
{ headers: { Authorization: `Bearer ${API_KEY}` } }
);
const { hasEvents, entityId } = await res.json();
if (hasEvents) {
const timeline = await fetch(
`https://api.gu1.ai/events/user/entity/${entityId}?limit=50`,
{ headers: { Authorization: `Bearer ${API_KEY}` } }
);
}
Próximos passos
Listar por entidade
Linha do tempo completa quando
hasEvents é trueListar eventos
Consultar com filtros
Estatísticas
Contagens por tipo de evento
Overview
Overview de eventos de usuário
Was this page helpful?