ListUserPoolsCommand

Lists user pools and their details in the current Amazon Web Services account.

Amazon Cognito evaluates Identity and Access Management (IAM) policies in requests for this API operation. For this operation, you must use IAM credentials to authorize requests, and you must grant yourself the corresponding IAM permission in a policy.

Learn more

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { CognitoIdentityProviderClient, ListUserPoolsCommand } from "@aws-sdk/client-cognito-identity-provider"; // ES Modules import
// const { CognitoIdentityProviderClient, ListUserPoolsCommand } = require("@aws-sdk/client-cognito-identity-provider"); // CommonJS import
const client = new CognitoIdentityProviderClient(config);
const input = { // ListUserPoolsRequest
  NextToken: "STRING_VALUE",
  MaxResults: Number("int"), // required
};
const command = new ListUserPoolsCommand(input);
const response = await client.send(command);
// { // ListUserPoolsResponse
//   UserPools: [ // UserPoolListType
//     { // UserPoolDescriptionType
//       Id: "STRING_VALUE",
//       Name: "STRING_VALUE",
//       LambdaConfig: { // LambdaConfigType
//         PreSignUp: "STRING_VALUE",
//         CustomMessage: "STRING_VALUE",
//         PostConfirmation: "STRING_VALUE",
//         PreAuthentication: "STRING_VALUE",
//         PostAuthentication: "STRING_VALUE",
//         DefineAuthChallenge: "STRING_VALUE",
//         CreateAuthChallenge: "STRING_VALUE",
//         VerifyAuthChallengeResponse: "STRING_VALUE",
//         PreTokenGeneration: "STRING_VALUE",
//         UserMigration: "STRING_VALUE",
//         PreTokenGenerationConfig: { // PreTokenGenerationVersionConfigType
//           LambdaVersion: "V1_0" || "V2_0" || "V3_0", // required
//           LambdaArn: "STRING_VALUE", // required
//         },
//         CustomSMSSender: { // CustomSMSLambdaVersionConfigType
//           LambdaVersion: "V1_0", // required
//           LambdaArn: "STRING_VALUE", // required
//         },
//         CustomEmailSender: { // CustomEmailLambdaVersionConfigType
//           LambdaVersion: "V1_0", // required
//           LambdaArn: "STRING_VALUE", // required
//         },
//         KMSKeyID: "STRING_VALUE",
//       },
//       Status: "Enabled" || "Disabled",
//       LastModifiedDate: new Date("TIMESTAMP"),
//       CreationDate: new Date("TIMESTAMP"),
//     },
//   ],
//   NextToken: "STRING_VALUE",
// };

ListUserPoolsCommand Input

See ListUserPoolsCommandInput for more details

Parameter
Type
Description
MaxResults
Required
number | undefined

The maximum number of user pools that you want Amazon Cognito to return in the response.

NextToken
string | undefined

This API operation returns a limited number of results. The pagination token is an identifier that you can present in an additional API request with the same parameters. When you include the pagination token, Amazon Cognito returns the next set of items after the current list. Subsequent requests return a new pagination token. By use of this token, you can paginate through the full list of items.

ListUserPoolsCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
NextToken
string | undefined

The identifier that Amazon Cognito returned with the previous request to this operation. When you include a pagination token in your request, Amazon Cognito returns the next set of items in the list. By use of this token, you can paginate through the full list of items.

UserPools
UserPoolDescriptionType[] | undefined

An array of user pools and their configuration details.

Throws

Name
Fault
Details
InternalErrorException
server

This exception is thrown when Amazon Cognito encounters an internal error.

InvalidParameterException
client

This exception is thrown when the Amazon Cognito service encounters an invalid parameter.

NotAuthorizedException
client

This exception is thrown when a user isn't authorized.

TooManyRequestsException
client

This exception is thrown when the user has made too many requests for a given operation.

CognitoIdentityProviderServiceException
Base exception class for all service exceptions from CognitoIdentityProvider service.