Agent Studio

Calls Endpoints

API endpoints for initiating and monitoring voice calls

Calls Endpoints

Endpoints for initiating voice calls (VoIP and SIP) and monitoring their status and transcripts.

Call Types

Agent Studio supports two types of calls:

TypeProtocolDescription
voipWebRTCIn-app calls via browser/mobile microphone
sipSIP/RTPPhone calls via PSTN through Twilio

Initiate Call

POST /api/v1/calls

Start a new voice call using a workflow.

Request Body:

{
  "workflow_slug": "daily-call",
  "user_id": "user-123",
  "call_type": "voip",
  "user_context": {
    "name": "John Doe",
    "language": "en"
  },
  "metadata": {
    "session_id": "abc123",
    "source": "mobile-app"
  }
}

Required Fields:

FieldTypeDescription
workflow_slugstringWorkflow to use for this call

Optional Fields:

FieldTypeDefaultDescription
user_idstringnullExternal user identifier
call_typestringvoipCall type: voip or sip
phone_numberstringnullPhone number for SIP calls (E.164 format)
user_contextobjectContext data available as {{user.*}} in templates
metadataobjectAdditional metadata stored with call

VoIP Call Example

User joins via WebRTC (browser/app microphone):

{
  "workflow_slug": "daily-call",
  "user_id": "user-123",
  "call_type": "voip",
  "user_context": {
    "name": "John Doe"
  }
}

SIP Call Example

Outbound phone call via Twilio:

{
  "workflow_slug": "welcome-call",
  "user_id": "user-456",
  "call_type": "sip",
  "phone_number": "+919876543210",
  "user_context": {
    "name": "Jane Smith",
    "onboarding_status": "new"
  }
}

For SIP calls, phone_number is required and must be in E.164 format (e.g., +919876543210).

Response:

{
  "call_id": "uuid",
  "room_name": "call-uuid",
  "url": "wss://livekit.example.com",
  "token": "eyJ...",
  "status": "pending"
}
FieldDescription
call_idUnique call identifier
room_nameLiveKit room name for connection
urlLiveKit server WebSocket URL
tokenJWT token for LiveKit authentication
statusInitial call status

For VoIP calls, the client uses the token and url to join via WebRTC. For SIP calls, the worker handles the phone dial-out automatically.

Test Agent Call

POST /api/v1/calls/test-agent

Start a test call with a single agent (no workflow). Useful for testing agents before adding to workflows.

Request Body:

{
  "agent_name": "greeter-agent",
  "user_id": "test-user",
  "user_context": {
    "name": "Tester"
  }
}

Response: Same as Initiate Call.

Test agent calls are always VoIP. SIP calls require a workflow.

Get Call

GET /api/v1/calls/{id}

Get call status and details.

Path Parameters:

ParameterTypeDescription
iduuidCall ID

Response:

{
  "id": "uuid",
  "workflow_id": "uuid",
  "workflow_slug": "daily-call",
  "user_id": "user-123",
  "status": "completed",
  "direction": "outbound",
  "call_type": "sip",
  "phone_number": "+919876543210",
  "duration_seconds": 180,
  "agent_history": ["greeter-agent", "meal-agent", "feedback-agent"],
  "current_agent": null,
  "metrics": {
    "duration_seconds": 180,
    "stt_latency_ms": 120,
    "llm_latency_ms": 280,
    "tts_latency_ms": 85,
    "total_tokens": 1500,
    "agent_handoffs": 2
  },
  "started_at": "2026-01-17T10:30:00Z",
  "ended_at": "2026-01-17T10:33:00Z",
  "created_at": "2026-01-17T10:29:55Z"
}

Get Call Transcript

GET /api/v1/calls/{id}/transcript

Get the full transcript of a call.

Path Parameters:

ParameterTypeDescription
iduuidCall ID

Response:

