Agent API/Conversations
Get Conversation History
Retrieve the full conversation history including all messages exchanged.
ended: true means the live session is gone. endedReason says why, when it is still known: inactivity_timeout (5 minutes with no message), user_close, exit_node, or customer_inactive. handoffActive: true means a person is handling the chat. csatRequested: true means the customer can be asked to rate a handoff that just ended. An inactivity close does not request a rating.
Book appointments: Assistant messages that confirmed an appointment also include bookingCard (same shape as Send Message: when, confirmation code, and calendarUrl for an .ics file). If you are not using scheduling, this field is never returned.
Product cards: Assistant messages that showed a product also include productCards (same shape as Send Message).
https://agent.askhandle.com/api/v1/public/conversations/{conversationId}Requires X-API-Key — Your secret agent API key (starts with ai_agent_)
Best practice
Timeouts. Use this to pick up a reply when Send Message timed out.
- Poll every 2 seconds, for up to a minute.
- Do not resend the user message while you are polling.
- An unchanged list means the turn is still running, or it failed.
Request
Headers
X-API-KeyYour secret agent API key
Query Parameters
conversationIdThe conversation ID
Response
Success 200
{
"conversationId": "conv_abc123def456",
"handoffActive": false,
"ended": false,
"csatRequested": false,
"messages": [
{
"role": "assistant",
"content": "👋 Welcome! How can I help you today?"
},
{
"role": "user",
"content": "I need help with my order"
},
{
"role": "assistant",
"content": "I'd be happy to help! What's your order number?"
}
]
}Errors
API key is missing, invalid, or the agent is not published. A finished session returns 200 with ended: true.
{
"error": "Invalid API key or workflow not published."
}Code examples
const conversationId = 'conv_abc123def456';
const response = await fetch(
`https://agent.askhandle.com/api/v1/public/conversations/${conversationId}`,
{
headers: {
'X-API-Key': 'YOUR_API_KEY'
}
}
);
const data = await response.json();
console.log('Conversation history:', data.messages);