CognitoIdentityProvider / Client / add_custom_attributes
add_custom_attributes#
- CognitoIdentityProvider.Client.add_custom_attributes(**kwargs)#
Adds additional user attributes to the user pool schema.
Note
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
See also: AWS API Documentation
Request Syntax
response = client.add_custom_attributes( UserPoolId='string', CustomAttributes=[ { 'Name': 'string', 'AttributeDataType': 'String'|'Number'|'DateTime'|'Boolean', 'DeveloperOnlyAttribute': True|False, 'Mutable': True|False, 'Required': True|False, 'NumberAttributeConstraints': { 'MinValue': 'string', 'MaxValue': 'string' }, 'StringAttributeConstraints': { 'MinLength': 'string', 'MaxLength': 'string' } }, ] )
- Parameters:
UserPoolId (string) –
[REQUIRED]
The user pool ID for the user pool where you want to add custom attributes.
CustomAttributes (list) –
[REQUIRED]
An array of custom attributes, such as Mutable and Name.
(dict) –
A list of the user attributes and their properties in your user pool. The attribute schema contains standard attributes, custom attributes with a
custom:
prefix, and developer attributes with adev:
prefix. For more information, see User pool attributes.Developer-only
dev:
attributes are a legacy feature of user pools, and are read-only to all app clients. You can create and update developer-only attributes only with IAM-authenticated API operations. Use app client read/write permissions instead.This data type is a request and response parameter of CreateUserPool and UpdateUserPool, and a response parameter of DescribeUserPool.
Name (string) –
The name of your user pool attribute. When you create or update a user pool, adding a schema attribute creates a custom or developer-only attribute. When you add an attribute with a
Name
value ofMyAttribute
, Amazon Cognito creates the custom attributecustom:MyAttribute
. WhenDeveloperOnlyAttribute
istrue
, Amazon Cognito creates your attribute asdev:MyAttribute
. In an operation that describes a user pool, Amazon Cognito returns this value asvalue
for standard attributes,custom:value
for custom attributes, anddev:value
for developer-only attributes..AttributeDataType (string) –
The data format of the values for your attribute. When you choose an
AttributeDataType
, Amazon Cognito validates the input against the data type. A custom attribute value in your user’s ID token is always a string, for example"custom:isMember" : "true"
or"custom:YearsAsMember" : "12"
.DeveloperOnlyAttribute (boolean) –
Note
You should use WriteAttributes in the user pool client to control how attributes can be mutated for new use cases instead of using
DeveloperOnlyAttribute
.Specifies whether the attribute type is developer only. This attribute can only be modified by an administrator. Users won’t be able to modify this attribute using their access token. For example,
DeveloperOnlyAttribute
can be modified using AdminUpdateUserAttributes but can’t be updated using UpdateUserAttributes.Mutable (boolean) –
Specifies whether the value of the attribute can be changed.
Any user pool attribute whose value you map from an IdP attribute must be mutable, with a parameter value of
true
. Amazon Cognito updates mapped attributes when users sign in to your application through an IdP. If an attribute is immutable, Amazon Cognito throws an error when it attempts to update the attribute. For more information, see Specifying Identity Provider Attribute Mappings for Your User Pool.Required (boolean) –
Specifies whether a user pool attribute is required. If the attribute is required and the user doesn’t provide a value, registration or sign-in will fail.
NumberAttributeConstraints (dict) –
Specifies the constraints for an attribute of the number type.
MinValue (string) –
The minimum value of an attribute that is of the number data type.
MaxValue (string) –
The maximum length of a number attribute value. Must be a number less than or equal to
2^1023
, represented as a string with a length of 131072 characters or fewer.
StringAttributeConstraints (dict) –
Specifies the constraints for an attribute of the string type.
MinLength (string) –
The minimum length of a string attribute value.
MaxLength (string) –
The maximum length of a string attribute value. Must be a number less than or equal to
2^1023
, represented as a string with a length of 131072 characters or fewer.
- Return type:
dict
- Returns:
Response Syntax
{}
Response Structure
(dict) –
Represents the response from the server for the request to add custom attributes.
Exceptions
CognitoIdentityProvider.Client.exceptions.ResourceNotFoundException
CognitoIdentityProvider.Client.exceptions.InvalidParameterException
CognitoIdentityProvider.Client.exceptions.TooManyRequestsException
CognitoIdentityProvider.Client.exceptions.NotAuthorizedException
CognitoIdentityProvider.Client.exceptions.UserImportInProgressException
CognitoIdentityProvider.Client.exceptions.InternalErrorException