# Class VonageClient

VonageClient is the main entry point for the Vonage Client SDK.

#### Hierarchy

- CombinedClientJS
  - VonageClient

#####
Index

### Methods

clearCallbacks
createSession
getConversation
off
on
setConfig
updateConversation

### Chat

createConversation
deleteConversation
deleteEvent
getConversationEvents
getConversationMember
getConversationMembers
getConversations
inviteToConversation
joinConversation
leaveConversation
sendCustomEvent
sendEphemeralEvent
sendMessageAudioEvent
sendMessageCustomEvent
sendMessageFileEvent
sendMessageImageEvent
sendMessageLocationEvent
sendMessageSeenEvent
sendMessageTemplateEvent
sendMessageTextEvent
sendMessageVCardEvent
sendMessageVideoEvent

### Voice

answer
disableEarmuff
enableEarmuff
getAudioOutputElement
getCallLegs
getLeg
getPeerConnection
hangup
mute
reconnectCall
reject
say
sendDTMF
serverCall
unmute

## Methods

### clearCallbacks

- clearCallbacks<T>(event): void

- Clear all callbacks for an event.

  #### Type Parameters

  - #### T extends "mute" | "conversationEvent" | "callHangup" | "callMediaDisconnect" | "legStatusUpdate" | "rtcStatsUpdate" | "callInvite" | "callInviteCancel" | "sessionError" | "callMediaError" | "callTransfer" | "earmuff" | "dtmf" | "callMediaReconnecting" | "callMediaReconnection" | "reconnecting" | "reconnection"

  #### Parameters

  - ##### event: T

    the event to unregister from (e.g. 'legStatusUpdate')

  #### Returns void

  void

  #### Example

      [[include: snippet_ClearCallbacks.txt]]

  #### Remarks

  This is useful for cleaning up callbacks when you no longer need them.

### createSession

- createSession(token, sessionId?): Promise<string>

- Create a session with a token and optional sessionId If no sessionId is provided, a new one will be generated and returned. If a sessionId is provided, it will be used to resume an existing session.

  #### Parameters

  - ##### token: string

  - ##### `Optional` sessionId: null | string

    optional sessionId to use

  #### Returns Promise<string>

  the `sessionId` of the session

  #### Example

      [[include: snippet_SessionCreate.txt]]

  Overrides vonage.CombinedClientJS.createSession

### getConversation

- getConversation(conversationIdOrName): Promise<Conversation>

- Get a Conversation

  #### Parameters

  - ##### conversationIdOrName: string

    the Conversation's id or conversation name

  #### Returns Promise<Conversation>

  the `Conversation`

  #### Example

      [[include: snippet_GetConversation.txt]]

  Overrides vonage.CombinedClientJS.getConversation

### off

- off<T>(event, callbackSymbol): boolean

- Unregister a callback for an event.

  #### Type Parameters

  - #### T extends "mute" | "conversationEvent" | "callHangup" | "callMediaDisconnect" | "legStatusUpdate" | "rtcStatsUpdate" | "callInvite" | "callInviteCancel" | "sessionError" | "callMediaError" | "callTransfer" | "earmuff" | "dtmf" | "callMediaReconnecting" | "callMediaReconnection" | "reconnecting" | "reconnection"

  #### Parameters

  - ##### event: T

    the event to register for (e.g. 'legStatusUpdate')

  - ##### callbackSymbol: symbol

    the callback symbol to unregister

  #### Returns boolean

  true if the callback was unregistered, false otherwise

  #### Example

      [[include: snippet_UnregisterListener.txt]]

  #### Remarks

  We recommend deregistering callbacks when you no longer need them.

### on

- on<T, P>(event, callback): symbol

