Create a section

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

Sections help users group their conversations and customize the list of spaces displayed in the Google Chat navigation panel. For more information, see Create and organize sections in Google Chat.

Prerequisites

Python

Create a section

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

  • Specify the chat.users.sections authorization scope.
  • Call the CreateSection method.
  • In the request body, provide a Section resource:
    • Set displayName to a name for the section (up to 80 characters).
    • Set type to CUSTOM_SECTION.

The following example creates a section:

Python

fromgoogle.cloudimport chat_v1
defcreate_section():
 # Create a client
 client = chat_v1.ChatServiceClient()
 # Initialize request
 request = chat_v1.CreateSectionRequest(
 parent="users/me",
 section=chat_v1.Section(
 display_name="SECTION_DISPLAY_NAME",
 type=chat_v1.Section.SectionType.CUSTOM_SECTION
 )
 )
 # Make the request
 response = client.create_section(request=request)
 print(response)

To run this sample, replace the following:

  • SECTION_DISPLAY_NAME: The name of the new section.

The Chat API returns an instance of Section that details the section that was created.

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.