Skip to main content

Overview

The SocketConfig interface defines all available configuration options for a Baileys WhatsApp Web socket connection. When using makeWASocket, you pass a UserFacingSocketConfig which is Partial<SocketConfig> with a required auth property.

Type Definition

Configuration Properties

Connection Settings

string | URL
default:"'wss://web.whatsapp.com/ws/chat'"
The WebSocket URL to connect to WhatsApp Web.
number
default:"20000"
Fails the connection if the socket times out in this interval (milliseconds).
number | undefined
default:"60000"
Default timeout for queries in milliseconds. Set to undefined for no timeout.
number
default:"30000"
Ping-pong interval for WebSocket connection (milliseconds).

Version & Browser

WAVersion
default:"[2, 3000, 1033846690]"
WhatsApp Web version to connect with. Type: [number, number, number]
WABrowserDescription
default:"Browsers.macOS('Chrome')"
Browser configuration as a tuple [OS, Browser, Version]. Use the Browsers constant for predefined configurations.

Network & Proxy

Agent
HTTPS proxy agent for the WebSocket connection.
Agent
Agent used for fetch requests when uploading/downloading media.

Logging

ILogger
default:"logger.child({ class: 'baileys' })"
Logger instance for debugging and logging. Compatible with Pino logger.

Authentication

AuthenticationState
required
Authentication state object to maintain the auth state. Use useMultiFileAuthState() to create this.

Events

boolean
default:"true"
Whether events should be emitted for actions done by this socket connection.

Media Settings

MediaConnInfo['hosts']
default:"[]"
Custom upload hosts to upload media to.
Width for link preview images in pixels.
Generate high quality link preview by uploading the jpegThumbnail to WhatsApp.

Retry & Error Handling

number
default:"250"
Time to wait between sending new retry requests (milliseconds).
number
default:"5"
Maximum retry count for failed messages.
boolean
default:"true"
Enable automatic session recreation for failed messages.
boolean
default:"true"
Enable recent message caching for retry handling.

QR Code & Pairing

number
Time to wait for the generation of the next QR code in milliseconds.
boolean
deprecated
This feature has been removed. Should the QR code be printed in the terminal.

History Sync

boolean
default:"true"
Whether Baileys should ask the phone for full history (will be received async).
(msg: proto.Message.IHistorySyncNotification) => boolean
Function to manage history processing. By default, syncs everything except FULL sync type.

Initialization

boolean
default:"true"
Whether Baileys should fire init queries automatically.
boolean
default:"true"
Marks the client as online whenever the socket successfully connects. Set to false to receive notifications in WhatsApp app.

Country Code

string
default:"'US'"
Alphanumeric country code (e.g., USA -> US) for the number used.

Caching

CacheStore
Cache to store media, so it doesn’t have to be re-uploaded.
CacheStore
Map to store retry counts for failed messages; used to determine whether to retry a message.
PossiblyExtendedCacheStore
Cache to store a user’s device list.
CacheStore
Cache to store call offers.
CacheStore
Cache to track placeholder resends.

Message Handling

(jid: string) => boolean | undefined
default:"() => false"
Function that returns if a JID should be ignored. No event for that JID will be triggered and messages from that JID will not be decrypted.
Function
default:"msg => msg"
Optionally patch the message before sending out.
Full signature:
(key: WAMessageKey) => Promise<proto.IMessage | undefined>
default:"async () => undefined"
Fetch a message from your store. Implement this so that messages that failed to send can be retried. This solves the “this message can take a while” issue.

Group Metadata

(jid: string) => Promise<GroupMetadata | undefined>
default:"async () => undefined"
Cached group metadata function to prevent redundant requests to WhatsApp and speed up message sending. Highly recommended for group usage.

Security & Verification

object
default:"{ patch: false, snapshot: false }"
Verify app state MACs for enhanced security.

Signal Repository

TransactionCapabilityOptions
Transaction capability options for SignalKeyStore.
Function
default:"makeLibSignalRepository"
Function to create signal repository.
Full signature:

HTTP Options

RequestInit
default:"{}"
Options for HTTP fetch requests.

Deprecated Options

boolean
deprecated
This feature has been removed. Should Baileys use the mobile API instead of the multi-device API.

CacheStore Interface

PossiblyExtendedCacheStore Interface

Complete Example

See Also