Wow! Build your WhatsApp integration. Start free. Register Now
WhatsApp API

Payment succeeded — send the group invite

Give paying customers a direct path from checkout to your private WhatsApp group. Once payment is confirmed, your backend can fetch the group invite and deliver it to the payer automatically through Whapi.Cloud. This use case shows integrators how to implement that flow through the WhatsApp API.

Triggered by your payment webhook Invite delivered to the payer's WhatsApp
Checkout confirmation beside a WhatsApp group invitation ready for the payer to open.
Decorartive bubble
Use case

When to use this flow

You sell access to a private WhatsApp group

The paid product is a seat in a private WhatsApp group, and entry is that group's invite link.

The target group is resolved dynamically

Your backend picks which WhatsApp group matches the purchased product or tier.

The invite should be sent automatically

The payer should receive the invite without someone copying the link.

WhatsApp chat on a phone showing the group invitation message the payer can tap to join.
Customer experience

The payer gets the invite without waiting

Before automation, someone copies the group link or chases the payer after checkout, so paid members sit idle while access is unclear.

After payment is confirmed, the group invitation shows up in the payer's WhatsApp chat so they can open it and join on their own time. Integrators build this result with the WhatsApp API.

Workflow

From payment confirmed to the group invite

1

Payment confirmed

Your payment webhook passes the payer's WhatsApp number and the purchased product or tier to your backend.

2

Resolve the paid group

GET /groups

Match the purchase to the right WhatsApp group. When its id is not stored yet, getGroups returns the list you match against.

3

Get the invite code

GET /groups/{GroupID}/invite

getGroupInvite reads the invite code for the group you just resolved.

4

Send the invite to the payer

POST /groups/link/{InviteCode}

sendGroupInvite delivers that invite to the payer's WhatsApp number from the payment event. The payer joins by opening the link.

Need delivery tracking? Track what happens after the send with status webhooks. The send response only confirms the request was accepted. Learn about delivery status →

Prerequisites

Before you run the flow

Connect the WhatsApp number that will send the invite, and authenticate every request with that number's API token. Your payment webhook stays in your stack. Whapi.Cloud runs the group invite calls.

Optional — go deeper for this flow

API implementation

The three calls in order

Resolve the paid group, fetch its invite code, then deliver the invite to the payer. Map the payer phone from your payment payload onto the send body field to.

Get your API token for free after you register on whapi.cloud, and use that token in the code instead of Your_Token from the examples.

Resolve the paid group

Find the WhatsApp group that matches the product the payer bought when that group id is not already stored.

curl --request GET \
     --url https://gate.whapi.cloud/groups \
     --header 'accept: application/json' \
     --header 'authorization: Bearer Your_Token'
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://gate.whapi.cloud/groups",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => [
    "accept: application/json",
    "authorization: Bearer Your_Token"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
import requests

url = "https://gate.whapi.cloud/groups"

headers = {
    "accept": "application/json",
    "authorization": "Bearer Your_Token",
}

response = requests.get(url, headers=headers)

print(response.text)
const url = 'https://gate.whapi.cloud/groups';

const response = await fetch(url, {
  method: 'GET',
  headers: {
    accept: 'application/json',
    authorization: 'Bearer Your_Token',
  },
});

console.log(await response.text());
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://gate.whapi.cloud/groups")
  .get()
  .addHeader("accept", "application/json")
  .addHeader("authorization", "Bearer Your_Token")
  .build();

Response response = client.newCall(request).execute();
using RestSharp;

var options = new RestClientOptions("https://gate.whapi.cloud/groups");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("accept", "application/json");
request.AddHeader("authorization", "Bearer Your_Token");
var response = await client.GetAsync(request);

Console.WriteLine("{0}", response.Content);
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	req, _ := http.NewRequest("GET", "https://gate.whapi.cloud/groups", nil)
	req.Header.Set("accept", "application/json")
	req.Header.Set("authorization", "Bearer Your_Token")

	res, _ := http.DefaultClient.Do(req)
	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)
	fmt.Println(string(body))
}

Get the invite code

Read the invite code for the group you resolved.

curl --request GET \
     --url https://gate.whapi.cloud/groups/{GroupID}/invite \
     --header 'accept: application/json' \
     --header 'authorization: Bearer Your_Token'
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://gate.whapi.cloud/groups/{GroupID}/invite",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => [
    "accept: application/json",
    "authorization: Bearer Your_Token"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
import requests

url = "https://gate.whapi.cloud/groups/{GroupID}/invite"

headers = {
    "accept": "application/json",
    "authorization": "Bearer Your_Token",
}

response = requests.get(url, headers=headers)

print(response.text)
const url = 'https://gate.whapi.cloud/groups/{GroupID}/invite';

const response = await fetch(url, {
  method: 'GET',
  headers: {
    accept: 'application/json',
    authorization: 'Bearer Your_Token',
  },
});

console.log(await response.text());
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://gate.whapi.cloud/groups/{GroupID}/invite")
  .get()
  .addHeader("accept", "application/json")
  .addHeader("authorization", "Bearer Your_Token")
  .build();

Response response = client.newCall(request).execute();
using RestSharp;

var options = new RestClientOptions("https://gate.whapi.cloud/groups/{GroupID}/invite");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("accept", "application/json");
request.AddHeader("authorization", "Bearer Your_Token");
var response = await client.GetAsync(request);

Console.WriteLine("{0}", response.Content);
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	req, _ := http.NewRequest("GET", "https://gate.whapi.cloud/groups/{GroupID}/invite", nil)
	req.Header.Set("accept", "application/json")
	req.Header.Set("authorization", "Bearer Your_Token")

	res, _ := http.DefaultClient.Do(req)
	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)
	fmt.Println(string(body))
}

