How to Add Participants to a WhatsApp Group with whatsapp-web.js

To add participants to a WhatsApp group with whatsapp-web.js, get the group with client.getChatById('<group id>@g.us') and call group.addParticipants([...]) with each person’s ID in <country code><number>@c.us form, for example 919XXXXXXXXX@c.us. The account you logged in with must be an admin of the group. The method returns one result per participant, with a code that tells you whether they were added, are already a member, or can only be invited.
This post was updated for whatsapp-web.js 1.34.8 (the current release in November 2026), which needs Node.js 18 or newer. The code below was checked against that release’s source and its GroupChat documentation.

I first explained this in a video on WhatsApp automation with JavaScript, after someone asked about it in the comments:
https://www.youtube.com/watch?v=iovH8bwSCWY
Setup
npm install whatsapp-web.js qrcode-terminal
whatsapp-web.js is an unofficial library: it runs WhatsApp Web in a headless browser (Puppeteer) and logs in as your own account when you scan the QR code. It is not the official WhatsApp Business API.
Add participants by phone number
const { Client, LocalAuth } = require("whatsapp-web.js");
const qrcode = require("qrcode-terminal");
const GROUP_ID = "120363XXXXXXXXXXXX@g.us"; // your group's ID
const NUMBERS = ["919XXXXXXXXX", "4479XXXXXXXX"]; // country code + number, no + or spaces
const client = new Client({ authStrategy: new LocalAuth() });
client.on("qr", (qr) => qrcode.generate(qr, { small: true }));
client.on("ready", async () => {
const group = await client.getChatById(GROUP_ID);
if (!group.isGroup) {
console.log("That ID is not a group");
return;
}
const ids = NUMBERS.map((n) => `${n}@c.us`);
const result = await group.addParticipants(ids, {
autoSendInviteV4: true, // invite people whose privacy settings block being added
comment: "Join our group", // text sent with that invite
});
if (typeof result === "string") {
console.log("Nobody was added:", result); // e.g. you are not an admin
return;
}
for (const [id, r] of Object.entries(result)) {
console.log(id, r.code, r.message, r.isInviteV4Sent ? "(invite sent)" : "");
}
});
client.initialize();
The ID of a contact is the country code and the phone number followed by @c.us: 919XXXXXXXXX@c.us is an Indian number (91 is India’s country code). The @c.us part is the same for every contact in every country. addParticipants also accepts a single ID as a string instead of an array.
Find the group ID
If you only know the group’s name, list your chats and print the IDs of the groups:
client.on("ready", async () => {
const chats = await client.getChats();
chats
.filter((chat) => chat.isGroup)
.forEach((chat) => console.log(chat.name, chat.id._serialized));
});
Group IDs end in @g.us. Save the one you need and use it with getChatById, so the script doesn’t depend on a group name that someone can change. The older version of this post found the group and the contact by name, as in the screenshot below; that still works, but an ID is more reliable.

What addParticipants returns
In 1.34.8 the signature is addParticipants(participantIds, options) and it resolves to either:
- an object keyed by participant ID, where each value has
code,messageandisInviteV4Sent, or - a string, an error message when nobody could be added (for example, you are not an admin of the group, or the group has no participants).
The options, with their defaults from the library’s source:
| Option | Default | What it does |
|---|---|---|
sleep |
[250, 500] |
Milliseconds to wait between participants: a random time between the two values, or a fixed number |
autoSendInviteV4 |
true |
Sends a private group invite to people whose privacy settings don’t let others add them |
comment |
'' |
The text sent with that invite |
Common errors
These are the codes and messages the library returns for each participant:
| Code | Meaning |
|---|---|
| 200 | The participant was added |
| 403 | They can only be added by a private invitation (their privacy settings); with autoSendInviteV4 the library tries to send one, and isInviteV4Sent says if it worked |
| 404 | The phone number is not registered on WhatsApp |
| 408 | They recently left the group, so you can’t add them back yet |
| 409 | They are already a member |
| 417 | They can’t be added to the community; invite them through the group’s invite link instead |
| 419 | The group is full |
If you get the string “AddParticipantsError: You have no admin rights to add a participant to a group”, make the logged-in account a group admin first. For people you can’t add directly (403 without an invite sent, or 417), share the group’s invite link: await group.getInviteCode() gives the code, and the link is https://chat.whatsapp.com/<code>.
Adding many people quickly from a personal account can get the number restricted by WhatsApp, so keep the sleep delay and add people who expect it. For more on automating WhatsApp with whatsapp-web.js, see how to send a list of options and read the reply.
FAQ
Do I need to be a group admin to add participants?
Yes. If the logged-in account is not an admin, addParticipants returns the error string “AddParticipantsError: You have no admin rights to add a participant to a group” and adds nobody.
Can I add someone by phone number if they are not in my contacts?
Yes. Pass <country code><number>@c.us directly; the number doesn’t have to be a saved contact, but it must be registered on WhatsApp (otherwise the result is code 404).
Why did adding a participant fail?
Read the code in the result for that participant: 403 means their privacy settings only allow an invitation, 408 that they left the group recently, 409 that they are already in it, 419 that the group is full. The table above lists every code.