sinch.domains.sms.api.v1.groups_apis module

class sinch.domains.sms.api.v1.groups_apis.Groups(sinch)[source]

Bases: BaseSms

create(
name: str | None = None,
members: List[str] | None = None,
child_groups: List[str] | None = None,
auto_update: AutoUpdateDict | None = None,
**kwargs,
) GroupResponse[source]

This endpoint allows you to create a group of recipients. A new group must be created with a group name. This is represented by the name field which can be up to 20 characters. In addition, there are a number of optional fields:

  • members field enables groups to be created with an initial list of contacts.

  • auto_update allows customers to auto subscribe to a new group. This contains three fields. The to field contains the group creator’s number. (This number must be provisioned by contacting your account manager.) The add and remove fields are objects containing the keywords that customers need to text to join or leave a group.

Parameters:
  • name (Optional[str]) – Name of the group. Max 20 characters. (optional)

  • members (Optional[List[str]]) – Initial list of phone numbers in E.164 format (MSISDNs) for the group. (optional)

  • child_groups (Optional[List[str]]) – MSISDNs of child groups to include in this group. If present, this group will be auto-populated. Elements must be valid group IDs. (optional)

  • auto_update (Optional[AutoUpdateDict]) – The auto-update settings for the group. (optional)

  • **kwargs

    Additional parameters for the request.

Returns:

GroupResponse

Return type:

GroupResponse

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

list(
page: int | None = None,
page_size: int | None = None,
**kwargs,
) Paginator[GroupResponse][source]

With the list operation you can list all groups that you have created. This operation supports pagination.

Groups are returned in reverse chronological order.

Parameters:
  • page (Optional[int]) – The page number starting from 0. (optional)

  • page_size (Optional[int]) – Determines the size of a page. (optional)

  • **kwargs

    Additional parameters for the request.

Returns:

Paginator[GroupResponse]

Return type:

Paginator[GroupResponse]

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

get(
group_id: str,
**kwargs,
) GroupResponse[source]

This operation retrieves a specific group with the provided group ID.

Parameters:

group_id (str) – ID of a group that you are interested in getting.

Returns:

GroupResponse

Return type:

GroupResponse

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

replace(
group_id: str,
name: str | None = None,
members: List[str] | None = None,
child_groups: List[str] | None = None,
auto_update: AutoUpdateDict | None = None,
**kwargs,
) GroupResponse[source]

The replace operation will replace all parameters, including members, of an existing group with new values.

Replacing a group targeted by a batch message scheduled in the future is allowed and changes will be reflected when the batch is sent.

Parameters:
  • group_id (str) – ID of the group to replace.

  • name (Optional[str]) – Name of the group. Max 20 characters. (optional)

  • members (Optional[List[str]]) – Initial list of phone numbers in E.164 format (MSISDNs) for the group. (optional)

  • child_groups (Optional[List[str]]) – MSISDNs of child groups to include in this group. If present, this group will be auto-populated. Elements must be valid group IDs. (optional)

  • auto_update (Optional[AutoUpdateDict]) – The auto-update settings for the group. (optional)

  • **kwargs

    Additional parameters for the request.

Returns:

GroupResponse

Return type:

GroupResponse

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

update(
group_id: str,
add: List[str] | None = None,
remove: List[str] | None = None,
name: str | None = None,
add_from_group: str | None = None,
remove_from_group: str | None = None,
auto_update: AutoUpdateDict | None = None,
**kwargs,
) GroupResponse[source]

With the update group operation, you can add and remove members in an existing group as well as rename the group.

This method encompasses a few ways to update a group:

  1. By using add and remove arrays containing phone numbers, you control the group movements. Any list of valid numbers in E.164 format can be added.

  2. By using the auto_update object, your customer can add or remove themselves from groups.

  3. You can also add or remove other groups into this group with add_from_group and remove_from_group.

Other group update info:

  • The request will not be rejected for duplicate adds or unknown removes.

  • The additions will be done before the deletions. If a phone number is on both lists, it will not be part of the resulting group.

  • Updating a group targeted by a batch message scheduled in the future is allowed. Changes will be reflected when the batch is sent.

Parameters:
  • group_id (str) – ID of the group to update.

  • add (Optional[List[str]]) – List of phone numbers (MSISDNs) in E.164 format to add to the group. (optional)

  • remove (Optional[List[str]]) – List of phone numbers (MSISDNs) in E.164 format to remove from the group. (optional)

  • name (Optional[str]) – Name of the group. Omit to leave the name unchanged; set explicitly to null to remove the existing name. (optional)

  • add_from_group (Optional[str]) – Copy the members from another group into this group. Must be a valid group ID. (optional)

  • remove_from_group (Optional[str]) – Remove the members in a specified group from this group. Must be a valid group ID. (optional)

  • auto_update (Optional[AutoUpdateDict]) – The auto-update settings for the group. (optional)

  • **kwargs

    Additional parameters for the request.

Returns:

GroupResponse

Return type:

GroupResponse

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

delete(group_id: str, **kwargs) None[source]

This operation deletes the group with the provided group ID.

Parameters:

group_id (str) – ID of the group to delete.

Returns:

None

Return type:

None

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

list_members(group_id: str, **kwargs) Paginator[str][source]

This operation retrieves the members of the group with the provided group ID.

Parameters:

group_id (str) – ID of the group whose members are being retrieved.

Returns:

Paginator[str]

Return type:

Paginator[str]

For detailed documentation, visit https://developers.sinch.com/docs/sms/.