Get Leg
Retrieves a single call leg by legId. Use this to inspect one participant leg and its latest state.
Signature
// Callback version
fun getLeg(
legId: String,
callback: (Exception?, Leg?) -> Unit
)
// Suspend version
suspend fun getLeg(
legId: String
): Leg
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
legId | string | Yes | Identifier of the leg to retrieve |
Return Type
Returns a Leg / VGVoiceLeg object for the requested leg.
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 |
Usage Example
// Callback
client.getLeg("legId") { err, leg ->
err?.let {
println("Error in getting leg: $it")
}
leg?.let {
println("Leg id: ${it.id}, media state: ${it.mediaState}")
}
}
// Coroutine
try {
val leg = client.getLeg("legId")
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 and related | Leg cannot be found for provided legId |
NETWORK_ERROR | internal:error:serviceNotAvailable | Network/service failure while fetching leg |
UNKNOWN_ERROR | N/A | Unexpected failure |
For complete error reference and handling guidelines, see Error Reference.
Notes
- Use
getCallLegswhen you need pagination over all legs in a call legIdvalues are available from call events likelegStatusUpdate
Related Actions
getCallLegs- Retrieve paginated call legs for a call
Related Events
onLegStatusUpdate- Fired when a remote leg status changes