Agent API/Conversations
End Conversation
Close a live conversation, save its transcript, and remove the session.
Send X-Ended-Reason: inactivity_timeout when the chat has had no message for 5 minutes, or omit the header to record user_close. The response includes csatRequested. An inactivity close does not ask for a rating.
DELETE
https://agent.askhandle.com/api/v1/public/conversations/{conversationId}Requires X-API-Key — Your public API key (starts with pk_live_)
Request
Headers
X-API-Keystringrequired
Your public API key
X-Ended-Reasonstring
Why the chat ended. inactivity_timeout after 5 minutes with no message. Omit to record user_close.
Query Parameters
conversationIdstringrequired
The conversation ID returned from Start Conversation
Response
Success 200
JSON
{
"success": true,
"message": "Conversation closed",
"csatRequested": false
}Errors
401
API key is missing or invalid
Error
{
"error": "Missing API key. Include X-API-Key header."
}Code examples
const conversationId = 'conv_abc123def456';
const response = await fetch(
`https://agent.askhandle.com/api/v1/public/conversations/${conversationId}`,
{
method: 'DELETE',
headers: {
'X-API-Key': 'pk_live_your_api_key_here',
'X-Ended-Reason': 'inactivity_timeout'
}
}
);
const data = await response.json();
console.log(data.message, data.csatRequested);