Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.tavus.io/llms.txt

Use this file to discover all available pages before exploring further.

Tavus sends JSON payloads to the callback_url you configure on each resource. On your server, read the body and branch on event_type (and message_type where noted). This page covers five callback areas: conversation events (below), guardrails, objectives, replica training, and video generation—payload shapes differ, and most event-specific fields live under properties.

Conversation Callbacks

If a callback_url is provided when you call POST https://tavusapi.com/v2/conversations (Create Conversation), callbacks will provide insight into the conversation’s state. These can be system-related (e.g. replica joins and room shutdowns) or application-related (e.g. final transcription parsing and recording-ready webhooks). Additional webhooks coming soon.

Structure

All Conversation callbacks share the following basic structure. Differences will occur in the properties object.
{
    "properties": {
    "replica_id": "<replica_id>"
    },
    "conversation_id": "<conversation_id>",
    "webhook_url": "<webhook_url>",
    "event_type": "<event_type>",
    "message_type": "<system/application>",
    "timestamp": "<timestamp>"
}

Types

Our callbacks are split into two main categories:

System Callbacks

These callbacks are to provide insight into system-related events in a conversation. They are:
  • system.replica_joined: This is fired when the replica becomes ready for a conversation.
  • system.shutdown: This is fired when the room shuts down, for any of the following reasons:
    • max_call_duration reached
    • participant_left_timeout reached
    • participant_absent_timeout reached
    • bot_could_not_join_meeting_it_was_probably_ended
    • daily_room_has_been_deleted
    • exception_encountered_during_conversation_startup
    • end_conversation_endpoint_hit
    • internal error occurred at step x
Examples:
{
  "properties": {
    "replica_id": "<replica_id>"
  },
  "conversation_id": "<conversation_id>",
  "webhook_url": "<webhook_url>",
  "event_type": "system.replica_joined",
  "message_type": "system",
  "timestamp": "2025-07-11T06:45:47.472000Z"
}

Application Callbacks

These callbacks are to inform developers about logical events that take place. They are:
  • application.transcription_ready: This is fired after ending a conversation, where the chat history is saved and returned.
  • application.recording_ready: This is fired once your recording is durably written to your storage destination. Includes storage_provider (s3 / gcs / azure_blob) and a fully-qualified storage_uri so the same handler works across providers. See Recording Storage to set up GCS, Azure, or S3-in-any-region destinations.
  • application.recording_copy_failed: This is fired only on the worker-copy path (GCS, Azure, or S3 in regions Daily doesn’t support natively) when Tavus is unable to deliver the recording into your bucket after retries. Daily’s default storage retains the recording for ~30 days as a manual recovery window. Common causes: customer IAM trust policy mismatch, federated credential drift, bucket region typo. Use this as the canary for misconfiguration in your end.
  • application.perception_analysis: This is fired after ending a conversation, when the replica has finished summarizing the visual artifacts that were detected throughout the call. This is a feature that is only available when the persona has raven-1 specified in the Perception Layer.
Examples:
{
  "properties": {
    "replica_id": "<replica_id>",
    "transcript": [
      {
        "role": "system",
        "content": "You are a helpful assistant."
      },
      {
        "role": "user",
        "content": "Hi."
      },
      {
        "role": "assistant",
        "content": "Hello! How can I help?"
      },
      {
        "role": "user",
        "content": "Quick question about my order."
      },
      {
        "role": "assistant",
        "content": "Sure—what's the order number?"
      }
    ]
  },
  "conversation_id": "<conversation_id>",
  "webhook_url": "<webhook_url>",
  "event_type": "application.transcription_ready",
  "message_type": "application",
  "timestamp": "2025-07-11T06:48:37.566057Z"
}

Guardrail Callbacks

If a callback_url is provided on a guardrail, a callback is sent when that guardrail is triggered during a conversation.
{
  "conversation_id": "<conversation_id>",
  "properties": {
    "guardrail": "<guardrails_name>"
  }
}

Objective Callbacks

If a callback_url is provided on an objective, a callback is sent when that objective is completed during a conversation.
{
  "conversation_id": "<conversation_id>",
  "objective_name": "<objective_name>",
  "output_variables": {
    "<variable_name>": "<value>"
  }
}

Replica Training Callbacks

If a callback_url is provided in the POST /replicas call, you will receive a callback on replica training completion or on replica training error.
{
    "replica_id": "rxxxxxxxxx",
    "status": "ready"
}

