Delete a section

This guide explains how to use the delete method on the Section resource of the Google Chat API to delete a custom section in Google Chat.

When you delete a section, its items (such as spaces) are moved to Google Chat's default sections and are not deleted.

Only sections of type CUSTOM_SECTION can be deleted. For more information, see Create and organize sections in Google Chat.

Prerequisites

Python

Delete a section

To delete a section with user authentication, pass the following in your request:

  • Specify the chat.users.sections authorization scope.
  • Call the DeleteSection method.
  • In the request body, set name to the resource name of the section to delete.

The following example deletes a section:

Python

from google.cloud import chat_v1

def delete_section():
    # Create a client
    client = chat_v1.ChatServiceClient()

    # Initialize request
    request = chat_v1.DeleteSectionRequest(
        name="SECTION_NAME"
    )

    # Make the request
    client.delete_section(request=request)

    print("Section deleted")

To run this sample, replace the following:

  • SECTION_NAME: The resource name of the section. You can obtain the resource name by calling the ListSections method.