Reference

Groups

Group chat ids end in @g.us. Send messages to a group by using its id as the chatId.

Tusk WhatsApp API: Groups

List groups

GET/v1/whatsapp/sessions/{sessionId}/groups

Returns the groups the number is in.

Parameters
NameTypeDescription
sessionIdrequiredpathThe session id from the sessions endpoints.
limitintegerMaximum groups to return, from 1 to 1000. Defaults to 1000.
offsetintegerNumber of groups to skip, for paging.
curl "https://api.tuskmail.africa/v1/whatsapp/sessions/$SESSION_ID/groups" \
  -H "X-API-Key: $TUSK_WA_KEY"
200 OK
[
  {
    "id": "[email protected]",
    "name": "Delivery team"
  }
]

Create a group

POST/v1/whatsapp/sessions/{sessionId}/groups

Creates a group with the given participants.

Body
NameTypeDescription
sessionIdrequiredpathThe session id from the sessions endpoints.
namerequiredstringThe group name.
participantsrequiredstring[]Chat ids of the people to add.
curl -X POST "https://api.tuskmail.africa/v1/whatsapp/sessions/$SESSION_ID/groups" \
  -H "X-API-Key: $TUSK_WA_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Delivery team",
  "participants": [
    "[email protected]",
    "[email protected]"
  ]
}'
201 Created
{
  "id": "[email protected]",
  "name": "Delivery team",
  "participantsCount": 3,
  "isAdmin": true
}

Get a group

GET/v1/whatsapp/sessions/{sessionId}/groups/{groupId}

Returns group details and participants.

Parameters
NameTypeDescription
sessionIdrequiredpathThe session id from the sessions endpoints.
groupIdrequiredpathThe group id, ending in @g.us.
curl "https://api.tuskmail.africa/v1/whatsapp/sessions/$SESSION_ID/groups/[email protected]" \
  -H "X-API-Key: $TUSK_WA_KEY"
200 OK
{
  "id": "[email protected]",
  "name": "Delivery team",
  "description": "Daily dispatch",
  "participants": [
    {
      "id": "[email protected]",
      "number": "254700000002",
      "isAdmin": true,
      "isSuperAdmin": true
    }
  ],
  "isAnnounce": false,
  "memberAddMode": "all"
}

Add participants

POST/v1/whatsapp/sessions/{sessionId}/groups/{groupId}/participants

Adds people to a group. The response reports the outcome for each person.

Body
NameTypeDescription
sessionIdrequiredpathThe session id from the sessions endpoints.
groupIdrequiredpathThe group id.
participantsrequiredstring[]Chat ids to add.
curl -X POST "https://api.tuskmail.africa/v1/whatsapp/sessions/$SESSION_ID/groups/[email protected]/participants" \
  -H "X-API-Key: $TUSK_WA_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "participants": [
    "[email protected]"
  ]
}'
200 OK
{
  "success": true,
  "message": "Participants updated",
  "results": [
    {
      "id": "[email protected]",
      "success": true,
      "status": 200
    }
  ]
}

Remove participants

DELETE/v1/whatsapp/sessions/{sessionId}/groups/{groupId}/participants

Removes people from a group.

Body
NameTypeDescription
sessionIdrequiredpathThe session id from the sessions endpoints.
groupIdrequiredpathThe group id.
participantsrequiredstring[]Chat ids to remove.
curl -X DELETE "https://api.tuskmail.africa/v1/whatsapp/sessions/$SESSION_ID/groups/[email protected]/participants" \
  -H "X-API-Key: $TUSK_WA_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "participants": [
    "[email protected]"
  ]
}'
200 OK
{
  "success": true,
  "message": "Participants updated",
  "results": [
    {
      "id": "[email protected]",
      "success": true,
      "status": 200
    }
  ]
}

Leave a group

POST/v1/whatsapp/sessions/{sessionId}/groups/{groupId}/leave

Makes the number leave the group.

Parameters
NameTypeDescription
sessionIdrequiredpathThe session id from the sessions endpoints.
groupIdrequiredpathThe group id.
curl -X POST "https://api.tuskmail.africa/v1/whatsapp/sessions/$SESSION_ID/groups/[email protected]/leave" \
  -H "X-API-Key: $TUSK_WA_KEY"
200 OK
{
  "success": true,
  "message": "Left group"
}

Get the invite link

GET/v1/whatsapp/sessions/{sessionId}/groups/{groupId}/invite-code

Returns the group's invite code and link.

Parameters
NameTypeDescription
sessionIdrequiredpathThe session id from the sessions endpoints.
groupIdrequiredpathThe group id.
curl "https://api.tuskmail.africa/v1/whatsapp/sessions/$SESSION_ID/groups/[email protected]/invite-code" \
  -H "X-API-Key: $TUSK_WA_KEY"
200 OK
{
  "inviteCode": "AbCdEfGhIjK",
  "inviteLink": "https://chat.whatsapp.com/AbCdEfGhIjK"
}