Video Generation Callbacks

If a callback_url is provided in the POST /videos call, you will receive callbacks on video generation completed and on video error.
{
    "created_at": "2024-08-28 15:27:40.824457",
    "data": {
    "script": "Hello this is a test to give examples of callbacks"
    },
    "download_url": "https://stream.mux.com/H5H029h02tY7XDpNj9JFDbLleTyUpsJr5npddO8gRsKqY/high.mp4?download=1e30440cf9",
    "generation_progress": "100/100",
    "hosted_url": "https://videos.tavus.io/video/1e30440cf9",
    "replica_id": "r90bbd427f71",
    "status": "ready",
    "status_details": "Your request has processed successfully!",
    "stream_url": "https://stream.mux.com/H5H029h02tY7XDpNj9JFDbLleTyUpsJr5npddO8gRsKqY.m3u8",
    "updated_at": "2024-08-28 15:29:19.802670",
    "video_id": "1e30440cf9",
    "video_name": "replica_id: r90bbd427f71 - August 28, 2024 - video: 1e30440cf9"
}

Sample Webhook Setup

Create a sample webhook endpoint using Python Flask, and expose it publicly with ngrok.

Prerequisites

1

Step 1: Install Python Dependencies

Install the Python dependencies needed to create the server.
pip install flask requests
2

Step 2: Make a Webhook Server

Set up a webhook server and save it as server.py.
import requests
from flask import Flask, request, jsonify

app = Flask(__name__)

# Store transcripts (in production, use a proper database)
transcripts = {}

@app.route('/webhook', methods=['POST'])
def handle_tavus_callback():
    data = request.json
    event_type = data.get('event_type')
    conversation_id = data.get('conversation_id')
    
    print(f"Received callback: {event_type} for conversation {conversation_id}")
    
    if event_type == 'system.replica_joined':
        print("✅ Replica has joined the conversation")
        
    elif event_type == 'system.shutdown':
        shutdown_reason = data['properties'].get('shutdown_reason')
        print(f"🔚 Conversation ended: {shutdown_reason}")
    
    elif event_type == 'application.recording_ready':
        s3_key = data['properties'].get('s3_key')
        print(f"s3_key : {s3_key}")

    elif event_type == 'application.perception_analysis':
        analysis = data['properties'].get('analysis')
        print(f"analysis : {analysis}")
        
    elif event_type == 'application.transcription_ready':
        print("📝 Transcript is ready!")
        transcript = data['properties']['transcript']
        transcripts[conversation_id] = transcript
        
        # Process the transcript
        analyze_conversation(conversation_id, transcript)
        
    return jsonify({"status": "success"}), 200

def analyze_conversation(conversation_id, transcript):
    """Analyze the conversation transcript"""
    user_turns = len([msg for msg in transcript if msg['role'] == 'user'])
    assistant_turns = len([msg for msg in transcript if msg['role'] == 'assistant'])
    
    print(f"Conversation {conversation_id} analysis:")
    print(f"- User turns: {user_turns}")
    print(f"- Assistant turns: {assistant_turns}")
    print(f"- Total messages: {len(transcript)}")

    print("Conversation : ")

    for msg in transcript:
        print(f"{msg['role']} : {msg['content']}")

if __name__ == '__main__':
    app.run(port=5000, debug=True)
The server will receive and process webhook callbacks from Tavus, handle different event types, store transcripts in memory, and analyze conversation data for each session.
3

Step 3: Run the Server

Run the app using the following command in the terminal:
python server.py
The server should run on port 5000.
4

Step 4: Forward the Port Using Ngrok

With ngrok installed and on your PATH, forward the port from a terminal (on Windows you can run ngrok.exe from the install folder instead).
ngrok http 5000
The command will generate a forwarding link (e.g., https://1234567890.ngrok-free.app), which can be used as the callback URL.
5

Step 5: Use the Callback URL

Include the callback URL in your request to Tavus by appending /webhook to the forwarding link and setting it in the callback_url field.
Create conversation with callback_url
curl --request POST \
  --url https://tavusapi.com/v2/conversations \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '{
  "callback_url": "https://1234567890.ngrok-free.app/webhook",
  "replica_id": "<replica_id>",
  "persona_id": "<persona_id>"
}'
  • Replace <api-key> with your actual API key. You can generate one in the Developer Portal.
  • Replace <replica_id> with the Replica ID you want to use.
  • Replace <persona_id> with the Persona ID you want to use.