- Register a callback for an event.

  #### Type Parameters

  - #### T extends "mute" | "conversationEvent" | "callHangup" | "callMediaDisconnect" | "legStatusUpdate" | "rtcStatsUpdate" | "callInvite" | "callInviteCancel" | "sessionError" | "callMediaError" | "callTransfer" | "earmuff" | "dtmf" | "callMediaReconnecting" | "callMediaReconnection" | "reconnecting" | "reconnection"

  - #### P extends ((event) => void) | ((callId, callQuality, reason) => void) | ((callId, reason) => void) | ((callId, legId, legStatus) => void) | ((stats, callId) => void) | ((callId, reason) => void) | ((callId, from, channelType) => void) | ((reason) => void) | ((callId, error) => void) | ((callId, legId, isMuted) => void) | ((callId, conversationId) => void) | ((callId, legId, earmuffStatus) => void) | ((callId, legId, digits) => void) | ((callId) => void) | ((callId) => void) | (() => void) | (() => void)

  #### Parameters

  - ##### event: T

    the event to register for (e.g. 'legStatusUpdate')

  - ##### callback: P

    the callback to register for the event

  #### Returns symbol

  a symbol that can be used to unregister the callback

  #### Example

      [[include: snippet_OnConversationEventListener.txt]]

  #### Remarks

  Be sure to store the symbol returned by this method so you can unregister the callback later. We recommend unregistering callbacks when you no longer need them. See off.

### setConfig

- setConfig(config): void

- Set a configuration for the client SDK

  #### Parameters

  - ##### config: ClientConfigObject

    A configuration object

  #### Returns void

  void

  #### Example

      [[include: snippet_SetClientConfig.txt]]

  Overrides vonage.CombinedClientJS.setConfig

### updateConversation

- updateConversation(conversationId, parameters): Promise<Conversation>

- Updates a conversation object identified by its unique conversation ID.

  This method overrides the conversation properties to the provided parameters and rest remains as it is.

  #### Parameters

  - ##### conversationId: string

    the Conversation's id.

  - ##### parameters: UpdateConversationParameters

    The properties of the conversation. These will replace existing values to the provided ones, rest will remain as they are.

  #### Returns Promise<Conversation>

  `conversation`, this object will contain the updated conversation properties if the update is successful.

  #### Example

      [[include: snippet_UpdateConversation.txt]]

  Overrides vonage.CombinedClientJS.updateConversation

## Chat

### createConversation

- createConversation(parameters?): Promise<string>

- Create a conversation

  #### Parameters

  - ##### `Optional` parameters: Nullable<CreateConversationParameters>

    A CreateConversationParameters object containing the parameters for the creation request.

  #### Returns Promise<string>

  the `cid` of the conversation

  #### Example

      [[include: snippet_CreateConversation.txt]]

  Overrides vonage.CombinedClientJS.createConversation

### deleteConversation

- deleteConversation(id): Promise<void>

- Delete a Conversation

  #### Parameters

  - ##### id: string

    the Conversation's id

  #### Returns Promise<void>

  void

  #### Example

      [[include: snippet_DeleteConversation.txt]]

  Overrides vonage.CombinedClientJS.deleteConversation

### deleteEvent

- deleteEvent(id, conversationId): Promise<void>

- Delete an Event in a Conversation

  #### Parameters

  - ##### id: number

    the id for the Event to be deleted

  - ##### conversationId: string

    the id for the conversation, the event belongs to.

  #### Returns Promise<void>

  void

  #### Example

      [[include:snippet_DeleteEvent.txt]]

  Overrides vonage.CombinedClientJS.deleteEvent

### getConversationEvents

- getConversationEvents(id, parameters?): Promise<EventsPage>

- Get a Conversation's Events

  #### Parameters

  - ##### id: string

    the Conversation's id

  - ##### `Optional` parameters: Nullable<GetConversationEventsParameters>

    A GetConversationEventsParameters object containing the parameters for the request.

  #### Returns Promise<EventsPage>

  a EventsPage containing the events

  #### Example

      [[include: snippet_GetConversationEvents.txt]]

  Overrides vonage.CombinedClientJS.getConversationEvents

### getConversationMember

- getConversationMember(cid, mid): Promise<Member>

- Get a Member of a Conversation

  #### Parameters

  - ##### cid: string

    the Conversation's id

  - ##### mid: string

    the Member's id

  #### Returns Promise<Member>

  the `Member`

  #### Example

      [[include: snippet_GetConversationMember.txt]]

  Inherited from vonage.CombinedClientJS.getConversationMember

### getConversationMembers

- getConversationMembers(id, parameters?): Promise<MembersPage>

- Get a Conversation's Members

  #### Parameters

  - ##### id: string

    the Conversation's id

  - ##### `Optional` parameters: Nullable<GetConversationMembersParameters>

    A GetConversationMembersParameters object containing the parameters for the request.

  #### Returns Promise<MembersPage>

  a `MembersPage` containing the members

  #### Example

      [[include: snippet_GetConversationMembers.txt]]

  Overrides vonage.CombinedClientJS.getConversationMembers

