List custom emojis in an organization

This guide explains how to use the list method on the CustomEmoji resource of the Google Chat API to list custom emoji visible to the authenticated user 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

List custom emoji in an organization

To list custom emoji in an organization with user authentication, pass the following in your request:

  • Specify the chat.customemojis authorization scope.
  • Call the ListCustomEmojis method.

The following example list custom emoji in an organization.

Node.js

chat/client-libraries/cloud/list-custom-emojis-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 get 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 = {
    // Optional. Replace FILTER here
    filter: 'FILTER'
  };

  // Make the request
  const pageResult = await chatClient.listCustomEmojisAsync(request);

  // Handle the response. Iterating over pageResult will yield results and
  // resolve additional pages automatically.
  for await (const response of pageResult) {
    console.log(response);
  }
}

main().catch(console.error);

To run this sample, replace the following:

  • FILTER: Optional, the filter to apply to the list request.