Endpoint de leitura para polling do estado de um intent. Use após POST /runWithAgents com async: true, quando a resposta imediata traz apenas { intentId, status: "planning" } e a execução continua em background.

Alternativas em tempo real: WebSocket /sequential-thinking ou GET /getKeeperSnapshot para histórico de eventos.

Endpoint

GET /getIntentStatus

Autenticação

Exige token Bearer. O KrakenD injeta X-Host-Id e X-Domain-Id quando aplicável. O hostId gravado no context do intent precisa coincidir com o host resolvido a partir do token — caso contrário, 403.

Authorization: Bearer {TOKEN}

Em ambiente local, quando os headers do gateway não existem, passe hostId, hostSlug ou domainId na query string (mesma resolução que runWithAgents).

Parâmetros (query string)

intentId
string (UUID)
required

ID da execução retornado por runWithAgents (síncrono ou assíncrono).

hostId
string (UUID)

UUID do host. Obrigatório apenas em ambiente local quando o token/gateway não resolve identidade.

hostSlug
string

Slug do host (alternativa ao hostId em ambiente local).

Exemplo

curl -G "{{BASE_URL}}/getIntentStatus" \
  -H "Authorization: Bearer {{TOKEN}}" \
  --data-urlencode "intentId=uuid-da-execucao"

Ambiente local

curl -G "http://localhost:8080/api/externalAPIs/public/sequentialThinking/getIntentStatus" \
  --data-urlencode "intentId=uuid-da-execucao" \
  --data-urlencode "hostId=uuid-do-host-aqui"

Resposta

{
  "data": {
    "intentId": "uuid-da-execucao",
    "status": "executing",
    "currentStepIndex": 2,
    "totalSteps": 5,
    "result": {
      "success": false,
      "intentId": "uuid-da-execucao",
      "steps": []
    }
  }
}

Quando a execução falhou:

{
  "data": {
    "intentId": "uuid-da-execucao",
    "status": "failed",
    "currentStepIndex": 1,
    "totalSteps": 3,
    "error": "Mensagem de erro persistida"
  }
}

Campos da resposta

data
object

Fluxo assíncrono recomendado

  1. POST /runWithAgents com "async": true → resposta HTTP 200 com { "intentId": "…", "status": "planning" } (não é 202).
  2. Poll GET /getIntentStatus?intentId=… até status ser terminal (completed, failed, cancelled, awaiting_input, etc.).
  3. Quando terminal, leia result (se presente) para obter finalAnswer, steps e metrics.
  4. Opcional: escute eventos em tempo real via socket /sequential-thinking ou recupere histórico com getKeeperSnapshot.
async function runAsyncAndWait(token, instructions) {
  const start = await fetch(`${BASE_URL}/runWithAgents`, {
    method: 'POST',
    headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
    body: JSON.stringify({ instructions, async: true }),
  }).then(r => r.json());

  const intentId = start.data.intentId;

  for (;;) {
    const snap = await fetch(
      `${BASE_URL}/getIntentStatus?intentId=${encodeURIComponent(intentId)}`,
      { headers: { Authorization: `Bearer ${token}` } },
    ).then(r => r.json());

    const { status, result } = snap.data;
    if (['completed', 'failed', 'cancelled', 'awaiting_input'].includes(status)) {
      return { status, result };
    }
    await new Promise(r => setTimeout(r, 1500));
  }
}

Erros

CódigoDescrição
400intentId ausente — O parâmetro “intentId” é obrigatório.
401Token inválido ou host não resolvido
403Intent pertence a outro host
404Intent não encontrado
500Erro interno do servidor