Groups Types#

class pywa.types.groups.GroupDetails#

Represents the details of a WhatsApp group.

Variables:
  • id (str) – The unique identifier of the group.

  • subject (str) – The subject for the group.

  • description (str | None) – The description of the group.

  • creation_timestamp (datetime.datetime) – The timestamp when the group was created.

  • suspended (bool) – Indicates if the group is suspended by WhatsApp.

  • total_participant_count (int) – The total number of participants in the group, excluding your business.

  • participants (list[GroupParticipant]) – The list of participants in the group, excluding your business.

  • join_approval_mode (GroupJoinApprovalMode) – Indicates if WhatsApp users who click the invitation link can join the group with or without being approved first.

Get the invite link for the group.

Returns:

The invite link for the group.

Return type:

GroupInviteLink

Reset the invite link for the group.

Returns:

A new invite link for the group.

Return type:

GroupInviteLink

get_join_requests(pagination=None)#

You can create groups that require join request approval. Once enabled, WhatsApp users who click the group invitation link can submit a request to join the group, or cancel a prior request:

Parameters:

pagination (Pagination | None) – The pagination to use.

Returns:

A Result iterable containing the join requests for the group.

Return type:

Result[GroupJoinRequest]

delete()#

Delete the group.

Returns:

An operation representing the delete group request. You can use the returned request ID to track the status of the delete operation.

Return type:

GroupOperation

remove_participants(participants)#

Remove participants from the group.

Parameters:

participants (Iterable[str]) – The participants to remove.

Returns:

An operation representing the remove participants request. You can use the returned request ID to track the

Return type:

GroupOperation

remove_all_participants()#

Remove all participants from the group.

Returns:

An operation representing the remove all participants request. You can use the returned request ID to track

Return type:

GroupOperation

update(*, subject=None, description=None, profile_picture)#

Update group settings.

Parameters:
  • subject (str | None) – Group subject, Maximum 128 characters.

  • description (str | None) – Group description. Maximum 2048 characters.

  • profile_picture (bytes | str | Path | BinaryIO | Iterator[bytes]) – The new group profile picture. Can be a bytes object, a file path, a file-like object, or an iterator that yields bytes.

Returns:

An operation representing the update group settings request. You can use the returned request ID to track the status of the update operation.

Return type:

GroupOperation

class pywa.types.groups.GroupParticipant#

Represents an participant in a WhatsApp group.

Variables:
  • bsuid –

    The WhatsApp user’s BSUID. See developers.facebook.com for more information.

  • wa_id –

    The user’s phone number in international format (without the β€˜+’ sign). Will be unavailable if the user enables the username feature. See developers.facebook.com for more information.

  • username – The username of the user.

  • parent_bsuid –

    The Parent business-scoped user ID. See developers.facebook.com for more information.

remove()#

Remove the participant from the group.

Return type:

GroupOperation

Represents an invite link for a WhatsApp group.

reset()#

Reset the invite link.

Returns:

A new invite link for the group.

Return type:

GroupInviteLink

class pywa.types.groups.GroupJoinRequest#

Represents a join request for a WhatsApp group.

Variables:
  • id (str) – The unique identifier of the join request.

  • user (GroupParticipant) – The user who submitted the join request.

  • creation_timestamp (datetime.datetime) – The timestamp when the join request was created.

approve()#

Approve the join request.

Return type:

GroupOperation

reject()#

Reject the join request.

Return type:

GroupOperation

class pywa.types.groups.GroupJoinRequestsResult#

Bases: Result[GroupJoinRequest]

Represents a paginated result of group join requests for a WhatsApp group.

approve_all(*, fetch_all=False, sleep=0.0)#

Approve all join requests.

Parameters:
  • fetch_all (bool) – Whether to fetch all join requests before approving. If False, only the current page of join requests will be approved.

  • sleep (float) – The number of seconds to sleep between approving each join request when fetch_all is True. This can help avoid hitting rate limits.

Return type:

GroupOperation

reject_all(*, fetch_all=False, sleep=0.0)#

Reject all join requests.

Parameters:
  • fetch_all (bool) – Whether to fetch all join requests before rejecting. If False, only the current page of join requests will be rejected.

  • sleep (float) – The number of seconds to sleep between rejecting each join request when fetch_all is True. This can help avoid hitting rate limits.

Return type:

GroupOperation

class pywa.types.groups.GroupJoinApprovalMode#

Indicates if WhatsApp users who click the invitation link can join the group with or without being approved first.

Variables:
  • AUTO_APPROVE – Indicates WhatsApp users can join the group without approval.

  • APPROVAL_REQUIRED – Indicates WhatsApp users must be approved via join request before they can access the group.

class pywa.types.groups.GroupOperation#

Represents an operation performed on a WhatsApp group, such as creating a group or adding participants.

Attributes:

request_id: The unique identifier for the group operation request. This can be used to track the status of the operation.