SignUp - Amazon Cognito User Pools

SignUp

Registers the user in the specified user pool and creates a user name, password, and user attributes.

Note

Amazon Cognito doesn't evaluate AWS Identity and Access Management (IAM) policies in requests for this API operation. For this operation, you can't use IAM credentials to authorize requests, and you can't grant IAM permissions in policies. For more information about authorization models in Amazon Cognito, see Using the Amazon Cognito user pools API and user pool endpoints.

Note

This action might generate an SMS text message. Starting June 1, 2021, US telecom carriers require you to register an origination phone number before you can send SMS messages to US phone numbers. If you use SMS text messages in Amazon Cognito, you must register a phone number with Amazon Pinpoint. Amazon Cognito uses the registered number automatically. Otherwise, Amazon Cognito users who must receive SMS messages might not be able to sign up, activate their accounts, or sign in.

If you have never used SMS text messages with Amazon Cognito or any other AWS service, Amazon Simple Notification Service might place your account in the SMS sandbox. In sandbox mode , you can send messages only to verified phone numbers. After you test your app while in the sandbox environment, you can move out of the sandbox and into production. For more information, see SMS message settings for Amazon Cognito user pools in the Amazon Cognito Developer Guide.

Request Syntax

{ "AnalyticsMetadata": { "AnalyticsEndpointId": "string" }, "ClientId": "string", "ClientMetadata": { "string" : "string" }, "Password": "string", "SecretHash": "string", "UserAttributes": [ { "Name": "string", "Value": "string" } ], "UserContextData": { "EncodedData": "string", "IpAddress": "string" }, "Username": "string", "ValidationData": [ { "Name": "string", "Value": "string" } ] }

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.

AnalyticsMetadata

The Amazon Pinpoint analytics metadata that contributes to your metrics for SignUp calls.

Type: AnalyticsMetadataType object

Required: No

ClientId

The ID of the client associated with the user pool.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: [\w+]+

Required: Yes

ClientMetadata

A map of custom key-value pairs that you can provide as input for any custom workflows that this action triggers.

You create custom workflows by assigning AWS Lambda functions to user pool triggers. When you use the SignUp API action, Amazon Cognito invokes any functions that are assigned to the following triggers: pre sign-up, custom message, and post confirmation. When Amazon Cognito invokes any of these functions, it passes a JSON payload, which the function receives as input. This payload contains a clientMetadata attribute, which provides the data that you assigned to the ClientMetadata parameter in your SignUp request. In your function code in Lambda, you can process the clientMetadata value to enhance your workflow for your specific needs.

For more information, see Customizing user pool Workflows with Lambda Triggers in the Amazon Cognito Developer Guide.

Note

When you use the ClientMetadata parameter, remember that Amazon Cognito won't do the following:

  • Store the ClientMetadata value. This data is available only to AWS Lambda triggers that are assigned to a user pool to support custom workflows. If your user pool configuration doesn't include triggers, the ClientMetadata parameter serves no purpose.

  • Validate the ClientMetadata value.

  • Encrypt the ClientMetadata value. Don't use Amazon Cognito to provide sensitive information.

Type: String to string map

Key Length Constraints: Minimum length of 0. Maximum length of 131072.

Value Length Constraints: Minimum length of 0. Maximum length of 131072.

Required: No

Password

The password of the user you want to register.

Type: String

Length Constraints: Maximum length of 256.

Pattern: [\S]+

Required: Yes

SecretHash

A keyed-hash message authentication code (HMAC) calculated using the secret key of a user pool client and username plus the client ID in the message.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: [\w+=/]+

Required: No

UserAttributes

An array of name-value pairs representing user attributes.

For custom attributes, you must prepend the custom: prefix to the attribute name.

Type: Array of AttributeType objects

Required: No

UserContextData

Contextual data about your user session, such as the device fingerprint, IP address, or location. Amazon Cognito advanced security evaluates the risk of an authentication event based on the context that your app generates and passes to Amazon Cognito when it makes API requests.

Type: UserContextDataType object

Required: No

Username

The username of the user that you want to sign up. The value of this parameter is typically a username, but can be any alias attribute in your user pool.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: [\p{L}\p{M}\p{S}\p{N}\p{P}]+

Required: Yes

ValidationData

Temporary user attributes that contribute to the outcomes of your pre sign-up Lambda trigger. This set of key-value pairs are for custom validation of information that you collect from your users but don't need to retain.

