> ## 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.

# connect

Connects to the SIP server and registers the client. This method fetches the SIP configuration from the endpoint URL, validates the widget is active, initializes the SIP user agent, and waits for both WebSocket connection and SIP registration to complete (with a 15-second timeout). This must be called before [`startCall()`](/click-to-call/sdk/api-reference/start-call).

## Signature

```typescript theme={null}
await client.connect();
```

## Parameters

None.

## Returns

`Promise<void>`

## Throws

An error if the client has been destroyed, the configuration fetch fails, the Click To Call widget is not active, or the SIP connection or registration fails (15-second timeout).

## Example

```typescript theme={null}
await client.connect();
console.log('Connected and registered');
```

### With Error Handling

```typescript theme={null}
try {
  await client.connect();
  console.log('Connected and registered');
} catch (error) {
  console.error('Failed to connect:', error.message);
}
```

## More Information

* [disconnect](/click-to-call/sdk/api-reference/disconnect)
* [connectAndCall](/click-to-call/sdk/api-reference/connect-and-call)
* [startCall](/click-to-call/sdk/api-reference/start-call)
* [registered](/click-to-call/sdk/event-reference/registered) event
