> For a complete documentation index, fetch https://docs.voximplant.ai/llms.txt

# Call (interface)

[Call](/api-reference/websdk5/call/overview)

Interface that represents a call and provides the API to manage it.

**Methods**

* [addEventListener](/api-reference/websdk5/call/call#addeventlistener)
* [addStream](/api-reference/websdk5/call/call#addstream)
* [answer](/api-reference/websdk5/call/call#answer)
* [hangup](/api-reference/websdk5/call/call#hangup)
* [hold](/api-reference/websdk5/call/call#hold)
* [muteMicrophone](/api-reference/websdk5/call/call#mutemicrophone)
* [reject](/api-reference/websdk5/call/call#reject)
* [removeEventListener](/api-reference/websdk5/call/call#removeeventlistener)
* [removeStream](/api-reference/websdk5/call/call#removestream)
* [replaceStream](/api-reference/websdk5/call/call#replacestream)
* [sendDTMF](/api-reference/websdk5/call/call#senddtmf)
* [sendInfo](/api-reference/websdk5/call/call#sendinfo)
* [sendMessage](/api-reference/websdk5/call/call#sendmessage)
* [start](/api-reference/websdk5/call/call#start)
* [startScreenSharing](/api-reference/websdk5/call/call#startscreensharing)
* [stopScreenSharing](/api-reference/websdk5/call/call#stopscreensharing)
* [toggleMicrophone](/api-reference/websdk5/call/call#togglemicrophone)
* [unmuteMicrophone](/api-reference/websdk5/call/call#unmutemicrophone)

**Properties**

* [destination](/api-reference/websdk5/call/call#destination)
* [direction](/api-reference/websdk5/call/call#direction)
* [duration](/api-reference/websdk5/call/call#duration)
* [hasScreenSharing](/api-reference/websdk5/call/call#hasscreensharing)
* [id](/api-reference/websdk5/call/call#id)
* [isMicrophoneMuted](/api-reference/websdk5/call/call#ismicrophonemuted)
* [isOnHold](/api-reference/websdk5/call/call#isonhold)
* [isVideoEnabled](/api-reference/websdk5/call/call#isvideoenabled)
* [localStreams](/api-reference/websdk5/call/call#localstreams)
* [remoteDisplayName](/api-reference/websdk5/call/call#remotedisplayname)
* [remoteSipUri](/api-reference/websdk5/call/call#remotesipuri)
* [remoteStreams](/api-reference/websdk5/call/call#remotestreams)
* [state](/api-reference/websdk5/call/call#state)
* [videoSendingStatus](/api-reference/websdk5/call/call#videosendingstatus)

## Methods

### addEventListener

`addEventListener(eventName: `[`CallEvent`](/api-reference/websdk5/call/callevents/callevent)`, listener: (event: `[`AnyCallEvent`](/api-reference/websdk5/call/callevents/anycallevent)`) => void | Promise<void>, options: `[`ListenerOptions`](/api-reference/websdk5/core/listeneroptions)`): void`

Registers a handler for the specified event.

One event can have more than one handler; handlers are executed in order of their registration.

**Parameters**

| Parameter   | Type                                                                                                        | Requirement | Description                                                                   |
| ----------- | ----------------------------------------------------------------------------------------------------------- | ----------- | ----------------------------------------------------------------------------- |
| `eventName` | [`CallEvent`](/api-reference/websdk5/call/callevents/callevent)                                             | Required    | Event name                                                                    |
| `listener`  | `(event: `[`AnyCallEvent`](/api-reference/websdk5/call/callevents/anycallevent)`) => void \| Promise<void>` | Required    | Handler function that is triggered when an event of the specified type occurs |
| `options`   | [`ListenerOptions`](/api-reference/websdk5/core/listeneroptions)                                            | Required    | Object that specifies characteristics about the event listener                |

**Returns:** void

### addStream

`addStream(stream: `[`LocalStream`](/api-reference/websdk5/stream/localstream)`): Promise<void>`

Starts sending an audio or video stream to the call.

If a video stream is added to a call that was originally started as audio only,
the remote participant receives the [CallEvent.CallUpgrade](/api-reference/websdk5/call/callevents/callevent#callupgrade) event
and can accept or reject the request to switch the call to video.

Returns a promise that is resolved when the operation is completed.

**Parameters**

| Parameter | Type                                                       | Requirement | Description           |
| --------- | ---------------------------------------------------------- | ----------- | --------------------- |
| `stream`  | [`LocalStream`](/api-reference/websdk5/stream/localstream) | Required    | Audio or video stream |

**Returns:** Promise\<void>

**Throws**

* [CallWrongStateError](/api-reference/websdk5/call/errors/callwrongstateerror) — if the call is in the [CallState.Failed](/api-reference/websdk5/call/callstate#failed),
  [CallState.Disconnecting](/api-reference/websdk5/call/callstate#disconnecting), or [CallState.Disconnected](/api-reference/websdk5/call/callstate#disconnected) state
* [StreamTypeMismatchError](/api-reference/websdk5/core/sharederrors/streamtypemismatcherror) — if the stream is of the [StreamType.ScreenVideo](/api-reference/websdk5/stream/streamtype#screenvideo) type
* [CallOnHoldError](/api-reference/websdk5/call/errors/callonholderror) — if the call is currently on hold
* [InactiveStreamError](/api-reference/websdk5/core/sharederrors/inactivestreamerror) — if the stream is not [active](https://developer.mozilla.org/en-US/docs/Web/API/MediaStream/active)
* [StreamUpdateFailedError](/api-reference/websdk5/core/sharederrors/streamupdatefailederror) — if the operation has failed

### answer

`answer(settings?: `[`CallSettings`](/api-reference/websdk5/call/callsettings)`): Promise<void>`

Answers the call. This method should be used only for incoming calls.

Calling this method initiates the connection process. One of the following events
is triggered as a result:

* [CallEvent.Connected](/api-reference/websdk5/call/callevents/callevent#connected) is triggered when the call connects successfully.
* [CallEvent.Failed](/api-reference/websdk5/call/callevents/callevent#failed) is triggered if the call fails to connect.

Returns a promise that is resolved if the call connection process has started successfully. A resolved promise
does not mean that the call is connected. You should subscribe to [CallEvent.Connected](/api-reference/websdk5/call/callevents/callevent#connected) to be
notified that the call is established.

**Parameters**

| Parameter  | Type                                                       | Requirement | Description                                                                                                        |
| ---------- | ---------------------------------------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------ |
| `settings` | [`CallSettings`](/api-reference/websdk5/call/callsettings) | Optional    | Call settings with additional call parameters, such as the preferred video codec, custom data, extra headers, etc. |

**Returns:** Promise\<void>

**Throws**

* [CallWrongDirectionError](/api-reference/websdk5/call/errors/callwrongdirectionerror) — if the method is called for an outgoing call
* [CallWrongStateError](/api-reference/websdk5/call/errors/callwrongstateerror) — if the call is in a state different from [CallState.Created](/api-reference/websdk5/call/callstate#created) or [CallState.Reconnecting](/api-reference/websdk5/call/callstate#reconnecting)
* [CallInternalError](/api-reference/websdk5/call/errors/callinternalerror) — if the operation has failed

### hangup

`hangup(headers?: Record<string, string>): void`

Terminates the call.

The following events are triggered depending on the call state:

* [CallEvent.Disconnected](/api-reference/websdk5/call/callevents/callevent#disconnected) is triggered on this call.
* [CallEvent.Disconnected](/api-reference/websdk5/call/callevents/callevent#disconnected) is triggered on the remote participant side if the call has connected.
* [CallEvent.Disconnected](/api-reference/websdk5/call/callevents/callevent#disconnected) is triggered on the callee side if an outgoing call is still connecting.
* [CallEvent.Failed](/api-reference/websdk5/call/callevents/callevent#failed) is triggered on the caller side if an incoming call has not been answered.

**Parameters**

| Parameter | Type                     | Requirement | Description                                                                                                       |
| --------- | ------------------------ | ----------- | ----------------------------------------------------------------------------------------------------------------- |
| `headers` | `Record<string, string>` | Optional    | Optional set of headers to send to the Voximplant Cloud. Names should begin with “X-” to be processed by the SDK. |

**Returns:** void

### hold

`hold(enable: boolean): Promise<void>`

Holds or unholds the call.

Returns a promise that is resolved when the operation is completed.

**Parameters**

| Parameter | Type      | Requirement | Description                        |
| --------- | --------- | ----------- | ---------------------------------- |
| `enable`  | `boolean` | Required    | Whether to hold or unhold the call |

**Returns:** Promise\<void>

**Throws**

* [CallWrongStateError](/api-reference/websdk5/call/errors/callwrongstateerror) — if the call is not in the [CallState.Connected](/api-reference/websdk5/call/callstate#connected) state
* [CallOnHoldError](/api-reference/websdk5/call/errors/callonholderror) on the attempt to hold the call that is already on hold
* [CallNotOnHoldError](/api-reference/websdk5/call/errors/callnotonholderror) on the attempt to resume the call that is currently not on hold
* [CallInternalError](/api-reference/websdk5/call/errors/callinternalerror) — if the operation has failed

### muteMicrophone

`muteMicrophone(): void`

Mutes the audio in the call.

**Returns:** void

### reject

`reject(rejectMode: `[`RejectMode`](/api-reference/websdk5/call/rejectmode)`, headers?: Record<string, string>): void`

Rejects an incoming call.

Calling this method terminates the incoming call attempt. The following events are triggered as a result:

* [CallEvent.Disconnected](/api-reference/websdk5/call/callevents/callevent#disconnected) is triggered on the callee side.
* [CallEvent.Failed](/api-reference/websdk5/call/callevents/callevent#failed) is triggered on the caller side.

**Parameters**

| Parameter    | Type                                                   | Requirement | Description                                                                                                       |
| ------------ | ------------------------------------------------------ | ----------- | ----------------------------------------------------------------------------------------------------------------- |
| `rejectMode` | [`RejectMode`](/api-reference/websdk5/call/rejectmode) | Required    | Call rejection mode                                                                                               |
| `headers`    | `Record<string, string>`                               | Optional    | Optional set of headers to send to the Voximplant Cloud. Names should begin with “X-” to be processed by the SDK. |

**Returns:** void

**Throws**

[CallWrongDirectionError](/api-reference/websdk5/call/errors/callwrongdirectionerror) If the method is called for an outgoing call.

### removeEventListener

`removeEventListener(eventName: `[`CallEvent`](/api-reference/websdk5/call/callevents/callevent)`, listener: (event: `[`AnyCallEvent`](/api-reference/websdk5/call/callevents/anycallevent)`) => void | Promise<void>): void`

Removes a previously registered handler for the specified event.

**Parameters**

| Parameter   | Type                                                                                                        | Requirement | Description                                      |
| ----------- | ----------------------------------------------------------------------------------------------------------- | ----------- | ------------------------------------------------ |
| `eventName` | [`CallEvent`](/api-reference/websdk5/call/callevents/callevent)                                             | Required    | Event name                                       |
| `listener`  | `(event: `[`AnyCallEvent`](/api-reference/websdk5/call/callevents/anycallevent)`) => void \| Promise<void>` | Required    | Handler function to remove from the event target |

**Returns:** void

### removeStream

`removeStream(stream: `[`LocalStream`](/api-reference/websdk5/stream/localstream)`): Promise<void>`

Stops sending audio or video stream to the call.

Returns a promise that is resolved when the operation is completed.

**Parameters**

| Parameter | Type                                                       | Requirement | Description |
| --------- | ---------------------------------------------------------- | ----------- | ----------- |
| `stream`  | [`LocalStream`](/api-reference/websdk5/stream/localstream) | Required    |             |

**Returns:** Promise\<void>

**Throws**

* [CallWrongStateError](/api-reference/websdk5/call/errors/callwrongstateerror) — if the call is in the [CallState.Failed](/api-reference/websdk5/call/callstate#failed),
  [CallState.Disconnecting](/api-reference/websdk5/call/callstate#disconnecting), or [CallState.Disconnected](/api-reference/websdk5/call/callstate#disconnected) state
* [StreamTypeMismatchError](/api-reference/websdk5/core/sharederrors/streamtypemismatcherror) — if the stream is of the [StreamType.ScreenAudio](/api-reference/websdk5/stream/streamtype#screenaudio) or [StreamType.ScreenVideo](/api-reference/websdk5/stream/streamtype#screenvideo) type
* [CallOnHoldError](/api-reference/websdk5/call/errors/callonholderror) — if the call is currently on hold
* [StreamUpdateFailedError](/api-reference/websdk5/core/sharederrors/streamupdatefailederror) — if the operation has failed

### replaceStream

`replaceStream(stream: `[`LocalStream`](/api-reference/websdk5/stream/localstream)`, oldStream?: `[`LocalStream`](/api-reference/websdk5/stream/localstream)`): Promise<void>`

Replaces the local audio or video stream that is currently being sent to the call with another local audio or video stream.

Returns a promise that is resolved when the operation is completed.

**Parameters**

| Parameter   | Type                                                       | Requirement | Description       |
| ----------- | ---------------------------------------------------------- | ----------- | ----------------- |
| `stream`    | [`LocalStream`](/api-reference/websdk5/stream/localstream) | Required    | New local stream  |
| `oldStream` | [`LocalStream`](/api-reference/websdk5/stream/localstream) | Optional    | Stream to replace |

**Returns:** Promise\<void>

**Throws**

* [CallWrongStateError](/api-reference/websdk5/call/errors/callwrongstateerror) — if the call is in the [CallState.Failed](/api-reference/websdk5/call/callstate#failed),
  [CallState.Disconnecting](/api-reference/websdk5/call/callstate#disconnecting), or [CallState.Disconnected](/api-reference/websdk5/call/callstate#disconnected) state
* [StreamTypeMismatchError](/api-reference/websdk5/core/sharederrors/streamtypemismatcherror) — if the stream is of [StreamType.ScreenAudio](/api-reference/websdk5/stream/streamtype#screenaudio) or [StreamType.ScreenVideo](/api-reference/websdk5/stream/streamtype#screenvideo) type
* [InactiveStreamError](/api-reference/websdk5/core/sharederrors/inactivestreamerror) — if the stream is not [active](https://developer.mozilla.org/en-US/docs/Web/API/MediaStream/active)
* [StreamUpdateFailedError](/api-reference/websdk5/core/sharederrors/streamupdatefailederror) — if the operation has failed

### sendDTMF

`sendDTMF(tones: string): void`

Sends DTMF(s) within the call.

**Parameters**

| Parameter | Type     | Requirement | Description |
| --------- | -------- | ----------- | ----------- |
| `tones`   | `string` | Required    | DTMF(s)     |

**Returns:** void

**Throws**

[InvalidArgumentsError](/api-reference/websdk5/core/sharederrors/invalidargumentserror) if the tones parameter is an empty string

### sendInfo

`sendInfo(mimeType: ${string}/${string}, body: string, headers?: Record<string, string>): void`

Sends an INFO message within the call.

**Parameters**

| Parameter  | Type                     | Requirement | Description                                                                                                   |
| ---------- | ------------------------ | ----------- | ------------------------------------------------------------------------------------------------------------- |
| `mimeType` | `${string}/${string}`    | Required    | MIME type of the info                                                                                         |
| `body`     | `string`                 | Required    | Custom string data                                                                                            |
| `headers`  | `Record<string, string>` | Optional    | Optional set of headers to be sent with the message. Names should begin with “X-” to be processed by the SDK. |

**Returns:** void

**Throws**

[InvalidMimeTypeError](/api-reference/websdk5/core/sharederrors/invalidmimetypeerror) if the provided mimeType is in an invalid format

### sendMessage

`sendMessage(message: string): void`

Sends a message within the call.

Implemented atop of SIP INFO for communication between the call endpoint and the Voximplant Cloud.

**Parameters**

| Parameter | Type     | Requirement | Description  |
| --------- | -------- | ----------- | ------------ |
| `message` | `string` | Required    | Message text |

**Returns:** void

### start

`start(): Promise<void>`

Starts the call. This method should be used only for outgoing calls.

Calling this method initiates the call setup. The following events may be triggered as a result:

* [CallEvent.StartRinging](/api-reference/websdk5/call/callevents/callevent#startringing) is triggered when the remote participant's device starts ringing.
* [CallEvent.Connected](/api-reference/websdk5/call/callevents/callevent#connected) is triggered when the call connects successfully.
* [CallEvent.Failed](/api-reference/websdk5/call/callevents/callevent#failed) is triggered if the call fails to connect, including when the callee rejects the call.

Returns a promise that is resolved if the call connection process has started successfully. A resolved promise
does not mean that the call is connected. You should subscribe to [CallEvent.Connected](/api-reference/websdk5/call/callevents/callevent#connected) to be
notified that the call is established.

**Returns:** Promise\<void>

**Throws**

* [CallWrongDirectionError](/api-reference/websdk5/call/errors/callwrongdirectionerror) — if the method is called for an incoming call
* [CallWrongStateError](/api-reference/websdk5/call/errors/callwrongstateerror) — if the call is in a state different from [CallState.Created](/api-reference/websdk5/call/callstate#created) or [CallState.Reconnecting](/api-reference/websdk5/call/callstate#reconnecting)

### startScreenSharing

`startScreenSharing(stream: `[`LocalScreenSharingStream`](/api-reference/websdk5/stream/localscreensharingstream)`[]): Promise<void>`

Starts sending a screen sharing stream to the call.

Returns a promise that is resolved when the operation is completed.

**Parameters**

| Parameter | Type                                                                                     | Requirement | Description                     |
| --------- | ---------------------------------------------------------------------------------------- | ----------- | ------------------------------- |
| `stream`  | [`LocalScreenSharingStream`](/api-reference/websdk5/stream/localscreensharingstream)`[]` | Required    | Array of screen sharing streams |

**Returns:** Promise\<void>

**Throws**

* [CallWrongStateError](/api-reference/websdk5/call/errors/callwrongstateerror) — if the call is not in the [CallState.Connected](/api-reference/websdk5/call/callstate#connected) state
* [CallOnHoldError](/api-reference/websdk5/call/errors/callonholderror) — if the call is currently on hold
* [InactiveStreamError](/api-reference/websdk5/core/sharederrors/inactivestreamerror) — if the stream is not [active](https://developer.mozilla.org/en-US/docs/Web/API/MediaStream/active)
* [StreamUpdateFailedError](/api-reference/websdk5/core/sharederrors/streamupdatefailederror) — if the operation has failed or the screen sharing is already being sent to the call

### stopScreenSharing

`stopScreenSharing(): Promise<void>`

Stops sending a screen sharing stream to the call.

Returns a promise that is resolved when the operation is completed.

**Returns:** Promise\<void>

**Throws**

* [CallWrongStateError](/api-reference/websdk5/call/errors/callwrongstateerror) — if the call is not in the [CallState.Connected](/api-reference/websdk5/call/callstate#connected) state
* [CallOnHoldError](/api-reference/websdk5/call/errors/callonholderror) — if the call is currently on hold
* [StreamUpdateFailedError](/api-reference/websdk5/core/sharederrors/streamupdatefailederror) — if the operation has failed or the screen sharing is not currently being sent

### toggleMicrophone

`toggleMicrophone(): boolean`

Toggles the audio mute status in the call.

**Returns:** boolean

### unmuteMicrophone

`unmuteMicrophone(): void`

Unmutes the audio in the call.

**Returns:** void

## Properties

### destination

`destination: string`

Destination that the call has been created with.

### direction

`direction: `[`CallDirection`](/api-reference/websdk5/call/calldirection)

Call direction.

### duration

`duration: number`

Call duration in milliseconds.

### hasScreenSharing

`hasScreenSharing: `[`ReadonlyWatchable`](/api-reference/websdk5/core/watchable/readonlywatchable)`<boolean>`

Watchable property that allows getting the screen sharing sending status and observing its changes.

### id

`id: string`

Call id.

### isMicrophoneMuted

`isMicrophoneMuted: `[`ReadonlyWatchable`](/api-reference/websdk5/core/watchable/readonlywatchable)`<boolean>`

Watchable property that allows getting the audio mute status and observing its changes.

### isOnHold

`isOnHold: `[`ReadonlyWatchable`](/api-reference/websdk5/core/watchable/readonlywatchable)`<boolean>`

Watchable property that allows getting whether the call is on hold.

### isVideoEnabled

`isVideoEnabled: `[`ReadonlyWatchable`](/api-reference/websdk5/core/watchable/readonlywatchable)`<boolean>`

Watchable property that indicates whether the video is enabled and allows observing its changes.

### localStreams

`localStreams: `[`ReadonlyWatchable`](/api-reference/websdk5/core/watchable/readonlywatchable)`<Set<`[`LocalStream`](/api-reference/websdk5/stream/localstream)`>>`

Watchable property that allows getting the array of the local audio and video streams that are currently being sent.

### remoteDisplayName

`remoteDisplayName: `[`ReadonlyWatchable`](/api-reference/websdk5/core/watchable/readonlywatchable)`<null | string>`

Watchable property that allows getting the call participant user display name and observing its changes.

Null for outgoing calls until the [CallEvent.Connected](/api-reference/websdk5/call/callevents/callevent#connected) event is triggered.

### remoteSipUri

`remoteSipUri: `[`ReadonlyWatchable`](/api-reference/websdk5/core/watchable/readonlywatchable)`<null | string>`

Watchable property that allows getting the call participant sip URI and observing its changes.

Null for outgoing calls until the [CallEvent.Connected](/api-reference/websdk5/call/callevents/callevent#connected) event is triggered.

### remoteStreams

`remoteStreams: `[`ReadonlyWatchable`](/api-reference/websdk5/core/watchable/readonlywatchable)`<Set<`[`RemoteStream`](/api-reference/websdk5/stream/remotestream)`>>`

Watchable property that allows getting the array of the remote audio and video streams that are currently being received.

### state

`state: `[`ReadonlyWatchable`](/api-reference/websdk5/core/watchable/readonlywatchable)`<`[`CallState`](/api-reference/websdk5/call/callstate)`>`

Watchable property that allows getting the current call state and observing its changes.

### videoSendingStatus

`videoSendingStatus: `[`ReadonlyWatchable`](/api-reference/websdk5/core/watchable/readonlywatchable)`<`[`VideoSendingStatus`](/api-reference/websdk5/call/videosendingstatus)`>`

Watchable property indicating the current sending status of the local video stream.

This property holds one of the following values:

* [VideoSendingStatus.Sending](/api-reference/websdk5/call/videosendingstatus#sending): A local video stream is being sent.
* [VideoSendingStatus.NotSending](/api-reference/websdk5/call/videosendingstatus#notsending): No local video is being sent.
* [VideoSendingStatus.Pending](/api-reference/websdk5/call/videosendingstatus#pending): A video stream is currently being added, removed, or replaced via the
  [Call.addStream](/api-reference/websdk5/call/call#addstream), [Call.removeStream](/api-reference/websdk5/call/call#removestream), or [Call.replaceStream](/api-reference/websdk5/call/call#replacestream) API.

The initial status when the call is connected is available in the
[CallEvent.Connected](/api-reference/websdk5/call/callevents/callevent#connected) event payload.

**Since:** 5.2.0