# whatsapp-web.js 1.2.1-post » Class: Client

## Methods

acceptInvite(inviteCode)
archiveChat()
destroy()
getChatById(chatId)
getChats()

getContactById(contactId)
getContacts()
getState()
initialize()
resetState()

sendMessage(chatId, content, options)
sendSeen(chatId)
setStatus(status)
unarchiveChat()

## Events

auth_failure
authenticated
change_state
disconnected
group_join

group_leave
group_update
message
message_ack
message_create

message_revoke_everyone
message_revoke_me
qr
ready

## new Client()

Extends
  EventEmitter
Fires
  Client#event:qr
  Client#event:authenticated
  Client#event:auth_failure
  Client#event:ready
  Client#event:message
  Client#event:message_ack
  Client#event:message_create
  Client#event:message_revoke_me
  Client#event:message_revoke_everyone
  Client#event:group_join
  Client#event:group_leave
  Client#event:group_update
  Client#event:disconnected
  Client#event:change_state

## Methods

async

### acceptInvite(inviteCode)

Accepts an invitation to join a group

#### Parameter

Name | Type | Optional | Description
--- | --- | --- | ---
inviteCode | string |  | Invitation code

async

### archiveChat() → boolean

Enables and returns the archive state of the Chat

Returns

  `boolean`

async

### destroy()

Closes the client

async

### getChatById(chatId) → Promise containing Chat

Get chat instance by ID

#### Parameter

Name | Type | Optional | Description
--- | --- | --- | ---
chatId | string |  |

Returns

  `Promise containing Chat`

async

### getChats() → Promise containing Array of Chat

Get all current chat instances

Returns

  `Promise containing Array of Chat`

async

### getContactById(contactId) → Promise containing Contact

Get contact instance by ID

#### Parameter

Name | Type | Optional | Description
--- | --- | --- | ---
contactId | string |  |

Returns

  `Promise containing Contact`

async

### getContacts() → Promise containing Array of Contact

Get all current contact instances

Returns

  `Promise containing Array of Contact`

async

### getState() → WAState

Gets the current connection state for the client

Returns

  `WAState`

async

### initialize()

Sets up events and requirements, kicks off authentication request

async

### resetState()

Force reset of connection state for the client

async

### sendMessage(chatId, content, options) → Promise containing Message

Send a message to a specific chatId

#### Parameters

Name | Type | Optional | Description
--- | --- | --- | ---
chatId | string |  |
content | (string, MessageMedia, or Location) |  |
options | object |  |

Returns

  `Promise containing Message`

  Message that was just sent

async

### sendSeen(chatId) → Promise containing boolean

Mark as seen for the Chat

#### Parameter

Name | Type | Optional | Description
--- | --- | --- | ---
chatId | string |  |

Returns

  `Promise containing boolean`

  result

async

### setStatus(status)

Sets the current user's status message

#### Parameter

Name | Type | Optional | Description
--- | --- | --- | ---
status | string |  | New status message

async

### unarchiveChat() → boolean

Changes and returns the archive state of the Chat

Returns

  `boolean`

## Events

### auth_failure

Emitted when there has been an error while trying to restore an existing session

#### Parameter

Name | Type | Optional | Description
--- | --- | --- | ---
message | string |  |

### authenticated

Emitted when authentication is successful

#### Parameter

Name | Type | Optional | Description
--- | --- | --- | ---
session | object |  | Object containing session information. Can be used to restore the session.

### change_state

Emitted when the connection state changes

#### Parameter

Name | Type | Optional | Description
--- | --- | --- | ---
state | WAState |  | the new connection state

### disconnected

Emitted when the client has been disconnected

#### Parameter

Name | Type | Optional | Description
--- | --- | --- | ---
reason | WAState |  | state that caused the disconnect

### group_join

Emitted when a user joins the chat via invite link or is added by an admin.

#### Parameter

Name | Type | Optional | Description
--- | --- | --- | ---
notification | GroupNotification |  | GroupNotification with more information about the action

### group_leave

Emitted when a user leaves the chat or is removed by an admin.

#### Parameter

Name | Type | Optional | Description
--- | --- | --- | ---
notification | GroupNotification |  | GroupNotification with more information about the action

### group_update

Emitted when group settings are updated, such as subject, description or picture.

#### Parameter

Name | Type | Optional | Description
--- | --- | --- | ---
notification | GroupNotification |  | GroupNotification with more information about the action

### message

Emitted when a new message is received.

#### Parameter

Name | Type | Optional | Description
--- | --- | --- | ---
message | Message |  | The message that was received

### message_ack

Emitted when an ack event occurrs on message type.

#### Parameters

Name | Type | Optional | Description
--- | --- | --- | ---
message | Message |  | The message that was affected
ack | MessageAck |  | The new ACK value

### message_create

Emitted when a new message is created, which may include the current user's own messages.

#### Parameter

Name | Type | Optional | Description
--- | --- | --- | ---
message | Message |  | The message that was created

### message_revoke_everyone

Emitted when a message is deleted for everyone in the chat.

#### Parameters

Name | Type | Optional | Description
--- | --- | --- | ---
message | Message |  | The message that was revoked, in its current state. It will not contain the original message's data.
revoked_msg | Message |  | The message that was revoked, before it was revoked. It will contain the message's original data. Note that due to the way this data is captured, it may be possible that this param will be undefined. Value can be null.

### message_revoke_me

Emitted when a message is deleted by the current user.

#### Parameter

Name | Type | Optional | Description
--- | --- | --- | ---
message | Message |  | The message that was revoked

### qr

Emitted when the QR code is received

#### Parameter

Name | Type | Optional | Description
--- | --- | --- | ---
qr | string |  | QR Code

### ready

Emitted when the client has initialized and is ready to receive messages.