You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/api-reference.mdx
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,6 +53,7 @@ client.on('text', (ctx) => {
53
53
|`pin(key, opts?)`|`(key, opts?: { duration?: number }): Promise<WAMessageKey>`| Pin a message (`duration` seconds; defaults 86400). |
54
54
|`unpin(key)`|`(key): Promise<WAMessageKey>`| Unpin a message. |
55
55
|`setDisappearing(jid, seconds)`|`(jid: string, seconds: number): Promise<void>`| Set the chat's disappearing-message timer. |
56
+
|`rejectCall(call \| callId, from?)`|`(call: CallPayload \| string, from?: string): Promise<void>`| 🔗 Reject an incoming call. Accepts the `call-incoming` payload or raw `callId` + caller jid. Throws `UNSUPPORTED_ON_CLOUD` on the cloud provider. See [`autoRejectCall`](/configuration#autorejectcall). |
56
57
|`lidToPn(lid)`|`(lid: string): Promise<string \| null>`| Resolve a `@lid` JID to its phone-number JID (`null` if unknown). Needs a connected socket. |
57
58
|`pnToLid(pn)`|`(pn: string): Promise<string \| null>`| Resolve a phone-number JID to its `@lid` JID (`null` if unknown). Needs a connected socket. |
58
59
|`broadcast(jids, build, opts?)`|`(jids: string[], build, opts?): Promise<BroadcastResult>`| Send to many recipients. See [Broadcast & Schedule](/automation). |
|`operationGuard`|`OperationGuardOptions`| on (spaces group/community/newsletter ops) | Serializes and rate-limits sensitive group / community / newsletter operations per category so rapid bulk actions don't trip a ban. |
43
43
|`presence`|`PresenceThrottleOptions`| on (drops duplicate presence) | Drops repeated presence updates (typing / recording / online) for the same chat within a short window. |
44
44
|`scheduleRateLimitPerSec`|`number`|`1` (`0` disables) | Max scheduled messages dispatched per second, smoothing out a backlog of overdue jobs so they don't all fire at once. |
45
+
|`autoRejectCall`|`boolean \| AutoRejectCallOptions`|`false` (off) | 🔗 **Unofficial only.** Auto-reject incoming WhatsApp calls. `true` rejects every call; pass an object for an allow-list and an `onReject` hook. |
45
46
|`autoDelete`|`AutoDeleteOptions \| false`|`on (1-month retention)`| Periodically prune old messages from the local store. See [Auto-Delete](/auto-delete). |
46
47
|`plugins`|`PluginsOptions`|`undefined`| Load and hot-reload plugins from a folder. See [Plugins](/plugins). |
47
48
|`autoConnect`|`boolean`|`true`| When `true`, the constructor calls `connect()` on the next microtask. Set `false` to connect manually. |
@@ -527,6 +528,59 @@ const client = new Client({
527
528
and `qrTimeout` are merely internal defaults you *can* override here if you really need to.
528
529
</Callout>
529
530
531
+
## `autoRejectCall`
532
+
533
+
<Callouttype="info">
534
+
🔗 **Unofficial provider only.** The official [Cloud API](/official) has no call events — calling
535
+
`client.rejectCall()` there throws `ZaileysProviderError('UNSUPPORTED_ON_CLOUD')`, and this option is
536
+
never wired.
537
+
</Callout>
538
+
539
+
Auto-reject incoming voice/video calls. **Off by default** — rejecting calls is opt-in.
540
+
541
+
```typescript
542
+
// reject every incoming call
543
+
const client =newClient({ autoRejectCall: true })
544
+
```
545
+
546
+
| Field | Type | Default | Description |
547
+
| --- | --- | --- | --- |
548
+
|`enabled`|`boolean`|`false`| Turn auto-rejecting on. Passing `autoRejectCall: true` is shorthand for `{ enabled: true }`. |
549
+
|`allow`|`string[] \| (jid: string) => boolean \| Promise<boolean>`|`undefined`| Callers to let ring. Array entries match the full jid **or** its digits. A predicate may be async. |
550
+
|`onReject`|`(call) => void \| Promise<void>`|`undefined`| Runs **after** a call was successfully rejected — e.g. to tell the caller why. |
551
+
552
+
```typescript
553
+
const client =newClient({
554
+
autoRejectCall: {
555
+
enabled: true,
556
+
allow: ['628owner@s.whatsapp.net'], // owner may still call
557
+
onReject: async (call) => {
558
+
awaitclient.send(call.from).text('Maaf, nomor ini tidak menerima telepon 🙏')
559
+
},
560
+
},
561
+
})
562
+
```
563
+
564
+
The `call` passed to `onReject` is the same `call-incoming` payload:
565
+
`{ kind, callId, from, isGroup, isVideo, timestamp, status }` — so you can branch on `isVideo` /
566
+
`isGroup` inside your hook or inside `allow`.
567
+
568
+
### Rejecting manually
569
+
570
+
Leave the option off and drive it yourself from the [`call-incoming`](/events) event:
571
+
572
+
```typescript
573
+
client.on('call-incoming', async (call) => {
574
+
if (call.isVideo) awaitclient.rejectCall(call) // pass the payload…
575
+
elseawaitclient.rejectCall(call.callId, call.from) // …or the raw ids
576
+
})
577
+
```
578
+
579
+
<Callouttype="default">
580
+
`onReject` and `allow` failures are caught and logged — a throwing hook never crashes the client.
581
+
`client.rejectCall()`**does** throw (e.g. `NOT_CONNECTED`) so you can handle it.
582
+
</Callout>
583
+
530
584
## `autoDelete`
531
585
532
586
`autoDelete` periodically prunes old messages from the local store to keep memory usage bounded. It is
| Calls / auto-reject calls | ❌ no call events in the Cloud API | Use the [unofficial provider](/unofficial) (`autoRejectCall`, `client.rejectCall()`) |
217
218
| Status / stories | ❌ | Unofficial provider |
218
219
| Read arbitrary chat history | ❌ | Persist inbound to your own [store](/storage)|
0 commit comments