Send the invite to the payer

Deliver that invite to the phone number on the payment event.

curl --request POST \
     --url https://gate.whapi.cloud/groups/link/{InviteCode} \
     --header 'accept: application/json' \
     --header 'authorization: Bearer Your_Token' \
     --header 'content-type: application/json' \
     --data '
{
  "to": "447123456789"
}
'
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://gate.whapi.cloud/groups/link/{InviteCode}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{\"to\":\"447123456789\"}",
  CURLOPT_HTTPHEADER => [
    "accept: application/json",
    "authorization: Bearer Your_Token",
    "content-type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
import requests

url = "https://gate.whapi.cloud/groups/link/{InviteCode}"

payload = {
  "to": "447123456789"
}
headers = {
    "accept": "application/json",
    "authorization": "Bearer Your_Token",
    "content-type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const url = 'https://gate.whapi.cloud/groups/link/{InviteCode}';

const response = await fetch(url, {
  method: 'POST',
  headers: {
    accept: 'application/json',
    authorization: 'Bearer Your_Token',
    'content-type': 'application/json',
  },
  body: JSON.stringify({
  "to": "447123456789"
}),
});

console.log(await response.text());
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"to\":\"447123456789\"}");
Request request = new Request.Builder()
  .url("https://gate.whapi.cloud/groups/link/{InviteCode}")
  .post(body)
  .addHeader("accept", "application/json")
  .addHeader("authorization", "Bearer Your_Token")
  .addHeader("content-type", "application/json")
  .build();

Response response = client.newCall(request).execute();
using RestSharp;

var options = new RestClientOptions("https://gate.whapi.cloud/groups/link/{InviteCode}");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("accept", "application/json");
request.AddHeader("authorization", "Bearer Your_Token");
request.AddHeader("content-type", "application/json");
request.AddJsonBody(new { to = "447123456789" });
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content);
package main

import (
	"bytes"
	"fmt"
	"io"
	"net/http"
)

func main() {
	body := []byte(`{"to":"447123456789"}`)
	req, _ := http.NewRequest("POST", "https://gate.whapi.cloud/groups/link/{InviteCode}", bytes.NewReader(body))
	req.Header.Set("accept", "application/json")
	req.Header.Set("authorization", "Bearer Your_Token")
	req.Header.Set("content-type", "application/json")

	res, _ := http.DefaultClient.Do(req)
	defer res.Body.Close()
	out, _ := io.ReadAll(res.Body)
	fmt.Println(string(out))
}
Delivery

Status after the send response

A successful send response does not mean the payer already has the invite. The first status visible before a webhook is pending. Later status changes arrive only on statuses.post and statuses.put. If the status stays pending and does not move to sent, delivered, or a later ack, the message was not delivered. Check the payload and whether the account can send this message type.

  • The send call is accepted when the response includes sent.

  • Further ack changes arrive on statuses.post and statuses.put, not as extra fields on the send response.

What to read on delivery and webhooks

Contact our support if something went wrong
When things break

Handle failures at each step

Payment can succeed while the invite chain still breaks, when the paid group is missing from the list, the invite code cannot be fetched, or sendGroupInvite fails. Handle the break at that step so the payer still gets the link.

Payment succeeded, but the invite failed?

Keep payment state separate from invite delivery. Retry the failed step or alert your team so the payer still gets the link. Do not send the customer through checkout again. Clients often mention that our support is responsive. Do not hesitate to ask for help.

Contact our support if something went wrong

Troubleshoot by API step

Status What it means What to do
400 Wrong request parameters
500 Internal Error
Status What it means What to do
400 Wrong request parameters
401 Need channel authorization for create invite link
403 You do not have permissions for this action
404 Specified group not found
429 Too many requests
500 Internal Error
Status What it means What to do
400 Wrong request parameters
401 Need channel authorization for this action
402 Trial version limit exceeded
404 Specified group not found
429 Too many requests
500 Internal Error
FAQ

Questions operators ask

If the GroupID for the paid group is already stored, you can skip getGroups and start at getGroupInvite. You still need the invite code before sendGroupInvite.
Map the payer phone from your payment webhook payload onto the to field in sendGroupInvite. Whapi.Cloud does not read your billing system.
The send delivers an invitation link in chat. The payer joins when they open the link.
Retry the failed invite step or alert your team. Do not leave the payer waiting, and do not ask them to pay again.
Resolving a group, fetching an invite, and sending that link are a core reason teams pick a full-feature gateway when the product is community access.
Supported WhatsApp Features

Everything you need to build WhatsApp automation

Whapi.Cloud gives you access to a complete set of WhatsApp features — messaging, media, groups, channels, webhooks and more. Build bots, automations and integrations without feature limitations.

Chosen by developers

Trusted by 3,300+ developers and SaaS teams

Developers worldwide rely on Whapi.Cloud to build automations, bots, CRM integrations, bulk messaging tools and advanced WhatsApp workflows. Our infrastructure processes millions of API requests with high stability — and grows every month.

Icon of feature

5,5K+

active API channels

Icon of feature

21M+

API requests processed monthly

“Everything is simple, intuitive and easy to navigate. The docs are clear, and all the info I need is right on the screen. Great job.”

roberto k. / Web Developer

“We connected WhatsApp to our workflows using n8n in just a few minutes. No code, no complications- everything worked on the first try.”

Martin p. / Developer

“Whapi.Cloud became a key part of our customer communication. We automated product updates, order notifications and support messages without needing Meta templates or approvals”

Oscar T. / CTO

Decorative bubble