Table of Contents

Class VoiceClient

Namespace
Vonage.Voice
Assembly
Vonage.dll
public class VoiceClient : IVoiceClient
Inheritance
VoiceClient
Implements
Inherited Members

Constructors

VoiceClient(Credentials)

Initializes a VoiceClient.

public VoiceClient(Credentials credentials = null)

Parameters

credentials Credentials

Credentials to use for api calls.

Methods

CreateCallAsync(CallCommand, Credentials)

Creates an outbound call to a phone number, SIP endpoint, WebSocket, or VBC extension.

public Task<CallResponse> CreateCallAsync(CallCommand command, Credentials creds = null)

Parameters

command CallCommand

The call configuration including destination endpoints, NCCO or answer URL, and optional settings such as machine detection and timers.

creds Credentials

(Optional) Overridden credentials for only this request.

Returns

Task<CallResponse>

A CallResponse containing the call UUID, status, direction, and conversation UUID.

Examples

var command = new CallCommand
{
    To = new[] { new PhoneEndpoint { Number = "447700900000" } },
    From = new PhoneEndpoint { Number = "447700900001" },
    Ncco = new Ncco(new TalkAction { Text = "Hello from Vonage!" })
};
var response = await client.CreateCallAsync(command);
Console.WriteLine($"Call UUID: {response.Uuid}");

Exceptions

VonageHttpRequestException

Thrown if an error is encountered when communicating with the API.

See Also

GetCallAsync(string, Credentials)

Retrieves detailed information about a single call by its UUID, including status, duration, price, and endpoints.

public Task<CallRecord> GetCallAsync(string id, Credentials creds = null)

Parameters

id string

The UUID of the call to retrieve.

creds Credentials

(Optional) Overridden credentials for only this request.

Returns

Task<CallRecord>

A CallRecord containing the full call details.

Examples

var call = await client.GetCallAsync("63f61863-4a51-4f6b-86e1-46edebcf9356");
Console.WriteLine($"Status: {call.Status}, Duration: {call.Duration}s");

Exceptions

VonageHttpRequestException

Thrown if an error is encountered when communicating with the API.

See Also

GetCallsAsync(CallSearchFilter, Credentials)

Retrieves a paginated list of calls, optionally filtered by status, date range, or conversation UUID.

public Task<PageResponse<CallList>> GetCallsAsync(CallSearchFilter filter, Credentials creds = null)

Parameters

filter CallSearchFilter

The filter criteria for searching calls (status, date range, pagination, ordering).

creds Credentials

(Optional) Overridden credentials for only this request.

Returns

Task<PageResponse<CallList>>

A paginated response containing matching CallList records.

Examples

var filter = new CallSearchFilter { Status = "completed", PageSize = 20 };
var calls = await client.GetCallsAsync(filter);

Exceptions

VonageHttpRequestException

Thrown if an error is encountered when communicating with the API.

See Also

GetRecordingAsync(string, Credentials)

Downloads a call recording as a byte array from the URL provided in the recording webhook.

public Task<GetRecordingResponse> GetRecordingAsync(string recordingUrl, Credentials creds = null)

Parameters

recordingUrl string

The recording URL received in the recording webhook event.

creds Credentials

(Optional) Overridden credentials for only this request.

Returns

Task<GetRecordingResponse>

A GetRecordingResponse containing the recording file as a byte array.

Examples

var recording = await client.GetRecordingAsync("https://api.nexmo.com/v1/files/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee");
File.WriteAllBytes("recording.mp3", recording.ResultStream);

Exceptions

VonageHttpRequestException

Thrown if an error is encountered when communicating with the API.

See Also

GetTranscriptionAsync(string, Credentials)

Retrieves a transcription result from the URL provided in the transcription webhook.

public Task<TranscriptionResult> GetTranscriptionAsync(string transcriptionUrl, Credentials creds = null)

Parameters

transcriptionUrl string

