Update a section

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

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

Prerequisites

Python

Update a section

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

  • Specify the chat.users.sections authorization scope.
  • Call the UpdateSection method.
  • In the request body, provide a Section resource and a field mask:
    • Set the name of the section to update.
    • Set displayName to the new name for the section.
    • Set updateMask to displayName.

The following example updates a section:

Python

fromgoogle.cloudimport chat_v1
fromgoogle.protobufimport field_mask_pb2
defupdate_section():
 # Create a client
 client = chat_v1.ChatServiceClient()
 # Initialize request
 request = chat_v1.UpdateSectionRequest(
 section=chat_v1.Section(
 name="SECTION_NAME",
 display_name="NEW_SECTION_DISPLAY_NAME"
 ),
 update_mask=field_mask_pb2.FieldMask(paths=["display_name"])
 )
 # Make the request
 response = client.update_section(request=request)
 print(response)

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.
  • NEW_SECTION_DISPLAY_NAME: The new name for the section.

The Chat API returns the updated instance of Section.

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.