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

fromgoogle.cloudimport chat_v1
defdelete_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.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026年04月20日 UTC.