Manage groups
Learn how to manage Telegram groups using Unipile API.
Manage group members
List members
To list all members of a group chat, use List all Chat Participants method and provide the chat ID.
const { data, error } = await messagingApi.getParticipantsList({
path: {
account_id: "acc_123456789",
chat_id: "chat_id",
},
query: {
limit: 20,
},
});participants = messaging_api.get_participants_list(
"chat_id",
"acc_123456789",
limit=20,
)curl --request GET \
--url https://api.unipile.com/v2/account_id/chats/chat_id/participants \
--header 'accept: application/json'Add a new member
To add a member to a group chat, use Add a Chat Participant method and provide the chat ID and the user ID to add. See Find User IDs.
Provider limitationsMake sure that the account owner has the Add other members permission in the group to perform this action. Unipile may respond successfully without actually adding the member if this limitation is not respected.
const { data, error } = await messagingApi.addParticipant({
path: {
account_id: "acc_123456789",
chat_id: "chat_id",
},
body: {
user_id: "1234562890",
},
});messaging_api.add_participant(
"chat_id",
"acc_123456789",
{"user_id": "1234562890"},
)curl --request POST \
--url https://api.unipile.com/v2/account_id/chats/chat_id/participants \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"user_id": "[email protected]"
}
'Remove a member
To remove a member from a group, use Remove a Chat Participant method and provide the chat ID and the ID of the user to remove.
Provider limitationsMake sure the account owner is admin of the group to perform this action. Unipile may respond successfully without actually removing the member if this limitation is not respected.
const { data, error } = await messagingApi.removeParticipant({
path: {
account_id: "acc_123456789",
chat_id: "chat_id",
user_id: "1234562890",
},
});messaging_api.remove_participant(
"chat_id",
"1234562890",
"acc_123456789",
)curl --request DELETE \
--url https://api.unipile.com/v2/account_id/chats/chat_id/participants/334455667788%40s.whatsapp.net \
--header 'accept: application/json'Exit a group
To exit a group, use Remove a Chat Participant method and provide the user ID of the account owner.
const account = await accountsApi.getAccount({
path: {
account_id: "acc_123456789",
},
});
const self_user_id = account.data.user_id;
const { data, error } = await messagingApi.removeParticipant({
path: {
account_id: "acc_123456789",
chat_id: "chat_id",
user_id: self_user_id,
},
});account = accounts_api.get_account("acc_123456789")
self_user_id = account.user_id
if self_user_id:
messaging_api.remove_participant(
"chat_id",
self_user_id,
"acc_123456789",
)
Note on exited groupsWhen the account owner leaves a group, the
read_onlyproperty is set totrueon the Chat object. The chat will remain in the chat list, and its messages can still be retrieved — this reflects WhatsApp’s native behavior.If the owner selects Exit and delete for me or Delete chat from the WhatsApp app after leaving, the chat and its messages will be removed entirely and will no longer appear in API results.
Deleting a chat via Unipile is not supported.
Update group name
To change the name of Group Chats, use Update a Chat method.
const { data, error } = await messagingApi.updateChat({
path: {
account_id: "acc_123456789",
chat_id: "chat_id",
},
body: {
name: "Updated Chat Name",
},
});messaging_api.update_chat(
"chat_id",
"acc_123456789",
{"name": "Updated Chat Name"},
)Updated about 1 month ago