> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cognigy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# on

Adds an event listener for a specific event. See the [Event Reference](/click-to-call/sdk/event-reference/overview) for all available events.

## Signature

```typescript theme={null}
client.on<T extends EventName>(event: T, callback: EventCallback<T>): this;
```

## Parameters

| Parameter  | Type               | Description                                                | Required |
| ---------- | ------------------ | ---------------------------------------------------------- | -------- |
| `event`    | `EventName`        | The name of the event to listen for.                       | Yes      |
| `callback` | `EventCallback<T>` | The callback function to invoke when the event is emitted. | Yes      |

## Returns

`this` — the client instance, allowing method chaining.

## Example

```typescript theme={null}
client.on('answered', (session) => {
  console.log('Call answered:', session.id);
});

client.on('error', (error) => {
  console.error('SDK error:', error.message);
});
```

### Type-Safe Event Handling

```typescript theme={null}
import type { WebRTCClientEvents } from '@cognigy/click-to-call-sdk';

const handleAnswered: WebRTCClientEvents['answered'] = (session) => {
  console.log('Call answered:', session.id);
};

client.on('answered', handleAnswered);
```

## More Information

* [off](/click-to-call/sdk/api-reference/off)
* [Event Reference](/click-to-call/sdk/event-reference/overview)
* [WebRTCClientEvents](/click-to-call/sdk/api-reference/types#webrtcclientevents)
