Delete a section
Stay organized with collections
Save and categorize content based on your preferences.
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
- A Business or Enterprise Google Workspace account with access to Google Chat.
- Set up your environment:
- Create a Google Cloud project.
- Configure the OAuth consent screen.
- Enable and configure the Google Chat API with a name, icon, and description for your Chat app.
- Install the Python Cloud Client Library.
-
Create OAuth client ID credentials for a desktop application. To run the sample in this
guide, save the credentials as a JSON file named
credentials.jsonto your local directory.
- Choose an authorization scope that supports user authentication.
Delete a section
To delete a section with user authentication, pass the following in your request:
- Specify the
chat.users.sectionsauthorization scope. - Call the
DeleteSectionmethod. - In the request body, set
nameto 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 theListSectionsmethod.
Related topics
- Create a section
- Update a section
- Change the position of a section
- List sections
- List spaces in a section
- Move a space to a different section