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 Java
Expand your audience by sending WhatsApp group invite links, taking advantage of the platform’s 98% open rates. However, privacy features now make it difficult to automatically add users who haven’t saved your number.
This tutorial provides a solution: send a private message with the group invite link, enabling users to join the group.
To accomplish this using the API:
1. Obtain the WhatsApp group invitation link (you must have invite permissions within the group). 2. Send the invite link via private WhatsApp message to the user.
Find more details 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 using Java
// This code requires you to have installed Unirest package.
// Documentation: https://kong.github.io/unirest-java/#requests
// Installation: http://kong.github.io/unirest-java/
HttpResponse<String> response = Unirest.get("https://api.wassenger.com/v1/devices/$DEVICE_ID/groups/$GROUP_ID@g.us/invite")
.header("Token", "ENTER API KEY HERE")
.asString();
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 using Java
// This code requires you to have installed Unirest package.
// Documentation: https://kong.github.io/unirest-java/#requests
// Installation: http://kong.github.io/unirest-java/
HttpResponse<String> response = Unirest.post("https://api.wassenger.com/v1/messages")
.header("Content-Type", "application/json")
.header("Token", "API TOKEN GOES HERE")
.body("{\"phone\":\"+12345678909\", \"message\":\"Join our offer and discounts WhatsApp group: https://chat.whatsapp.com/CPBgYNktDdV0nkjzz9\"}")
.asString();
🤩 🤖 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!







