---
url: /apidocs/videochat_handshake.md
---
## Videochat handshake API

| Endpoint | Method | Description |
|-----|-----|-----|
| [videochat:requestDirectVideochat](#request-direct-videochat) | websocket | Request direct videochat |
| [videochat:invite](#invite-to-videochat) | websocket | Invite to videochat |
| [videochat:acceptVideochatRequest](#accept-videochat-request) | websocket | Accept videochat request |
| [videochat:declineVideochatRequest](#decline-videochat-request) | websocket | Decline videochat request |
| [videochat:mergeToVideochat](#merge-to-videochat) | websocket | Merge to videochat |
| [videochat:videochatRequested](#videochat-requested-event) | websocketEvent | Videochat requested event |
| [videochat:directVideochatRequestAccepted](#direct-videochat-request-accepted-event) | websocketEvent | Direct videochat request accepted event |
| [videochat:videochatAccepted](#videochat-accepted-event) | websocketEvent | Videochat accepted event |
| [videochat:videochatDeclined](#videochat-declined-event) | websocketEvent | Videochat declined event |

### Request direct videochat

**Method:** websocket

**Endpoint:** videochat:requestDirectVideochat

**Description:** Request direct videochat call with a user.

If opponent user not found, server will answer with error code 1021.

If opponent user is not available, server will answer with error code 10011.

If opponent user is available, server will answer with `videochatRequestId`, which is used for handshake operation.

**Request:**

**Response:**

### Invite to videochat

**Method:** websocket

**Endpoint:** videochat:invite

**Description:** Invite user to an existing videochat.

If opponent user not found, server will answer with error code 1021.

If opponent user is not available, server will answer with error code 10011.

If opponent user is available, server will send him an event to join videochat.

**Request:**

**Response:**

### Accept videochat request

**Method:** websocket

**Endpoint:** videochat:acceptVideochatRequest

**Description:** Accept incoming videochat call. This API could be requested only by opponent user who is receiving incoming videochat call.

**Request:**

**Response:**

### Decline videochat request

**Method:** websocket

**Endpoint:** videochat:declineVideochatRequest

**Description:** Decline videochat call. This API could be requested by both, initiator and opponent user.

**Request:**

**Response:**

### Merge to videochat

**Method:** websocket

**Endpoint:** videochat:mergeToVideochat

**Description:** If User A has incoming DIRECT call request (from User B) while in another videochat, he could merge User B to current videochat.

**Request:**

**Response:**

### Videochat requested event

**Event:** videochat:videochatRequested

**Description:** Opponent user will receive this event when he is requested to join videochat. User can accept or decline incoming call using `videochatRequestId`.

**Data:**

### Direct videochat request accepted event

**Event:** videochat:directVideochatRequestAccepted

**Description:** Direct videochat initiator user will receive this event when opponent user accepts the call.

**Data:**

### Videochat accepted event

**Event:** videochat:videochatAccepted

**Description:** Opponent user will receive this event in all his sockets (if has many) if he accepts the call. This way other sockets would know that the call is already accepted.

**Data:**

### Videochat declined event

**Event:** videochat:videochatDeclined

**Description:** Initiator user will receive this event when opponent user declines the call. Opponent user will receive this event in all his sockets (if has many) if he declines the call. This way other sockets would know that the call is already declined.

**Data:**

## Models

#### User Simple
