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
| Parameter | Type | Required | Description |
|---|---|---|---|
callId | string | Yes | Identifier of the call |
parameters | GetCallLegsParameters | No | Pagination/order options |
GetCallLegsParameters
| Property | Type | Required | Description |
|---|---|---|---|
order | asc | desc | No | Order of returned legs |
pageSize | number | No | Number of legs per page |
cursor | string | No | Cursor for pagination continuation |
Return Type
Returns LegsPage containing:
| Property | Type | Description |
|---|---|---|
legs | Leg[] | List of call legs — see below |
nextCursor | string? | Cursor for next page (if available) |
previousCursor | string? | Cursor for previous page (if available) |
Leg Properties
| Property | Type | Description |
|---|---|---|
id / legId | string | Unique leg identifier |
type | string | Leg type (e.g. app, phone, sip) |
direction | string | inbound or outbound |
conversationId | string | Conversation the leg belongs to |
status | string | Current leg status |
startTime | string | Leg start timestamp |
endTime | string | Leg end timestamp |
from | LegChannel | Origin channel — see below |
to | LegChannel | Destination channel — see below |
mediaState | MediaState? | Optional: mute, earmuff, recording, and streaming state |
LegChannel Properties
| Property | Type | Description |
|---|---|---|
type | string? | Channel type (app, phone, sip, websocket) |
user | string? | User identifier — present for app-type channels |
number | string? | Phone number — present for phone-type channels |
MediaState Properties
| Property | Type | Description |
|---|---|---|
muted | boolean | Whether the leg is currently muted |
earmuffed | boolean | Whether the leg is currently earmuffed |
recording | boolean | Whether the leg is being recorded |
streaming | boolean | Whether 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 Type | Error Code | Description |
|---|---|---|
INTERNAL_ERROR | voice:error:no_call_found | Call not found for provided callId |
CS_ERROR | Pagination/validation errors | Invalid cursor/page parameters or backend response error |
NETWORK_ERROR | internal:error:serviceNotAvailable | Network/service failure while fetching legs |
UNKNOWN_ERROR | N/A | Unexpected 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
Related Events
onLegStatusUpdate- Fired when a remote leg status changes