Interrupt
Interrupt the avatar's current speech or action.
Endpoint
POST /v1/avatar-session/:sessionId/interrupt
Authentication
Header: Authorization: Bearer {token}
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
sessionId | string | Yes | Session ID from create-session |
Request Body
Empty body ({}).
Response
Success (200)
{
"success": true
}
Error Responses
400- Bad request401- Unauthorized404- Not found410- Gone (session ended)500- Server error
Examples
cURL
curl -X POST https://api.avatar.us.kaltura.ai/v1/avatar-session/session-123/interrupt \
-H "Authorization: Bearer $TOKEN"
JavaScript (fetch)
await fetch(`https://api.avatar.us.kaltura.ai/v1/avatar-session/${sessionId}/interrupt`, {
method: 'POST',
headers: {
Authorization: `Bearer ${token}`,
},
});
Usage Notes
What It Does
- Stops current speech immediately
- Clears the speech queue
- Avatar returns to idle state
Use Cases
- User interruption
- Emergency stop
- Conversation turn-taking
- Error recovery
Complete Example
// Start speaking
await fetch(`${baseUrl}/${sessionId}/say-text`, {
method: 'POST',
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
text: 'This is a very long message that might need to be interrupted...',
}),
});
// User clicks "Stop"
document.getElementById('stop-btn').addEventListener('click', async () => {
await fetch(`${baseUrl}/${sessionId}/interrupt`, {
method: 'POST',
headers: {
Authorization: `Bearer ${token}`,
},
});
console.log('Avatar interrupted');
});
Next Steps
- Say Text - Resume speaking
- End Session - End the session