Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Listing users in a collection

Focus mode
Listing users in a collection - Amazon Rekognition

You can use the ListUsers operation to list UserIds and the UserStatus. To see the FaceIDs that are associated with a UserID, use the ListFaces operation.

To list users (SDK)
  1. If you haven't already:

    1. Create or update a user with AmazonRekognitionFullAccess permissions. For more information, see Step 1: Set up an AWS account and create a User.

    2. Install and configure the AWS CLI and the AWS SDKs. For more information, see Step 2: Set up the AWS CLI and AWS SDKs.

  2. Use the following examples to call the ListUsers operation.

    Java

    This Java example lists the users in a collection using the ListUsers operation.

    import java.util.List; import com.amazonaws.services.rekognition.AmazonRekognition; import com.amazonaws.services.rekognition.AmazonRekognitionClientBuilder; import com.amazonaws.services.rekognition.model.ListUsersRequest; import com.amazonaws.services.rekognition.model.ListUsersResult; import com.amazonaws.services.rekognition.model.User; public class ListUsers { public static void main(String[] args) throws Exception { AmazonRekognition amazonRekognition = AmazonRekognitionClientBuilder.defaultClient(); System.out.println("Listing users"); int limit = 10; ListUsersResult listUsersResult = null; String paginationToken = null; do { if (listUsersResult != null) { paginationToken = listUsersResult.getNextToken(); } ListUsersRequest request = new ListUsersRequest() .withCollectionId(collectionId) .withMaxResults(limit) .withNextToken(paginationToken); listUsersResult = amazonRekognition.listUsers(request); List<User> users = listUsersResult.getUsers(); for (User currentUser: users) { System.out.println(currentUser.getUserId() + " : " + currentUser.getUserStatus()); } } while (listUsersResult.getNextToken() != null); } }
    AWS CLI

    This AWS CLI command lists the users in a collection with the ListUsers operation.

    aws rekognition list-users --collection-id collection-id --max-results number-of-max-results
    Python

    The following example lists the users in a collection with the ListUsers operation.

    # Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. # PDX-License-Identifier: MIT-0 (For details, see https://github.com/awsdocs/amazon-rekognition-developer-guide/blob/master/LICENSE-SAMPLECODE.) import boto3 from botocore.exceptions import ClientError import logging from pprint import pprint logger = logging.getLogger(__name__) session = boto3.Session(profile_name='profile-name') client = session.client('rekognition') def list_users(collection_id): """ List all users from the given collection :param collection_id: The ID of the collection where user is stored. :return: response that contains list of Users found within given collection """ logger.info(f'Listing the users in collection: {collection_id}') try: response = client.list_users( CollectionId=collection_id ) pprint(response["Users"]) except ClientError: logger.exception(f'Failed to list all user from given collection: {collection_id}') raise else: return response def main(): collection_id = "collection-id" list_users(collection_id) if __name__ == "__main__": main()

    This Java example lists the users in a collection using the ListUsers operation.

    import java.util.List; import com.amazonaws.services.rekognition.AmazonRekognition; import com.amazonaws.services.rekognition.AmazonRekognitionClientBuilder; import com.amazonaws.services.rekognition.model.ListUsersRequest; import com.amazonaws.services.rekognition.model.ListUsersResult; import com.amazonaws.services.rekognition.model.User; public class ListUsers { public static void main(String[] args) throws Exception { AmazonRekognition amazonRekognition = AmazonRekognitionClientBuilder.defaultClient(); System.out.println("Listing users"); int limit = 10; ListUsersResult listUsersResult = null; String paginationToken = null; do { if (listUsersResult != null) { paginationToken = listUsersResult.getNextToken(); } ListUsersRequest request = new ListUsersRequest() .withCollectionId(collectionId) .withMaxResults(limit) .withNextToken(paginationToken); listUsersResult = amazonRekognition.listUsers(request); List<User> users = listUsersResult.getUsers(); for (User currentUser: users) { System.out.println(currentUser.getUserId() + " : " + currentUser.getUserStatus()); } } while (listUsersResult.getNextToken() != null); } }

ListUsers operation response

The response for a request to ListUsers includes a list of the Users in the collection along with the UsedId and UserStatus of the User.

{ "NextToken": "B1asJT3bAb/ttuGgPFV8BZoBZyGQzlUHXbuTNLh48a6enU7kXKw43hpOwizW7LOk/Gk7Em09lznoq6+FcDCcSq2olrn7A98BLkt5keu+ZRVRUTyrXtT6J7Hmp+ieQ2an6Zu0qzPfcdPeaJ9eAxG2d0WNrzJgi5hvmjoiSTTfKX3MQz1sduWQkvAAs4hZfhZoKFahFlqWofshCXa/FHAAY3PL1PjxXbkNeSSMq8V7i1MlKCdrPVykCv9MokpPt7jtNvKPEZGUhxgBTFMxNWLEcFnzAiCWDg91dFy/LalshPjXA9UVc5Gx9vIJNQ/eO3cQRghAkCT3FOAiXsLAnA015ODTomZpWWVpqB21wKpI3LYmfAVFrDPGzpbTVlRmLsJm41bkmnBBBw9+DHz1Jn7zW+qc5Fs3yaHu0f51Xg==", "Users": [ { "UserId": "demoUser4", "UserStatus": "CREATED" }, { "UserId": "demoUser2", "UserStatus": "CREATED" } ] }

On this page

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.