### getConversations

- getConversations(parameters?): Promise<ConversationsPage>

- Get a list of Conversations for the user.

  #### Parameters

  - ##### `Optional` parameters: Nullable<GetConversationsParameters>

    A GetConversationsParameters object containing the parameters for the request.

  #### Returns Promise<ConversationsPage>

  a `ConversationsPage` containing the conversations

  #### Example

      [[include: snippet_GetConversations.txt]]

  Overrides vonage.CombinedClientJS.getConversations

### inviteToConversation

- inviteToConversation(id, name): Promise<string>

- Invite a user to a Conversation by user's `name`

  #### Parameters

  - ##### id: string

    the Conversation's id

  - ##### name: string

    the name of the user to invite

  #### Returns Promise<string>

  the `memberId` of the member

  #### Example

      [[include: snippet_InviteToConversation.txt]]

  Overrides vonage.CombinedClientJS.inviteToConversation

### joinConversation

- joinConversation(id): Promise<string>

- Join a Conversation

  #### Parameters

  - ##### id: string

    the Conversation's id

  #### Returns Promise<string>

  the `memberId` of the member

  #### Example

      [[include: snippet_JoinConversation.txt]]

  Overrides vonage.CombinedClientJS.joinConversation

### leaveConversation

- leaveConversation(id): Promise<void>

- Leave a Conversation

  #### Parameters

  - ##### id: string

    the Conversation's id

  #### Returns Promise<void>

  void

  #### Example

      [[include: snippet_LeaveConversation.txt]]

  Overrides vonage.CombinedClientJS.leaveConversation

### sendCustomEvent

- sendCustomEvent(id, eventType, customData): Promise<string>

- Send a Custom event to a Conversation

  #### Parameters

  - ##### id: string

    the Conversation's id

  - ##### eventType: string

  - ##### customData: CustomData

    the body of the event

  #### Returns Promise<string>

  the `timestamp` of the message

  #### Example

      [[include: snippet_SendCustomEvent.txt]]

  Overrides vonage.CombinedClientJS.sendCustomEvent

### sendEphemeralEvent

- sendEphemeralEvent(id, customData): Promise<string>

- Send an ephemeral event to a Conversation

  #### Parameters

  - ##### id: string

    the Conversation's id

  - ##### customData: CustomData

    the body of the event

  #### Returns Promise<string>

  the `timestamp` of the message

  #### Example

      [[include: snippet_SendEphemeralEvent.txt]]

  Overrides vonage.CombinedClientJS.sendEphemeralEvent

### sendMessageAudioEvent

- sendMessageAudioEvent(id, audioUrl): Promise<string>

- Send a audio message to a Conversation.

  #### Parameters

  - ##### id: string

    the Conversation's id

  - ##### audioUrl: URL

    the url of the audio resource.

  #### Returns Promise<string>

  the `timestamp` of the message

  #### Example

      [[include: snippet_SendAudioMessage.txt]]

  Overrides vonage.CombinedClientJS.sendMessageAudioEvent

### sendMessageCustomEvent

- sendMessageCustomEvent(id, customData): Promise<string>

- Send a custom message to a Conversation

  #### Parameters

  - ##### id: string

    the Conversation's id

  - ##### customData: CustomData

    the body of the message

  #### Returns Promise<string>

  the `timestamp` of the message

  #### Example

      [[include: snippet_SendCustomMessage.txt]]

  Overrides vonage.CombinedClientJS.sendMessageCustomEvent

### sendMessageFileEvent

- sendMessageFileEvent(id, fileUrl): Promise<string>

- Send a file message to a Conversation.

  #### Parameters

  - ##### id: string

    the Conversation's id

  - ##### fileUrl: URL

    the url of the file resource.

  #### Returns Promise<string>

  the `timestamp` of the message

  #### Example

      [[include: snippet_SendFileMessage.txt]]

  Overrides vonage.CombinedClientJS.sendMessageFileEvent

### sendMessageImageEvent

- sendMessageImageEvent(id, imageUrl): Promise<string>

- Send a Image message to a Conversation.

  #### Parameters

  - ##### id: string

    the Conversation's id

  - ##### imageUrl: URL

    the url of the image resource.

  #### Returns Promise<string>

  the `timestamp` of the message

  #### Example

      [[include: snippet_SendImageMessage.txt]]

  Overrides vonage.CombinedClientJS.sendMessageImageEvent

