Skip to content

Get Call Legs

Retrieves paginated call legs for a call. Use this to inspect participants/legs and related metadata.

Signature

// Callback version
fun getCallLegs(
  callId: String,
  parameters: GetCallLegsParameters?,
  callback: (Exception?, LegsPage?) -> Unit
)

// Suspend version
suspend fun getCallLegs(
  callId: String,
  parameters: GetCallLegsParameters?
): LegsPage

Parameters

ParameterTypeRequiredDescription
callIdstringYesIdentifier of the call
parametersGetCallLegsParametersNoPagination/order options

GetCallLegsParameters

PropertyTypeRequiredDescription
orderasc | descNoOrder of returned legs
pageSizenumberNoNumber of legs per page
cursorstringNoCursor for pagination continuation

Return Type

Returns LegsPage containing:

PropertyTypeDescription
legsLeg[]List of call legs — see below
nextCursorstring?Cursor for next page (if available)
previousCursorstring?Cursor for previous page (if available)

Leg Properties

PropertyTypeDescription
id / legIdstringUnique leg identifier
typestringLeg type (e.g. app, phone, sip)
directionstringinbound or outbound
conversationIdstringConversation the leg belongs to
statusstringCurrent leg status
startTimestringLeg start timestamp
endTimestringLeg end timestamp
fromLegChannelOrigin channel — see below
toLegChannelDestination channel — see below
mediaStateMediaState?Optional: mute, earmuff, recording, and streaming state

LegChannel Properties

PropertyTypeDescription
typestring?Channel type (app, phone, sip, websocket)
userstring?User identifier — present for app-type channels
numberstring?Phone number — present for phone-type channels

MediaState Properties

PropertyTypeDescription
mutedbooleanWhether the leg is currently muted
earmuffedbooleanWhether the leg is currently earmuffed
recordingbooleanWhether the leg is being recorded
streamingbooleanWhether the leg audio is being streamed to an external WebSocket

Usage Example


 // Callback
 client.getCallLegs(
     "callId",
     GetCallLegsParameters(PresentingOrder.ASC, 10)
 ) { err, page ->
     err?.let { /* Handle Error in fetching Legs */ }
     page?.let {
         val nextCursor = it.nextCursor
         it.legs.forEach { leg ->
             println("Leg id: ${leg.id}, media state: ${leg.mediaState}")
         }
     }
 }

 // Coroutine
 try {
     val (legs, previousCursor, nextCursor ) = client.getCallLegs(
         "callId",
         GetCallLegsParameters(PresentingOrder.ASC, 10)
     )
     legs.forEach {leg ->
         println("Leg id: ${leg.id}, media state: ${leg.mediaState}")
     }
 }
 catch(e: VGError) { /* Handle Vonage Error */ }
 catch(e: Error) { /* Handle generic Error */ }

Errors

Error TypeError CodeDescription
INTERNAL_ERRORvoice:error:no_call_foundCall not found for provided callId
CS_ERRORPagination/validation errorsInvalid cursor/page parameters or backend response error
NETWORK_ERRORinternal:error:serviceNotAvailableNetwork/service failure while fetching legs
UNKNOWN_ERRORN/AUnexpected failure

For complete error reference and handling guidelines, see Error Reference.

Notes

  • Use cursors to paginate through large call leg sets
  • Ordering and page size defaults are applied when omitted

Built with VitePress.