Class CardWithId Stay organized with collections Save and categorize content based on your preferences.
Page Summary
CardWithIdis a builder for objects that provide a unique identifier for a card when sending multiple cards.CardWithIdis only available for Google Chat apps.The
setCard(card)method sets the card of thecardWithId.The
setCardId(id)method sets the unique card ID of thecardWithId.
A builder forCard objects. This class is a unique identifier for a card in amessage when sending multiple cards.
Only available for Google Chat apps. Not available for Google Workspace add-ons.
constcardSection=CardService.newCardSection();cardSection.addWidget(CardService.newTextParagraph().setText('This is a text paragraph widget.'),);constcard=CardService.newCardBuilder().setHeader(CardService.newCardHeader().setTitle('Card title')).addSection(cardSection).build();constcardWithId=CardService.newCardWithId().setCardId('card_id').setCard(card);
Methods
| Method | Return type | Brief description |
|---|---|---|
set | Card | Sets the card of thecard. |
set | Card | Sets the unique card ID of thecard. |
Detailed documentation
setCard(card)
Sets the card of thecard.
constcardHeader=CardService.newCardHeader().setTitle('Card Header Title').setSubtitle('Card Header Subtitle');constcard=CardService.newCardBuilder().setHeader(cardHeader).build();constcardWithId=CardService.newCardWithId().setCard(card);
Parameters
| Name | Type | Description |
|---|---|---|
card | Card | TheCard to use. |
Return
Card — This object, for chaining.
setCardId(id)
Sets the unique card ID of thecard.
constcardWithId=CardService.newCardWithId();// Sets the card ID of the cardWithId.cardWithId.setCardId('card_id');
Parameters
| Name | Type | Description |
|---|---|---|
id | String | The text to use. |
Return
Card — This object, for chaining.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-03 UTC.