### sendMessageLocationEvent

- sendMessageLocationEvent(id, location): Promise<string>

- Send a Location message to a Conversation.

  #### Parameters

  - ##### id: string

    the Conversation's id

  - ##### location: Location

    the description of the location.

  #### Returns Promise<string>

  the `timestamp` of the message

  #### Example

      [[include: snippet_SendLocationMessage.txt]]

  Overrides vonage.CombinedClientJS.sendMessageLocationEvent

### sendMessageSeenEvent

- sendMessageSeenEvent(id, conversationId): Promise<string>

- Send a message seen event to a Conversation

  #### Parameters

  - ##### id: number

    the event id

  - ##### conversationId: string

    the conversation id

  #### Returns Promise<string>

  the `timestamp` of the message

  #### Example

      [[include: snippet_SendMessageSeenEvent.txt]]

  Overrides vonage.CombinedClientJS.sendMessageSeenEvent

### sendMessageTemplateEvent

- sendMessageTemplateEvent(id, templateObject, whatsappObject): Promise<string>

- Send a template message to a Conversation.

  #### Parameters

  - ##### id: string

    the Conversation's id

  - ##### templateObject: Template

    the description(name and paramters) of the template.

  - ##### whatsappObject: Whatsapp

    the description(locale and policies of business account) of the location.

  #### Returns Promise<string>

  the `timestamp` of the message

  #### Example

      [[include: snippet_SendTemplateMessage.txt]]

  Overrides vonage.CombinedClientJS.sendMessageTemplateEvent

### sendMessageTextEvent

- sendMessageTextEvent(id, text, raw?): Promise<string>

- Send a text message to a Conversation

  #### Parameters

  - ##### id: string

    the Conversation's id

  - ##### text: string

    the Body of the message

  - ##### raw: boolean = false

    whether to send the text as raw or not (default: false, not recommended)

  #### Returns Promise<string>

  the `timestamp` of the message

  #### Example

      [[include: snippet_SendTextMessage.txt]]

  Overrides vonage.CombinedClientJS.sendMessageTextEvent

### sendMessageVCardEvent

- sendMessageVCardEvent(id, vCardUrl): Promise<string>

- Send a vcard message to a Conversation.

  #### Parameters

  - ##### id: string

    the Conversation's id

  - ##### vCardUrl: URL

    the url of the vCardUrl resource.

  #### Returns Promise<string>

  the `timestamp` of the message

  #### Example

      [[include: snippet_SendVcardMessage.txt]]

  Overrides vonage.CombinedClientJS.sendMessageVCardEvent

### sendMessageVideoEvent

- sendMessageVideoEvent(id, videoUrl): Promise<string>

- Send a Vidoe message to a Conversation.

  #### Parameters

  - ##### id: string

    the Conversation's id

  - ##### videoUrl: URL

    the url of the video resource.

  #### Returns Promise<string>

  the `timestamp` of the message

  #### Example

      [[include: snippet_SendVideoMessage.txt]]

  Overrides vonage.CombinedClientJS.sendMessageVideoEvent

## Voice

### answer

- answer(callId): Promise<void>

- Answer a call

  #### Parameters

  - ##### callId: string

    Call ID

  #### Returns Promise<void>

  void

  #### Example

      [[include: snippet_AnswerCall.txt]]

  Inherited from vonage.CombinedClientJS.answer

### disableEarmuff

- disableEarmuff(callId): Promise<void>

- Unearmuff your leg of a call

  #### Parameters

  - ##### callId: string

    Call ID

  #### Returns Promise<void>

  void

  #### Example

      [[include: snippet_DisableEarmuff.txt]]

  Inherited from vonage.CombinedClientJS.disableEarmuff

### enableEarmuff

- enableEarmuff(callId): Promise<void>

- Earmuff your leg of a call

  #### Parameters

  - ##### callId: string

    Call ID

  #### Returns Promise<void>

  void

  #### Example

      [[include: snippet_EnableEarmuff.txt]]

  Inherited from vonage.CombinedClientJS.enableEarmuff

### getAudioOutputElement

- getAudioOutputElement(): undefined | HTMLAudioElement
- `Experimental`

  Get the HTML Audio Element for the SDK. It can be used to route output to other devices.

  #### Returns undefined | HTMLAudioElement

  Overrides vonage.CombinedClientJS.getAudioOutputElement

