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

The student leaves the WhatsApp group when access ends

Students stop seeing course lessons in the group chat after their access is over. When course access ends, your backend can confirm the student is still in the group and remove them through Whapi.Cloud. This use case shows integrators how to implement that flow through the WhatsApp API.

Triggered by your backend or a payment webhook WhatsApp group id is already stored
A phone showing a WhatsApp course group member list at the moment a student's access has ended.
Use case

When to use this flow

The course seat is a WhatsApp group

Use this flow when enrolled students sit in a WhatsApp group and the seat you revoke is membership in that group.

The WhatsApp group id is already stored

Use this flow when the WhatsApp group id is already stored and you only confirm the student is still listed.

Access end comes from your own systems

Use this flow when your backend or a payment webhook is what marks the course as ended.

A phone showing WhatsApp group info where the former student is no longer in the member list.
Customer experience

The student is no longer in the group

Before automation, expired students stay in the group and keep seeing lessons and chat, so paid content leaks and support gets complaints.

After access ends, the student is no longer in the course WhatsApp group. Integrators build this result with the WhatsApp API.

Workflow

From access ended to group removal

1

Course access ended

Your backend or payment webhook reports that this student's course access is over and names the WhatsApp group they were in.

2

Confirm the student is listed

GET /groups/{GroupID}

getGroup returns the group and its participants for the stored group id, so you can match the student before removal.

3

Remove that participant

DELETE /groups/{GroupID}/participants

removeGroupParticipant removes the matched participant. Send the same group id and that contact id in participants.

Prerequisites

Before you run the flow

The WhatsApp number connected to your channel is the one that removes the student. Each request uses that number's API token. The channel must be authorized, and the number needs permission to remove a participant.

Optional — go deeper for this flow

API implementation

Confirm the student, then remove them

Course access has already ended outside Whapi.Cloud. Read the stored group so you know the student is still a participant, then remove that participant from the group.

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.

Confirm the student is listed

Read the stored group and its participants so the student can be matched before removal.

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

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

$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests

url = "https://gate.whapi.cloud/groups/GROUP_ID"
headers = {
    "accept": "application/json",
    "authorization": "Bearer Your_Token",
}

response = requests.get(url, headers=headers)
print(response.text)
const url = 'https://gate.whapi.cloud/groups/GROUP_ID';

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/GROUP_ID")
  .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/GROUP_ID");
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/GROUP_ID", nil)
	req.Header.Set("accept", "application/json")
	req.Header.Set("authorization", "Bearer Your_Token")

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

Remove that participant

Remove the matched participant so they are no longer in the course group.

curl --request DELETE \
     --url https://gate.whapi.cloud/groups/GROUP_ID/participants \
     --header 'accept: application/json' \
     --header 'authorization: Bearer Your_Token' \
     --header 'content-type: application/json' \
     --data '
{
  "participants": ["12345678901"]
}'
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://gate.whapi.cloud/groups/GROUP_ID/participants",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => "DELETE",
  CURLOPT_POSTFIELDS => "{\"participants\":[\"12345678901\"]}",
  CURLOPT_HTTPHEADER => [
    "accept: application/json",
    "authorization: Bearer Your_Token",
    "content-type: application/json"
  ],
]);

$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests

url = "https://gate.whapi.cloud/groups/GROUP_ID/participants"
payload = {"participants": ["12345678901"]}
headers = {
    "accept": "application/json",
    "authorization": "Bearer Your_Token",
    "content-type": "application/json",
}

response = requests.delete(url, json=payload, headers=headers)
print(response.text)
const url = 'https://gate.whapi.cloud/groups/GROUP_ID/participants';

const response = await fetch(url, {
  method: 'DELETE',
  headers: {
    accept: 'application/json',
    authorization: 'Bearer Your_Token',
    'content-type': 'application/json',
  },
  body: JSON.stringify({
    participants: ['12345678901'],
  }),
});

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

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"participants\":[\"12345678901\"]}");
Request request = new Request.Builder()
  .url("https://gate.whapi.cloud/groups/GROUP_ID/participants")
  .delete(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/GROUP_ID/participants");
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.AddStringBody("{\"participants\":[\"12345678901\"]}", DataFormat.Json);
var response = await client.DeleteAsync(request);

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

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

func main() {
	body := strings.NewReader(`{"participants":["12345678901"]}`)
	req, _ := http.NewRequest("DELETE", "https://gate.whapi.cloud/groups/GROUP_ID/participants", 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))
}
When things break

Handle failures at each step

After course access ends, the student can still be in the group if the group is missing, the participant is not found, or the API call fails. Retry that step or alert your team.

Access ended, but the student is still in the group?

The group may be missing, the participant may not be found, or the call may fail. Retry the removal or alert your team so the student does not keep seeing the group. 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
404 Specified group not found
500 Internal Error
Status What it means What to do
400 Wrong request parameters
401 Need channel authorization for remove participant
403 You do not have permissions for this action
404 Specified group or participant not found
500 Internal Error
FAQ

Questions operators ask

Retry the removal or alert your team. The group may be missing, the participant may not be found, or the API call may have failed. Do not treat the student as removed until that step succeeds.
No. The result is that the student is no longer in the WhatsApp group. The flow reads that group's participants and removes one person.
No. The WhatsApp group id is already stored. getGroup confirms the student is among the participants. removeGroupParticipant then removes that participant.
No. This flow runs when course access ends, and the branch is removal from the group. It does not approve a join request and it does not send an invite link.
Your backend or a payment webhook decides that. Whapi.Cloud removes the participant after that event. It does not decide that the course is over.
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