Skip to main content
Configuration types for creating and managing WhatsApp socket connections.

SocketConfig

Complete configuration object for makeWASocket().

Connection Settings

string | URL
required
The WebSocket URL to connect to WhatsApp serversDefault: 'wss://web.whatsapp.com/ws/chat'
number
required
Connection timeout in milliseconds. Fails if socket doesn’t connect within this time.Default: 20000 (20 seconds)
number | undefined
required
Default timeout for queries in milliseconds. undefined for no timeout.Default: 60000 (60 seconds)
number
required
Ping-pong interval for WebSocket connection in millisecondsDefault: 25000 (25 seconds)
Agent
Proxy agent for WebSocket connection
Agent
Agent used for HTTP fetch requests (uploading/downloading media)

Client Identification

WAVersion
required
WhatsApp Web version to connect withType: [number, number, number]Example: [2, 2323, 4]
WABrowserDescription
required
Browser identification sent to WhatsAppType: [string, string, string]Example: ['Baileys', 'Chrome', '1.0.0']
string
required
Alphanumeric country code for the number (e.g., ‘US’, ‘BR’, ‘IN’)

Authentication

AuthenticationState
required
Authentication state object containing credentials and keysSee AuthenticationState
TransactionCapabilityOptions
required
Options for SignalKeyStore transaction capability

Logging and Events

ILogger
required
Logger instance for debug output
boolean
required
Whether to emit events for actions done by this socket connectionDefault: true

History and Sync

boolean
required
Whether to ask the phone for full history (received asynchronously)Default: false
function
required
Control which history messages to sync
Return true to sync, false to skip
boolean
required
Whether to automatically fire initialization queriesDefault: true

Message Handling

function
required
Fetch a message from your store for retry logic
Required for handling “this message can take a while” issues
function
required
Optionally modify messages before sending
function
required
Determine if a JID should be ignored (no events, no decryption)

Media

MediaConnInfo['hosts']
required
Custom upload hosts for media
Width for link preview images in pixelsDefault: 192
Generate high quality link previews (uploads jpegThumbnail to WhatsApp)Default: false

Retry and Error Handling

number
required
Time to wait between sending retry requests in millisecondsDefault: 250
number
required
Maximum retry count for messagesDefault: 5
number
Time to wait for QR code generation in millisecondsDefault: 60000 (60 seconds)
boolean
required
Enable automatic session recreation for failed messagesDefault: false
boolean
required
Enable recent message caching for retry handlingDefault: false

Caching

CacheStore
Cache to store media to avoid re-uploadingSee CacheStore
CacheStore
Cache to track retry counts for failed messages
PossiblyExtendedCacheStore
Cache to store user device lists
CacheStore
Cache to store call offers
CacheStore
Cache to track placeholder resends
function
required
Fetch cached group metadata to speed up message sending

Advanced

boolean
required
Mark client as online when socket connectsDefault: true
object
required
Verify app state MACs
RequestInit
required
Options for HTTP fetch requests
function
required
Factory function for creating signal repositories

CacheStore

Interface for cache implementations used throughout Baileys.
function
required
Get a cached key
function
required
Set a key in the cache
function
required
Delete a key from the cache
function
required
Flush all data from cache

PossiblyExtendedCacheStore

Extended cache store with batch operations:
function
Get multiple keys at once
function
Set multiple keys at once
function
Delete multiple keys at once

Supporting Types

WAVersion

WABrowserDescription

PatchedMessageWithRecipientJID

Example Configuration