The transcription_url delivered by the transcription webhook (e.g. https://api.nexmo.com/v1/files/...).

creds Credentials

(Optional) Overridden credentials for only this request.

Returns

Task<TranscriptionResult>

The deserialized TranscriptionResult containing channels, transcripts, and word-level detail.

Examples

var transcription = await client.GetTranscriptionAsync("https://api.nexmo.com/v1/files/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee");

Exceptions

VonageHttpRequestException

Thrown if an error is encountered when communicating with the API.

See Also

StartDtmfAsync(string, DtmfCommand, Credentials)

Sends DTMF (Dual-Tone Multi-Frequency) tones into an active call.

public Task<CallCommandResponse> StartDtmfAsync(string id, DtmfCommand cmd, Credentials creds = null)

Parameters

id string

The UUID of the call to send DTMF tones to.

cmd DtmfCommand

The DTMF command containing the digit string to send.

creds Credentials

(Optional) Overridden credentials for only this request.

Returns

Task<CallCommandResponse>

A CallCommandResponse confirming the action was performed.

Examples

var response = await client.StartDtmfAsync("63f61863-4a51-4f6b-86e1-46edebcf9356", new DtmfCommand { Digits = "1713" });

Exceptions

VonageHttpRequestException

Thrown if an error is encountered when communicating with the API.

See Also

StartStreamAsync(string, StreamCommand, Credentials)

Streams an audio file into an active call. The file must be a single-channel 16-bit WAV at 8kHz or 16kHz, or an MP3 file.

public Task<CallCommandResponse> StartStreamAsync(string id, StreamCommand command, Credentials creds = null)

Parameters

id string

The UUID of the call to stream audio into.

command StreamCommand

The stream command containing the audio URL, loop count, and volume level.

creds Credentials

(Optional) Overridden credentials for only this request.

Returns

Task<CallCommandResponse>

A CallCommandResponse confirming the stream was started.

Examples

var command = new StreamCommand { StreamUrl = new[] { "https://example.com/waiting.mp3" } };
var response = await client.StartStreamAsync("63f61863-4a51-4f6b-86e1-46edebcf9356", command);

Exceptions

VonageHttpRequestException

Thrown if an error is encountered when communicating with the API.

See Also

StartTalkAsync(string, TalkCommand, Credentials)

Plays a text-to-speech message into an active call using the specified language and voice style.

public Task<CallCommandResponse> StartTalkAsync(string id, TalkCommand cmd, Credentials creds = null)

Parameters

id string

The UUID of the call to play text-to-speech into.

cmd TalkCommand

The talk command containing the text, language, voice style, loop count, and volume level.

creds Credentials

(Optional) Overridden credentials for only this request.

Returns

Task<CallCommandResponse>

A CallCommandResponse confirming the talk was started.

Examples

var cmd = new TalkCommand { Text = "Hello, how are you?", Language = "en-US", Style = 0 };
var response = await client.StartTalkAsync("63f61863-4a51-4f6b-86e1-46edebcf9356", cmd);

Exceptions

VonageHttpRequestException

Thrown if an error is encountered when communicating with the API.

See Also

StopStreamAsync(string, Credentials)

Stops streaming an audio file into an active call.

public Task<CallCommandResponse> StopStreamAsync(string id, Credentials creds = null)

Parameters

id string

The UUID of the call to stop streaming audio into.

creds Credentials

(Optional) Overridden credentials for only this request.

Returns

Task<CallCommandResponse>

A CallCommandResponse confirming the stream was stopped.

Examples

var response = await client.StopStreamAsync("63f61863-4a51-4f6b-86e1-46edebcf9356");

Exceptions

VonageHttpRequestException

Thrown if an error is encountered when communicating with the API.

See Also

StopTalkAsync(string, Credentials)

Stops playing a text-to-speech message in an active call.

public Task<CallCommandResponse> StopTalkAsync(string id, Credentials creds = null)

Parameters

id string

The UUID of the call to stop the text-to-speech in.

creds Credentials

(Optional) Overridden credentials for only this request.

Returns

Task<CallCommandResponse>

A CallCommandResponse confirming the talk was stopped.

Examples

var response = await client.StopTalkAsync("63f61863-4a51-4f6b-86e1-46edebcf9356");

Exceptions

VonageHttpRequestException

Thrown if an error is encountered when communicating with the API.

See Also

SubscribeRealTimeDtmf(string, Uri, Credentials)

Registers a listener to receive real-time asynchronous DTMF inputs from a call. This is only applicable to Input NCCO events with the mode set to asynchronous. The payload delivered to the URL will be an Input webhook event with a single DTMF digit every time the callee enters DTMF into the call.

public Task SubscribeRealTimeDtmf(string uuid, Uri eventUrl, Credentials creds = null)

Parameters

uuid string

The UUID of the call leg to subscribe to.

eventUrl Uri

The URL to send DTMF events to as POST requests.

creds Credentials

(Optional) Overridden credentials for only this request.

Returns

Task

Examples

await client.SubscribeRealTimeDtmf("63f61863-4a51-4f6b-86e1-46edebcf9356",
    new Uri("https://example.com/dtmf-events"));
See Also

UnsubscribeRealTimeDtmf(string, Credentials)

Removes the registered DTMF listener from a call, stopping real-time DTMF event delivery.

public Task UnsubscribeRealTimeDtmf(string uuid, Credentials creds = null)

Parameters

uuid string

The UUID of the call leg to unsubscribe from.

creds Credentials

(Optional) Overridden credentials for only this request.

Returns

Task

Examples

await client.UnsubscribeRealTimeDtmf("63f61863-4a51-4f6b-86e1-46edebcf9356");
See Also

UpdateCallAsync(string, CallEditCommand, Credentials)

Modifies an in-progress call. Supports hangup, mute, unmute, earmuff, unearmuff, and transfer actions.

public Task<bool> UpdateCallAsync(string id, CallEditCommand command, Credentials creds = null)

Parameters

id string

The UUID of the call to modify.

command CallEditCommand

The edit command specifying the action to perform (e.g., hangup, mute, transfer).

creds Credentials

(Optional) Overridden credentials for only this request.

Returns

Task<bool>

true if the call was successfully modified.

Examples

var success = await client.UpdateCallAsync("63f61863-4a51-4f6b-86e1-46edebcf9356",
    new CallEditCommand { Action = CallEditCommand.ActionType.hangup });

Exceptions

VonageHttpRequestException

Thrown if an error is encountered when communicating with the API.

See Also

WithRegion(Region)

Returns a new Voice client targeting a specific region. Use this to create and manage calls within a specific geographic region.

public IVoiceClient WithRegion(VonageUrls.Region targetedRegion)

Parameters

targetedRegion VonageUrls.Region

The region to target for API requests.

Returns

IVoiceClient

A new IVoiceClient instance configured for the specified region.