All classes live under the Pam\WhatsApp namespace. This page covers version 1.2.0. The package maps every public symbol and member of whatsapp-web.js 1.34.7 (81 symbols and 670 members), recorded in its api-matrix.json; the most important surface is listed here.
| Method |
Description |
new Client(?ClientOptions $options = null) |
Creates a client backed by a browser session. Nothing launches yet. |
Client::launch(?ClientOptions $options = null) |
Creates a client and launches the browser immediately. |
Client::forSession(Session $session) |
Creates a client over any Contract\Session, for tests. |
initialize() |
Opens WhatsApp Web and starts authentication. Can be called once. |
run() |
Pumps events until the state is Closed or Failed. |
pump(float $timeoutSeconds = 1.0) |
Handles pending events for up to the timeout; returns bool. |
reconnect() |
Schedules a reconnect after the client closed or failed. |
destroy() / close() |
Closes the browser and keeps the saved session. |
logout() |
Unlinks the device and deletes the saved session. |
diagnoseSession() |
Returns SessionDiagnostics. |
Read-only properties: state (ClientState), info (?ClientInfo), interface (?InterfaceController), pupBrowser (?Pam\Browser\Browser), and pupPage (?Pam\Browser\Page).
| Option |
Type |
Default |
authStrategy |
?AuthStrategy |
null |
sessionDirectory |
?string |
null (cannot be combined with authStrategy) |
browserExecutable |
?string |
null |
headless |
bool |
true |
browserTimeoutSeconds |
float |
30.0 |
authenticationTimeoutSeconds |
float |
60.0 |
authTimeoutMs |
?int |
null (overrides the previous option) |
browserArguments |
list<string> |
[] |
browserName |
?string |
null (Chrome, Firefox, IE, Opera, Safari, or Edge) |
deviceName |
?string |
null |
bypassCSP |
bool |
false |
evalOnNewDoc |
?string |
null |
ffmpegPath |
string |
'ffmpeg' |
pairWithPhoneNumber |
?PairWithPhoneNumber |
null |
proxyAuthentication |
?ProxyAuthentication |
null |
puppeteer |
?Pam\Browser\Chromium\LaunchOptions |
null |
qrMaxRetries |
int |
0 (unlimited) |
takeoverOnConflict |
bool |
false |
takeoverTimeoutMs |
int |
0 |
userAgent |
?string |
null |
webVersion |
?string |
a pinned WhatsApp Web build |
webVersionCache |
?WebVersionCacheOptions |
new LocalWebCacheOptions() |
session |
?Contract\Session |
null |
autoReconnect |
bool |
false |
reconnectMaxAttempts |
int |
3 (1 to 10) |
reconnectDelayMs |
int |
1000 |
logger |
?Closure(LogLevel, string, array) |
null |
browserName and deviceName control how the linked device is labelled in Linked devices on the phone.
| Class |
Options |
Auth\NoAuth |
None. |
Auth\LocalAuth |
LocalAuthOptions(clientId: ?string, dataPath: ?string, rmMaxRetries: int = 4) |
Auth\RemoteAuth |
RemoteAuthOptions(store: RemoteStore, backupSyncIntervalMs: int, clientId: ?string, dataPath: ?string, rmMaxRetries: int = 4) |
| Class |
What it represents |
Message |
A message, with reply(), edit(), delete(), forward(), react(), downloadMedia(), downloadMediaStream(), and more. |
Chat, PrivateChat, GroupChat |
Conversations. GroupChat adds participant and settings management. |
Channel |
A WhatsApp channel (newsletter). |
Contact, PrivateContact, BusinessContact |
People and businesses. |
MessageMedia |
Media content: fromFilePath(), fromUrl(), or the constructor. |
Location, Poll, ContactList, ScheduledEvent |
Rich content you can send. |
Label, Broadcast, Call, Reaction, PollVote |
Other WhatsApp objects. |
TerminalQrCode |
render(string $data, string $indent = ' ') draws a QR code for terminals. |
| Enum |
Cases |
ClientState |
Created, Initializing, AwaitingAuthentication, Ready, Closed, Failed |
ConnectionState |
Connected, Opening, Pairing, Timeout, Unlaunched, Unpaired, UnpairedIdle, Conflict, DeprecatedVersion, ProxyBlock, TosBlock, SmbaTosBlock, Unknown |
DisconnectionReason |
Logout, Conflict, Unlaunched, QrRetryLimit |
MessageAck |
Error, Pending, Server, Device, Read, Played |
LogLevel |
Debug, Info, Warning, Error |
EventType |
See Events. |
All enums are integer-backed.
| Exception |
Thrown when |
Exception\WhatsAppException |
Base class of OperationException, ContactNotFoundException, and BridgeException. Extends RuntimeException. |
Exception\OperationException |
A send or reconnect failed after its last attempt. Has operation, target, attempt. |
Exception\ContactNotFoundException |
A phone number is not registered on WhatsApp. Has phoneNumber. |
Exception\BridgeException |
The bridge produced invalid data, or a listener threw while handling an event. |
Exception\VersionResolveException |
The requested WhatsApp Web version could not be resolved. Extends RuntimeException directly. |
Invalid arguments, such as a malformed phone number or out-of-range option, throw InvalidArgumentException. Calling a sending method before the client is ready throws LogicException.