[
  {
    "role": "system",
    "content": "Call started",
    "timestamp": "2026-01-17T10:30:00Z",
    "agent_name": "greeter-agent"
  },
  {
    "role": "assistant",
    "content": "Hello! How are you today?",
    "timestamp": "2026-01-17T10:30:05Z",
    "agent_name": "greeter-agent"
  },
  {
    "role": "user",
    "content": "I'm doing well, thanks!",
    "timestamp": "2026-01-17T10:30:10Z",
    "agent_name": "greeter-agent"
  },
  {
    "role": "assistant",
    "content": "Great! What did you have for breakfast?",
    "timestamp": "2026-01-17T10:30:15Z",
    "agent_name": "meal-agent",
    "tool_call": {
      "name": "save_meal",
      "arguments": { "meal_type": "breakfast" }
    }
  }
]

Get Call Metrics

GET /api/v1/calls/{id}/metrics

Get performance metrics for a call.

Response:

{
  "duration_seconds": 180,
  "stt_latency_ms": 120,
  "llm_latency_ms": 280,
  "tts_latency_ms": 85,
  "total_tokens": 1500,
  "agent_handoffs": 2
}

List Calls

GET /api/v1/calls

List calls with filtering and pagination.

Query Parameters:

ParameterTypeDescription
pageintegerPage number (default: 1)
page_sizeintegerItems per page (default: 20, max: 100)
statusstringFilter by status
workflow_iduuidFilter by workflow
user_idstringFilter by user
started_afterdatetimeFilter by start time (after)
started_beforedatetimeFilter by start time (before)

Response:

{
  "items": [
    {
      "id": "uuid",
      "workflow_id": "uuid",
      "workflow_slug": "daily-call",
      "user_id": "user-123",
      "status": "completed",
      "call_type": "sip",
      "duration_seconds": 180,
      "agent_history": ["greeter-agent", "meal-agent"],
      "started_at": "2026-01-17T10:30:00Z",
      "ended_at": "2026-01-17T10:33:00Z"
    }
  ],
  "total": 100,
  "page": 1,
  "page_size": 20,
  "pages": 5
}

List Active Calls

GET /api/v1/calls/active

List currently active calls.

Query Parameters:

ParameterTypeDescription
limitintegerMax results (default: 50, max: 100)

Response:

[
  {
    "id": "uuid",
    "workflow_slug": "daily-call",
    "user_id": "user-456",
    "status": "active",
    "call_type": "voip",
    "current_agent": "meal-agent",
    "started_at": "2026-01-17T10:35:00Z"
  }
]

Call Status Values

StatusDescription
pendingCall initiated, waiting for connection
connectingEstablishing connection
activeCall in progress
completedCall ended normally
failedCall failed to connect
disconnectedCall dropped unexpectedly
timeoutCall timed out

Call Type Values

TypeDescription
voipWebRTC-based in-app call
sipPhone call via SIP/PSTN

Call Direction

DirectionDescription
inboundUser initiated the call
outboundSystem initiated the call

SIP Call Flow

For SIP calls, the flow is:

  1. API receives call request with call_type: "sip" and phone_number
  2. LiveKit room is created
  3. Worker is dispatched with phone number in metadata
  4. Worker creates SIP participant via LiveKit SIP service
  5. LiveKit SIP dials out through Twilio trunk
  6. When user answers, audio flows through LiveKit room
  7. Agent interacts with user via voice
  8. Call ends, room is cleaned up
API Request → LiveKit Room → Worker → SIP Server → Twilio → PSTN → Phone

Provider Keys Endpoints

List Provider Keys

GET /api/v1/provider-keys

List configured BYOK provider keys (key values are masked).

Response:

{
  "items": [
    {
      "id": "uuid",
      "provider_type": "stt",
      "provider_name": "deepgram",
      "is_default": true,
      "created_at": "2026-01-17T10:30:00Z"
    }
  ]
}

Create Provider Key

POST /api/v1/provider-keys

Add a BYOK provider key.

Request Body:

{
  "provider_type": "stt",
  "provider_name": "deepgram",
  "api_key": "dg_xxxxx",
  "is_default": true
}

Delete Provider Key

DELETE /api/v1/provider-keys/{id}

Delete a provider key. Returns 204 on success.

On this page