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 Kotlin
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 using Kotlin
// This code requires you to have installed okhttp package.
// Documentation: https://square.github.io/okhttp/recipes/
// Installation via Maven: https://square.github.io/okhttp/#releases
val client = OkHttpClient()
val request = Request.Builder()
.url("https://api.wassenger.com/v1/devices/$DEVICE_ID/groups/$GROUP_ID@g.us/invite")
.get()
.addHeader("Token", "ENTER API KEY HERE")
.build()
val response = client.newCall(request).execute()
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 Kotlin
// This code requires you to have installed okhttp package.
// Documentation: https://square.github.io/okhttp/recipes/
// Installation via Maven: https://square.github.io/okhttp/#releases
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\"phone\":\"+12345678909\", \"message\":\"Join our offer and discounts WhatsApp group: https://chat.whatsapp.com/CPBgYNktDdV0nkjzz9\"}")
val request = Request.Builder()
.url("https://api.wassenger.com/v1/messages")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("Token", "API TOKEN GOES HERE")
.build()
val response = client.newCall(request).execute()
🤩 🤖 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!







