Interface IVoiceClient
Exposes Voice API v1 features for creating outbound calls, controlling in-progress calls, streaming audio, playing text-to-speech, sending DTMF tones, and retrieving call history.
public interface IVoiceClient
Methods
CreateCallAsync(CallCommand, Credentials)
Creates an outbound call to a phone number, SIP endpoint, WebSocket, or VBC extension.
Task<CallResponse> CreateCallAsync(CallCommand command, Credentials creds = null)
Parameters
commandCallCommandThe call configuration including destination endpoints, NCCO or answer URL, and optional settings such as machine detection and timers.
credsCredentials(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.
Task<CallRecord> GetCallAsync(string id, Credentials creds = null)
Parameters
idstringThe UUID of the call to retrieve.
credsCredentials(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.
Task<PageResponse<CallList>> GetCallsAsync(CallSearchFilter filter, Credentials creds = null)
Parameters
filterCallSearchFilterThe filter criteria for searching calls (status, date range, pagination, ordering).
credsCredentials(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.
Task<GetRecordingResponse> GetRecordingAsync(string recordingUrl, Credentials creds = null)
Parameters
recordingUrlstringThe recording URL received in the recording webhook event.
credsCredentials(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.
Task<TranscriptionResult> GetTranscriptionAsync(string transcriptionUrl, Credentials creds = null)
Parameters
transcriptionUrlstringThe
transcription_urldelivered by the transcription webhook (e.g.https://api.nexmo.com/v1/files/...).credsCredentials(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.
Task<CallCommandResponse> StartDtmfAsync(string id, DtmfCommand cmd, Credentials creds = null)
Parameters
idstringThe UUID of the call to send DTMF tones to.
cmdDtmfCommandThe DTMF command containing the digit string to send.
credsCredentials(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.
Task<CallCommandResponse> StartStreamAsync(string id, StreamCommand command, Credentials creds = null)
Parameters
idstringThe UUID of the call to stream audio into.
commandStreamCommandThe stream command containing the audio URL, loop count, and volume level.
credsCredentials(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.
Task<CallCommandResponse> StartTalkAsync(string id, TalkCommand cmd, Credentials creds = null)
Parameters
idstringThe UUID of the call to play text-to-speech into.
cmdTalkCommandThe talk command containing the text, language, voice style, loop count, and volume level.
credsCredentials(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.
Task<CallCommandResponse> StopStreamAsync(string id, Credentials creds = null)
Parameters
idstringThe UUID of the call to stop streaming audio into.
credsCredentials(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.
Task<CallCommandResponse> StopTalkAsync(string id, Credentials creds = null)
Parameters
idstringThe UUID of the call to stop the text-to-speech in.
credsCredentials(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.
Task SubscribeRealTimeDtmf(string uuid, Uri eventUrl, Credentials creds = null)
Parameters
uuidstringThe UUID of the call leg to subscribe to.
eventUrlUriThe URL to send DTMF events to as POST requests.
credsCredentials(Optional) Overridden credentials for only this request.
Returns
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.
Task UnsubscribeRealTimeDtmf(string uuid, Credentials creds = null)
Parameters
uuidstringThe UUID of the call leg to unsubscribe from.
credsCredentials(Optional) Overridden credentials for only this request.
Returns
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.
Task<bool> UpdateCallAsync(string id, CallEditCommand command, Credentials creds = null)
Parameters
idstringThe UUID of the call to modify.
commandCallEditCommandThe edit command specifying the action to perform (e.g., hangup, mute, transfer).
credsCredentials(Optional) Overridden credentials for only this request.
Returns
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.
IVoiceClient WithRegion(VonageUrls.Region targetedRegion)
Parameters
targetedRegionVonageUrls.RegionThe region to target for API requests.
Returns
- IVoiceClient
A new IVoiceClient instance configured for the specified region.