Create a custom emoji

This guide explains how to use the create method on the CustomEmoji resource of the Google Chat API to create a new custom emoji in a Google Workspace 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

Create a custom emoji

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

  • Specify the chat.customemojis authorization scope.
  • Call the CreateCustomEmoji method.
  • In the request body, provide a CustomEmoji resource, setting the emojiName (a unique identifier you choose for the emoji) and payload (image content you choose for the emoji).

The following example creates a custom emoji:

Node.js

chat/client-libraries/cloud/create-custom-emoji-user-cred.js
importfsfrom'node:fs';
import{createClientWithUserCredentials}from'./authentication-utils.js';
constUSER_AUTH_OAUTH_SCOPES=[
'https://www.googleapis.com/auth/chat.customemojis',
];
// This sample shows how to create custom emoji with user credential
asyncfunctionmain(){
// Create a client
constchatClient=awaitcreateClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// TODO(developer) Replace FILENAME here.
constfilename='FILENAME';
// Read custom emoji file content into a base64 encoded string.
constfileContent=fs.readFileSync(filename,{encoding:'base64'});
// Initialize request argument(s)
constrequest={
custom_emoji:{
// TODO(developer): Replace EMOJI_NAME here.
emoji_name:'EMOJI_NAME',
payload:{
file_content:fileContent,
filename,
},
},
};
// Make the request
constresponse=awaitchatClient.createCustomEmoji(request);
// Handle the response
console.log(response);
}
awaitmain();

To run this sample, replace the following:

  • FILENAME: A filename of the image.
  • EMOJI_NAME: A unique name for your custom emoji, like :smiley-face:.

The Chat API returns an instance of CustomEmoji that details the custom emoji 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 2025年10月13日 UTC.