Skip to main content
POST
/
export
/
conversation
Export Conversation
curl --request POST \
  --url https://api.talkifai.dev/export/conversation \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "conversationId": "agent_abc123_1705320000_user123",
  "includeTranscript": true,
  "includeAnalysis": true,
  "includeRecording": true
}
'
{
  "exportMetadata": {},
  "conversation": {},
  "summary": {}
}

Overview

Exports a single conversation’s complete data as a downloadable JSON file. Includes billing session details, agent configuration, transcript, post-call analysis, and recording URL (if available). Authentication: API Key or Internal Token Response: JSON file download

Request

Endpoint 1: Form Data

POST /api/export/conversation
Content-Type: application/x-www-form-urlencoded
Form Parameters:
ParameterTypeRequiredDefaultDescription
conversationIdstringRoom name/conversation ID to export
includeTranscriptbooleantrueInclude transcript data
includeAnalysisbooleantrueInclude post-call analysis
includeRecordingbooleantrueInclude recording URL

Endpoint 2: JSON Body

POST /api/export/conversation/json
Content-Type: application/json
Request Body:
{
  "conversationId": "agent_abc123_1705320000_user123",
  "includeTranscript": true,
  "includeAnalysis": true,
  "includeRecording": true
}

Headers

For API Key Authentication:
x-api-key: YOUR_API_KEY
For Internal Authentication:
x-internal-token: YOUR_INTERNAL_TOKEN
x-organization-id: org_123

Response

Status: 200 OK Content-Type: application/json Content-Disposition: attachment; filename="conversation-{id}-{date}.json"

Response Structure

{
  "exportMetadata": {
    "exportedAt": "2024-01-15T10:35:00Z",
    "organizationId": "org_123",
    "conversationId": "agent_abc123_1705320000_user123",
    "dataVersion": "1.1",
    "exportType": "single_conversation",
    "includedData": {
      "transcript": true,
      "analysis": true,
      "recording": true
    },
    "schemaVersion": "billing-session-v1"
  },
  "conversation": {
    "sessionId": "session_abc123",
    "roomName": "agent_abc123_1705320000_user123",
    "agentId": "agent_xyz789",
    "agentName": "Customer Support Bot",
    "sessionType": "webcall",
    "sessionStatus": "completed",
    "agentModel": "gpt_4o_mini",
    "agentArchitecture": "pipeline",
    "keyMode": "talkifai_keys",
    "callDirection": "inbound",
    "callerPhone": "+12025550123",
    "calleePhone": "+1234567890",
    "startTime": "2024-01-15T10:30:00Z",
    "endTime": "2024-01-15T10:35:00Z",
    "duration": 300,
    "baseCost": 0.25,
    "totalCost": 0.45,
    "user": {
      "id": "user_123",
      "name": "John Doe",
      "email": "john@example.com",
      "phone": "+12025550123",
      "company": "Acme Corp"
    },
    "agent": {
      "id": "agent_xyz789",
      "name": "Customer Support Bot",
      "description": "Handles customer inquiries",
      "model": "gpt_4o_mini",
      "stt": "deepgram",
      "agentArchitecture": "pipeline",
      "realtimeProvider": null,
      "enabledFunctions": ["web_search", "end_call"],
      "functionCallingEnabled": true,
      "enabledCustomFunctions": [],
      "greetingMessage": "Hello! How can I help you?",
      "greetingType": "agentFirst",
      "temperature": 0.7,
      "enabledPronunciations": [],
      "postCallAnalysisModel": "gpt_5_mini",
      "category": "customer_support",
      "mode": "public",
      "inactivityTimeout": 30
    },
    "transcript": {
      "raw": "[{\"speaker\": \"agent\", \"text\": \"Hello! How can I help you?\", \"timestamp\": \"2024-01-15T10:30:00Z\"}, ...]",
      "parsed": [
        {
          "function": "check_order_status",
          "parameters": {"order_id": "ORD-12345"},
          "timestamp": "2024-01-15T10:31:00Z"
        }
      ],
      "createdAt": "2024-01-15T10:35:00Z",
      "user": {
        "id": "user_123",
        "name": "John Doe",
        "email": "john@example.com"
      }
    },
    "postCallAnalysis": {
      "analysisData": {
        "call_summary": "Customer called about order status. Issue resolved.",
        "call_outcome": "Fully Resolved",
        "agent_professionalism": 9,
        "followed_protocol": true,
        "empathy_shown": true,
        "improvement_areas": "None"
      },
      "analyzedAt": "2024-01-15T10:36:00Z",
      "user": {
        "id": "user_123",
        "name": "John Doe",
        "email": "john@example.com"
      },
      "agent": {
        "id": "agent_xyz789",
        "name": "Customer Support Bot",
        "description": "Handles customer inquiries",
        "model": "gpt_4o_mini"
      }
    },
    "recording": {
      "id": "rec_abc123",
      "fileName": "recordings/2024/01/15/agent_abc123_1705320000_user123.webm",
      "signedUrl": "https://storage.googleapis.com/...?X-Goof-Algorithm=...",
      "urlExpiry": "2024-01-16T10:35:00Z",
      "createdAt": "2024-01-15T10:35:00Z",
      "available": true
    },
    "createdAt": "2024-01-15T10:30:00Z",
    "updatedAt": "2024-01-15T10:36:00Z"
  },
  "summary": {
    "hasTranscript": true,
    "hasAnalysis": true,
    "hasRecording": true,
    "hasFunctionCalls": true,
    "recordingAvailable": true,
    "duration": 300,
    "callCompleted": true,
    "isTelephonyCall": true,
    "hasBillingInfo": true
  }
}

Response Fields

Export Metadata

FieldTypeDescription
exportMetadata.exportedAtstringISO 8601 timestamp
exportMetadata.organizationIdstringOrganization ID
exportMetadata.conversationIdstringExported conversation ID
exportMetadata.dataVersionstringData schema version
exportMetadata.exportTypestringsingle_conversation
exportMetadata.includedDataobjectWhat data is included
exportMetadata.includedData.transcriptbooleanTranscript included
exportMetadata.includedData.analysisbooleanAnalysis included
exportMetadata.includedData.recordingbooleanRecording included
exportMetadata.schemaVersionstringSchema version

Conversation Object

FieldTypeDescription
conversation.sessionIdstringBilling session ID
conversation.roomNamestringRoom/conversation ID
conversation.agentIdstringAgent ID
conversation.agentNamestringAgent display name
conversation.sessionTypestringwebcall, telephony, chat
conversation.sessionStatusstringcompleted, failed, abandoned
conversation.agentModelstringLLM model used
conversation.agentArchitecturestringpipeline, realtime, text
conversation.keyModestringtalkifai_keys, my_keys, hybrid
conversation.callDirectionstringinbound or outbound
conversation.callerPhonestringCaller phone number
conversation.calleePhonestringDestination phone number
conversation.startTimestringISO 8601 timestamp
conversation.endTimestringISO 8601 timestamp
conversation.durationnumberDuration in seconds
conversation.baseCostnumberBase infrastructure cost
conversation.totalCostnumberTotal session cost
conversation.userobjectUser details
conversation.agentobjectAgent configuration
conversation.transcriptobjectTranscript data (if included)
conversation.postCallAnalysisobjectAnalysis data (if included)
conversation.recordingobjectRecording data (if included)

Summary Object

FieldTypeDescription
summary.hasTranscriptbooleanTranscript exists
summary.hasAnalysisbooleanAnalysis exists
summary.hasRecordingbooleanRecording exists
summary.hasFunctionCallsbooleanFunction calls in transcript
summary.recordingAvailablebooleanGCS bucket configured
summary.durationnumberCall duration
summary.callCompletedbooleanHas end time
summary.isTelephonyCallbooleanPhone call (not web)
summary.hasBillingInfobooleanHas cost data

Authentication

API Key Authentication

Header:
x-api-key: YOUR_API_KEY
Valid Keys:
  • Active API keys from database
  • Test keys: test-api-key-123, demo-api-key-456

Internal Token Authentication

Headers:
x-internal-token: YOUR_INTERNAL_TOKEN
x-organization-id: org_123
Use Case: Internal service-to-service calls

Error Responses

401 Unauthorized

{
  "detail": "Authentication required: either x-internal-token or x-api-key header"
}
{
  "detail": "Invalid API key"
}

400 Bad Request

{
  "detail": "Organization ID missing for internal requests. Please provide x-organization-id header."
}

404 Not Found

{
  "detail": "Conversation not found or you don't have access to this conversation"
}

500 Server Error

{
  "detail": "Export failed"
}

Examples

cURL (Form Data)

curl -X POST "https://api.talkifai.dev/api/export/conversation" \
  -H "x-api-key: YOUR_API_KEY" \
  -F "conversationId=agent_abc123_1705320000_user123" \
  -F "includeTranscript=true" \
  -F "includeAnalysis=true" \
  -F "includeRecording=true" \
  -o conversation-export.json

cURL (JSON)

curl -X POST "https://api.talkifai.dev/api/export/conversation/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "conversationId": "agent_abc123_1705320000_user123",
    "includeTranscript": true,
    "includeAnalysis": true,
    "includeRecording": true
  }' \
  -o conversation-export.json

JavaScript (Fetch)

const response = await fetch('https://api.talkifai.dev/api/export/conversation/json', {
  method: 'POST',
  headers: {
    'x-api-key': 'YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    conversationId: 'agent_abc123_1705320000_user123',
    includeTranscript: true,
    includeAnalysis: true,
    includeRecording: true
  })
});

if (response.ok) {
  const blob = await response.blob();
  const url = window.URL.createObjectURL(blob);
  const a = document.createElement('a');
  a.href = url;
  a.download = response.headers.get('content-disposition').split('filename=')[1];
  a.click();
  window.URL.revokeObjectURL(url);
}

Python (Requests)

import requests

url = "https://api.talkifai.dev/api/export/conversation/json"
headers = {
    "x-api-key": "YOUR_API_KEY",
    "Content-Type": "application/json"
}
data = {
    "conversationId": "agent_abc123_1705320000_user123",
    "includeTranscript": True,
    "includeAnalysis": True,
    "includeRecording": True
}

response = requests.post(url, json=data, headers=headers)

if response.status_code == 200:
    filename = response.headers['Content-Disposition'].split('filename=')[1]
    with open(filename, 'wb') as f:
        f.write(response.content)
    print(f"Exported: {filename}")

Next.js (Download)

async function downloadConversation(conversationId: string) {
  const response = await fetch('/api/export/conversation/json', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      conversationId,
      includeTranscript: true,
      includeAnalysis: true,
      includeRecording: true
    })
  });

  if (response.ok) {
    const blob = await response.blob();
    const url = URL.createObjectURL(blob);
    const a = document.createElement('a');
    a.href = url;
    a.download = `conversation-${conversationId}-${new Date().toISOString().split('T')[0]}.json`;
    document.body.appendChild(a);
    a.click();
    document.body.removeChild(a);
    URL.revokeObjectURL(url);
  }
}

Recording Signed URLs

How it works:
  • Recording URLs are Google Cloud Storage signed URLs
  • Expiry: 1 day from export time
  • Requires GCS_BUCKET environment variable
  • Requires credentials.json for GCP authentication
When Recording is Unavailable:
{
  "recording": null
}
Reasons:
  • includeRecording: false
  • GCS bucket not configured
  • Recording file not found
  • Storage client initialization failed

Data Included in Export

Always Included

  • ✅ Billing session details
  • ✅ Agent configuration
  • ✅ Call metadata (duration, cost, timestamps)
  • ✅ User information (if available)

Conditionally Included

  • ✅ Transcript (if includeTranscript: true and exists)
  • ✅ Post-call analysis (if includeAnalysis: true and exists)
  • ✅ Recording URL (if includeRecording: true and GCS configured)

Function Calls

Extracted from transcript JSON:
{
  "functionCalls": [
    {
      "function": "check_order_status",
      "parameters": {"order_id": "ORD-12345"},
      "result": {"status": "shipped", "tracking": "1Z999AA1"},
      "timestamp": "2024-01-15T10:31:00Z"
    }
  ]
}

Use Cases

Export for Compliance

// Export all conversations with full data
const conversations = await getConversationList();
for (const conv of conversations) {
  await downloadConversation(conv.id);
}

Backup Conversation Data

# Daily backup script
def backup_conversations():
    conversations = get_today_conversations()
    for conv in conversations:
        export_conversation(conv['id'])

Share Conversation with Customer

// Export specific conversation for customer
const exportData = await exportConversation(conversationId);
emailToCustomer(exportData);


Environment Variables

Required for Full Functionality:
VariableDescriptionExample
GCS_BUCKETGoogle Cloud Storage buckettalkifai-recordings
INTERNAL_TOKENInternal service tokenyour-secret-token
credentials.jsonGCP service account keyFile in root directory
Recording Storage:
  • Recordings stored in: gs://{GCS_BUCKET}/recordings/{date}/{filename}.webm
  • Signed URLs expire after 1 day
  • Requires GCP credentials for authentication

Authorizations

Authorization
string
header
required

Your TalkifAI API key. Get it from Studio → Settings → API Keys.

Body

application/json
conversationId
string
required

Room name or conversation ID to export

Example:

"agent_abc123_1705320000_user123"

includeTranscript
boolean
default:true

Include transcript data

includeAnalysis
boolean
default:true

Include post-call analysis

includeRecording
boolean
default:true

Include recording signed URL

Response

Exported conversation JSON file

exportMetadata
object
conversation
object
summary
object