### getCallLegs

- getCallLegs(callId, parameters?): Promise<LegsPage>

- Get a Call's Legs

  #### Parameters

  - ##### callId: string

  - ##### `Optional` parameters: Nullable<GetCallLegsParameters>

    A GetCallLegsParameters object containing the parameters for the request.

  #### Returns Promise<LegsPage>

  a `LegsPage` containing the legs

  #### Example

      [[include: snippet_GetCallLegs.txt]]

  Overrides vonage.CombinedClientJS.getCallLegs

### getLeg

- getLeg(legId): Promise<LegJS>

- Get the Leg for a call

  #### Parameters

  - ##### legId: string

    The Leg Id

  #### Returns Promise<LegJS>

  Overrides vonage.CombinedClientJS.getLeg

### getPeerConnection

- getPeerConnection(id): RTCPeerConnection
- `Experimental`

  Get the Peer Connection for a call

  #### Parameters

  - ##### id: string

    The Call Id

  #### Returns RTCPeerConnection

  Overrides vonage.CombinedClientJS.getPeerConnection

### hangup

- hangup(callId, reasonText?, reasonCode?): Promise<void>

- Hangup a call.

  #### Parameters

  - ##### callId: string

    the `callId` of the call to hangup

  - ##### `Optional` reasonText: string

    optional reason text to send to the other party

  - ##### `Optional` reasonCode: string

    optional reason code to send to the other party

  #### Returns Promise<void>

  void

  #### Example

      [[include: snippet_CallHangup.txt]]

  Overrides vonage.CombinedClientJS.hangup

### mute

- mute(callId): Promise<void>

- Mute your leg of a call

  #### Parameters

  - ##### callId: string

    Call ID

  #### Returns Promise<void>

  void

  #### Example

      [[include: snippet_Mute.txt]]

  Inherited from vonage.CombinedClientJS.mute

### reconnectCall

- reconnectCall(callId): Promise<void>

- Reconnect a call

  #### Parameters

  - ##### callId: string

    Call ID

  #### Returns Promise<void>

  void

  #### Example

      [[include: snippet_ReconnectCall.txt]]

  Inherited from vonage.CombinedClientJS.reconnectCall

### reject

- reject(callId): Promise<void>

- Reject a call

  #### Parameters

  - ##### callId: string

    Call ID

  #### Returns Promise<void>

  void

  #### Example

      [[include: snippet_RejectCall.txt]]

  Inherited from vonage.CombinedClientJS.reject

### say

- say(callId, text): Promise<void>

- Sends a TTS message to the Call

  #### Parameters

  - ##### callId: string

    the `callId` of the call to send the message to

  - ##### text: string

    the text to send

  #### Returns Promise<void>

  void

  Overrides vonage.CombinedClientJS.say

- say(callId, params): Promise<void>

- Sends a TTS message to the Call

  #### Parameters

  - ##### callId: string

    the `callId` of the call to send the message to

  - ##### params: CallSayParams

    the `CallSayParams` to send

  #### Returns Promise<void>

  void

  #### Example

      [[include: snippet_Say.txt]]

  Overrides vonage.CombinedClientJS.say

### sendDTMF

- sendDTMF(callId, digits): Promise<void>

- Send a string of digits to a call via DTMF

  #### Parameters

  - ##### callId: string

    Call ID

  - ##### digits: string

    DTMF digits

  #### Returns Promise<void>

  void

  #### Example

      [[include: snippet_Dtmf.txt]]

  Inherited from vonage.CombinedClientJS.sendDTMF

### serverCall

- serverCall(context?): Promise<string>

- Make a server call to the Vonage API. This is used to initiate a call using the Voice API and NCCO.

  #### Parameters

  - ##### `Optional` context: Json

    the context to send to the server passed as Custom data to the voice answer webhook

  #### Returns Promise<string>

  the `callId` of the call

  #### Example

      [[include: snippet_OutboundCall.txt]]

  Overrides vonage.CombinedClientJS.serverCall

### unmute

- unmute(callId): Promise<void>

- Unmute your leg of a call

  #### Parameters

  - ##### callId: string

    Call ID

  #### Returns Promise<void>

  void

  Inherited from vonage.CombinedClientJS.unmute