Delete a custom emoji

This guide explains how to use the delete method on the CustomEmoji resource of the Google Chat API to delete a custom emoji in a Google Workspace organization.

By default, users can only delete custom emoji they created. Emoji managers assigned by the administrator can delete any custom emoji in the organization.

Custom emojis are only available for Google Workspace accounts, and your administrator must turn custom emoji on for your organization. For more information, see Learn about custom emoji in Google Chat and Manage custom emoji permissions .

Prerequisites

Node.js

Delete a custom emoji

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

  • Specify the chat.customemojis authorization scope.
  • Call the DeleteCustomEmoji() method.
    • In the request body, set name to the resource name of the custom emoji to delete.

The following example deletes a custom emoji.

Node.js

chat/client-libraries/cloud/delete-custom-emoji-user-cred.js
 import 
  
 { 
 createClientWithUserCredentials 
 } 
  
 from 
  
 './authentication-utils.js' 
 ; 
 const 
  
 USER_AUTH_OAUTH_SCOPES 
  
 = 
  
 [ 
 'https://www.googleapis.com/auth/chat.customemojis' 
 ]; 
 // This sample shows how to delete a custom emoji with user credential 
 async 
  
 function 
  
 main 
 () 
  
 { 
  
 // Create a client 
  
 const 
  
 chatClient 
  
 = 
  
 await 
  
 createClientWithUserCredentials 
 ( 
 USER_AUTH_OAUTH_SCOPES 
 ); 
  
 // Initialize request argument(s) 
  
 const 
  
 request 
  
 = 
  
 { 
  
 // TODO(developer): Replace EMOJI_NAME here. 
  
 name 
 : 
  
 'customEmojis/EMOJI_NAME' 
  
 }; 
  
 // Make the request 
  
 const 
  
 response 
  
 = 
  
 await 
  
 chatClient 
 . 
 deleteCustomEmoji 
 ( 
 request 
 ); 
  
 // Handle the response 
  
 console 
 . 
 log 
 ( 
 response 
 ); 
 } 
 main 
 (). 
 catch 
 ( 
 console 
 . 
 error 
 ); 

To run this sample, replace the following:

  • EMOJI_NAME : the unique name for your custom emoji, in the emoji_name field. You can obtain the ID by calling the ListCustomEmoji method, or from the response body returned after creating a custom emoji asynchronously with the Chat API.
Create a Mobile Website
View Site in Mobile | Classic
Share by: