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.
| Parameter | Type | Required | Description |
|---|---|---|---|
messageId | string (UUID) | Yes | Message to investigate. message_id is also accepted. |
generalInstructions | string | Yes | Your 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 }
}
}| Field | Description |
|---|---|
analysis.json.summary | Short explanation of what shaped the answer. |
analysis.json.snippets[].aiSnippet | A 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). |
error | Error text, or null. |
tokens_used | Tokens used by the analysis. |
| Status | When |
|---|---|
400 | A required field is missing or the analysis failed. |
404 | The message, or its processing record, was not found. |
500 | Internal error. |
Message diagnostics
ReferenceTechnical details
POST /api/externalAPIs/public/investigateMessage
Authentication: host token.
| Parameter | Type | Required | Description |
|---|---|---|---|
messageId | string (UUID) | Yes | Message to investigate. |
useAIV2 | boolean | No | Default false. Adds an AI analysis in aiAnalysis. |
generalInstructions | string | No | Your question for the AI analysis, used with useAIV2. |
replaceDomainName | string | No | Replaces 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-..." }'| Field | Description |
|---|---|
host_slug | Account of the message. |
message | The message record. |
iaRequests | AI calls made for this message: model, caller, tokens and cost of each. |
externalApiRequests | Calls to external APIs (for example your systems, through agents): the request as curl and the response. |
control | Totals and status: totalInputTokens, totalOutputTokens, responseStatus, timings and the processing log. |
time_ranking | Steps ranked by time spent. |
tolky_recap | Recap of the request, when available. |
aiAnalysis | Only 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.