Your Lambda function can analyze this additional data and act on it. Your function might perform external API operations like logging user attributes and validation data to Amazon CloudWatch Logs. Validation data might also affect the response that your function returns to Amazon Cognito, like automatically confirming the user if they sign up from within your network.

For more information about the pre sign-up Lambda trigger, see Pre sign-up Lambda trigger.

Type: Array of AttributeType objects

Required: No

Response Syntax

{ "CodeDeliveryDetails": { "AttributeName": "string", "DeliveryMedium": "string", "Destination": "string" }, "UserConfirmed": boolean, "UserSub": "string" }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

CodeDeliveryDetails

The code delivery details returned by the server response to the user registration request.

Type: CodeDeliveryDetailsType object

UserConfirmed

A response from the server indicating that a user registration has been confirmed.

Type: Boolean

UserSub

The UUID of the authenticated user. This isn't the same as username.

Type: String

Length Constraints: Minimum length of 0. Maximum length of 131072.

Errors

For information about the errors that are common to all actions, see Common Errors.

CodeDeliveryFailureException

This exception is thrown when a verification code fails to deliver successfully.

HTTP Status Code: 400

ForbiddenException

This exception is thrown when AWS WAF doesn't allow your request based on a web ACL that's associated with your user pool.

HTTP Status Code: 400

InternalErrorException

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

HTTP Status Code: 500

InvalidEmailRoleAccessPolicyException

This exception is thrown when Amazon Cognito isn't allowed to use your email identity. HTTP status code: 400.

HTTP Status Code: 400

InvalidLambdaResponseException

This exception is thrown when Amazon Cognito encounters an invalid AWS Lambda response.

HTTP Status Code: 400

InvalidParameterException

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

HTTP Status Code: 400

InvalidPasswordException

This exception is thrown when Amazon Cognito encounters an invalid password.

HTTP Status Code: 400

InvalidSmsRoleAccessPolicyException

This exception is returned when the role provided for SMS configuration doesn't have permission to publish using Amazon SNS.

HTTP Status Code: 400

InvalidSmsRoleTrustRelationshipException

This exception is thrown when the trust relationship is not valid for the role provided for SMS configuration. This can happen if you don't trust cognito-idp.amazonaws.com or the external ID provided in the role does not match what is provided in the SMS configuration for the user pool.

HTTP Status Code: 400

NotAuthorizedException

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

HTTP Status Code: 400

ResourceNotFoundException

This exception is thrown when the Amazon Cognito service can't find the requested resource.

HTTP Status Code: 400

TooManyRequestsException

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

HTTP Status Code: 400

UnexpectedLambdaException

This exception is thrown when Amazon Cognito encounters an unexpected exception with AWS Lambda.

HTTP Status Code: 400

UserLambdaValidationException

This exception is thrown when the Amazon Cognito service encounters a user validation exception with the AWS Lambda service.

HTTP Status Code: 400

UsernameExistsException

This exception is thrown when Amazon Cognito encounters a user name that already exists in the user pool.

HTTP Status Code: 400

Examples

Example

A sign-up request for the user mary_major.

Sample Request

POST HTTP/1.1 Host: cognito-idp.us-east-1.amazonaws.com X-Amz-Date: 20230613T200059Z Accept-Encoding: gzip, deflate, br X-Amz-Target: AWSCognitoIdentityProviderService.SignUp User-Agent: <UserAgentString> Authorization: AWS4-HMAC-SHA256 Credential=<Credential>, SignedHeaders=<Headers>, Signature=<Signature> Content-Length: <PayloadSizeBytes> { "ClientId": "1example23456789", "Username": "mary_major", "Password": "<Password>", "SecretHash": "<Secret hash>", "UserAttributes": [ { "Name": "name", "Value": "Mary" }, { "Name": "email", "Value": "mary_major@example.com" }, { "Name": "phone_number", "Value": "+12065551212" } ] }

Sample Response

HTTP/1.1 200 OK Date: Tue, 13 Jun 2023 20:00:59 GMT Content-Type: application/x-amz-json-1.0 Content-Length: <PayloadSizeBytes> x-amzn-requestid: a1b2c3d4-e5f6-a1b2-c3d4-EXAMPLE11111 Connection: keep-alive { "CodeDeliveryDetails": { "AttributeName": "email", "DeliveryMedium": "EMAIL", "Destination": "m***@e***" }, "UserConfirmed": false, "UserSub": "44284a5f-66af-4888-b582-fccc213c51fd" }

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: