In this tutorial, we are going to show you how to get a WhatsApp group invitation link and send it to your contacts with the Wassenger API and Node.js
Expanding your audience by sending WhatsApp group invite links is highly effective, thanks to the platform’s impressive 98% open rates. Imagine being able to send personalized recommendations, answer common questions, and analyze market trends automatically and instantly.
However, enhanced privacy features now make it difficult to automatically add users to groups if they haven’t saved your number, as their settings may prevent it.
The good news is there’s a solution covered in this tutorial: you can send a private message to specific users with the group invite link, enabling them to join the group.
To achieve this, you’ll perform two tasks using the API:
1. Obtain the WhatsApp group invitation link: You must be a participant with invite permissions in the target group. 2. Send the group invite link via private WhatsApp message to the user.
Find more information and code examples below!
🤩 🤖 Wassenger is a complete communication platform and API solution for WhatsApp. Explore more than 100+ API use cases and automate anything on WhatsApp by signing up for a free trial and get started in minutes!
Requirements
- Have a WhatsApp number already linked to the platform and online.
- Get your Wassenger API key here
- Group WhatsApp ID (WID) that you can find in two ways:
How to obtain the Group WhatsApp ID
You can obtain the Group WhatsApp ID by using one of these methods:
- Web: go to number’s settings > Groups > Copy the Group WID.
- API: query the available groups in your number using this endpoint.
API endpoint
We will use the following API endpoints to send messages to a group:
🖥️ Looking for a code example? Go to the API live tester and get ready-to-use code examples in 15+ programming languages, including Python, JavaScript, PHP, C#, Java, Ruby, Go, Powershell, cURL and more.
Get the invitation link with Node (fetch)
// Examples requires you to have installed node-fetch Node.js package.
// Install it by running: npm install --save node-fetch or yarn add node-fetch
const fetch = require('node-fetch');
const url =
'https://api.wassenger.com/v1/devices/$DEVICE_ID/groups/$GROUP_ID@g.us/invite';
const options = { method: 'GET', headers: { Token: 'ENTER API KEY HERE' } };
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
Get the invitation link with Node (axios)
const axios = require('axios').default;
const options = {
method: 'GET',
url: 'https://api.wassenger.com/v1/devices/$DEVICE_ID/groups/$GROUP_ID@g.us/invite',
headers: { Token: 'ENTER API KEY HERE' }
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
Get the invitation link with Node (unirest)
// Examples requires you to have installed unirest Node.js package.
// Install it by running: npm install --save unirest or yarn add unirest
const unirest = require('unirest');
const req = unirest(
'GET',
'https://api.wassenger.com/v1/devices/$DEVICE_ID/groups/$GROUP_ID@g.us/invite'
);
req.headers({
Token: 'ENTER API KEY HERE'
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
You will get something like:
{
"code": "CPBgYNktDdV0nkjzz9",
"url": "https://chat.whatsapp.com/CPBgYNktDdV0nkjzz9"
}
🤩 🤖 Wassenger is a complete API solution for WhatsApp. Sign up for a 7-day free trial and get started in minutes!
Now, you can share the link with the contacts you want to invite to your group.
Send a message with the given link with Node (fetch)
// Examples requires you to have installed node-fetch Node.js package.
// Install it by running: npm install --save node-fetch or yarn add node-fetch
const fetch = require('node-fetch');
const url = 'https://api.wassenger.com/v1/messages';
const options = {
method: 'POST',
headers: { 'Content-Type': 'application/json', Token: 'ENTER API KEY HERE' },
body: '{"phone":"+1234567890", "message":"Join our newsletter group!: https://chat.whatsapp.com/CPBgYNktDdV0nkjzz9NzJ1"}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
Send a message with the given link with Node (axios)
const axios = require('axios').default;
const options = {
method: 'POST',
url: 'https://api.wassenger.com/v1/messages',
headers: { 'Content-Type': 'application/json', Token: 'ENTER API KEY HERE' },
data: {
phone: '+1234567890',
message:
'Join my newsletter group!: https://chat.whatsapp.com/CPBgYNktDdV0nkjzz9NzJ1'
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
Send a message with the given link with Node (unirest)
// Examples requires you to have installed unirest Node.js package.
// Install it by running: npm install --save unirest or yarn add unirest
const unirest = require('unirest');
const req = unirest('POST', 'https://api.wassenger.com/v1/messages');
req.headers({
'Content-Type': 'application/json',
Token: 'ENTER API KEY HERE'
});
req.type('json');
req.send({
phone: '+1234567890',
message:
'Join my newsletter group!: https://chat.whatsapp.com/CPBgYNktDdV0nkjzz9NzJ1'
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
🤩 🤖 Wassenger is a complete API solution for WhatsApp. Sign up for a 7-day free trial and get started in minutes!
Live API testing
You can live-test and play with the API directly from your browser.
Once you are done testing, get the auto-generated code example in your preferred programming language and you will be ready to go.
🤩 🤖 Wassenger is a complete API solution for WhatsApp. Sign up for a 7-day free trial and get started in minutes!







