Developers
ENPT

Investigate an answer

Find out why the avatar answered a message the way it did.

When an answer surprises you, investigation shows where it came from. Tolky looks at what the avatar received when it wrote that message (instructions, knowledge chunks, automations, conversation history) and points to the parts that shaped each sentence of the answer.

There are two calls:

  • Explain an answer: you ask a question in plain language ("why was the tone so formal?") and get a summary plus the answer snippets linked to the instructions behind them.
  • Message diagnostics: the technical record of the message (AI calls, external calls, tokens, timings), with an optional AI analysis.

Both need the ID of the avatar's message. Send a message returns it in createdMessageIds.

Explain an answer

ReferenceTechnical details

POST /api/externalAPIs/public/investigateV2

Authentication: host token.

ParameterTypeRequiredDescription
messageIdstring (UUID)YesMessage to investigate. message_id is also accepted.
generalInstructionsstringYesYour question about the answer. general_instructions is also accepted.
curl -X POST "https://api.tolky.to/api/externalAPIs/public/investigateV2" \
  -H "Authorization: Bearer $TOLKY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "messageId": "7d3f9a0b-...",
    "generalInstructions": "Why did the avatar answer so formally?"
  }'
{
  "code": 200,
  "message": "OK",
  "data": {
    "analysis": {
      "json": {
        "summary": "The formal tone comes from the avatar instructions, which ask for a professional style.",
        "snippets": [
          {
            "aiSnippet": "Good afternoon. How may I help you today?",
            "instructionSnippets": [
              {
                "snippet": "Always keep a professional and formal tone.",
                "explanation": "This instruction set the formal greeting.",
                "score": 8
              }
            ]
          }
        ]
      },
      "formato": "json"
    },
    "error": null,
    "tokens_used": { "prompt_tokens": 1500, "completion_tokens": 800, "total_tokens": 2300 }
  }
}
FieldDescription
analysis.json.summaryShort explanation of what shaped the answer.
analysis.json.snippets[].aiSnippetA part of the avatar's answer.
analysis.json.snippets[].instructionSnippets[]The instruction or context parts behind it: snippet, explanation, and score (0 to 10, how much it influenced the answer).
errorError text, or null.
tokens_usedTokens used by the analysis.
StatusWhen
400A required field is missing or the analysis failed.
404The message, or its processing record, was not found.
500Internal error.

Message diagnostics

ReferenceTechnical details

POST /api/externalAPIs/public/investigateMessage

Authentication: host token.

ParameterTypeRequiredDescription
messageIdstring (UUID)YesMessage to investigate.
useAIV2booleanNoDefault false. Adds an AI analysis in aiAnalysis.
generalInstructionsstringNoYour question for the AI analysis, used with useAIV2.
replaceDomainNamestringNoReplaces the word "tolky" in the response with this text.
curl -X POST "https://api.tolky.to/api/externalAPIs/public/investigateMessage" \
  -H "Authorization: Bearer $TOLKY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "messageId": "7d3f9a0b-..." }'
FieldDescription
host_slugAccount of the message.
messageThe message record.
iaRequestsAI calls made for this message: model, caller, tokens and cost of each.
externalApiRequestsCalls to external APIs (for example your systems, through agents): the request as curl and the response.
controlTotals and status: totalInputTokens, totalOutputTokens, responseStatus, timings and the processing log.
time_rankingSteps ranked by time spent.
tolky_recapRecap of the request, when available.
aiAnalysisOnly with useAIV2: analysis.json.analyzed_parts (each part of the answer, the inputs that contributed and the reasoning), error, tokens_used.

Any failure, including a missing messageId, returns 500 with the reason in message.

Previous

Conversation details

Next

Inspect conversation context