Calls SDKs JavaScript v1
Calls SDKs JavaScript
Calls SDKs
Version 1


Copy link

In order to use the features of the Calls SDK in your apps, user authentication with the Sendbird server must be initiated through the SendBirdCall.authenticate() method. To make or receive calls, the SendBirdCall instance should be connected with the Sendbird server. Connect socket by using the SendBirdCall.connectWebSocket() method after a user’s authentication has been completed.

Note: Even if your organization already uses Sendbird Chat, a separate user authentication is needed for Sendbird Calls.

Initialize the Calls SDK with APP_ID

Copy link

As shown below, the SendBirdCall instance must be initialized when a client app is launched. Initialization is done by using the APP_ID of your Sendbird application in the Dashboard. If the instance is initialized with a different APP_ID, all existing call-related data in a client app will be cleared and the SendBirdCall instance will be initialized again with the new APP_ID.

// Initialize SendBirdCall instance to use APIs in your app.

Authenticate to the Sendbird server

Copy link

In order to use the interfaces and methods provided in a SendBirdCall instance, a user must be connected to the Sendbird server by authentication. Without authentication, calling the methods of the Calls SDK will not work in a user’s client app. This means that if a user performs actions such as accepting an incoming call before authentication, the user will receive errors from the Sendbird server.

Using an access token

Copy link

Through our Chat Platform API, you can create a user using an access token. You can also issue an access token for an existing user.

// The USER_ID below should be unique to your Sendbird application.
SendBirdCall.authenticate({ userId: USER_ID, accessToken: ACCESS_TOKEN }, (result, error) => {
    if (error) {
        // Handle authentication failure.
    } else {
        // The user has been successfully authenticated and is connected to the Sendbird server.

// Establish websocket connection with the Sendbird server.
        /* Succeeded to connect*/
        /* Failed to connect */

Using a session token

Copy link

You can also use a session token instead of an access token to authenticate a user. Session tokens are a more secure option because they expire after a certain period whereas access tokens don't. See Chat Platform API guides for further explanation about the difference between access token and session token, how to issue a session token, and how to revoke all session tokens.

Note: Sendbird Calls is charged by minutes which starts as soon as the call is connected. It is recommended that you authenticate users for the Calls SDK at your earliest convenience.

Deauthenticate from the Sendbird server

Copy link

Deauthenticate a user from the Sendbird server using the SendBirdCall.deauthenticate() method. It will clear all current direct calls, session keys, and user information from a user’s client app. This can also be considered as logging out from the server.