Delete a message (original) (raw)

This guide explains how to use thedelete()method on the Message resource of the Google Chat API to delete a text or card message.

In the Chat API, a Chat message is represented by theMessage resource. While Chat users can only send messages that contain text, Chat apps can use many other messaging features, including displaying static or interactive user interfaces, collecting information from users, and delivering messages privately. To learn more about messaging features available for the Chat API, see theGoogle Chat messages overview.

With app authentication, you can use this method to delete a message that the Chat app sent. Withuser authentication, you can use this method to delete a message that the authenticated user sent. If the user is a space manager for the space, you might also be able to delete a message that other space members sent. For more information, see Learn about your role as a Space Manager.

Prerequisites

Node.js

Python

Java

Apps Script

Delete a message with user authentication

To delete a message with user authentication, pass the following in your request:

The following example deletes a message withuser authentication:

Node.js

Python

Java

Apps Script

To run this sample, replace the following:

If successful, the response body is empty, which indicates that the message is deleted.

Delete a message with app authentication

To delete a message withapp authentication, pass the following in your request:

The following example deletes a message withapp authentication:

Node.js

Python

Java

Apps Script

To run this sample, replace the following:

If successful, the response body is empty, which indicates that the message is deleted.