:doc:`CognitoIdentityProvider <../../cognito-idp>` / Client / add_custom_attributes

*********************
add_custom_attributes
*********************



.. py:method:: CognitoIdentityProvider.Client.add_custom_attributes(**kwargs)

  

  Adds additional user attributes to the user pool schema. Custom attributes can be mutable or immutable and have a ``custom:`` or ``dev:`` prefix. For more information, see `Custom attributes <https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-attributes.html#user-pool-settings-custom-attributes>`__.

   

  .. 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**

     

    
    * `Signing Amazon Web Services API Requests <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_aws-signing.html>`__
     
    * `Using the Amazon Cognito user pools API and user pool endpoints <https://docs.aws.amazon.com/cognito/latest/developerguide/user-pools-API-operations.html>`__
    

    

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/cognito-idp-2016-04-18/AddCustomAttributes>`_  


  **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'
                }
            },
        ]
    )
    
  :type UserPoolId: string
  :param UserPoolId: **[REQUIRED]** 

    The ID of the user pool where you want to add custom attributes.

    

  
  :type CustomAttributes: list
  :param CustomAttributes: **[REQUIRED]** 

    An array of custom attribute names and other properties. Sets the following characteristics:

      AttributeDataType  

    The expected data type. Can be a string, a number, a date and time, or a boolean.

      Mutable  

    If true, you can grant app clients write access to the attribute value. If false, the attribute value can only be set up on sign-up or administrator creation of users.

      Name  

    The attribute name. For an attribute like ``custom:myAttribute``, enter ``myAttribute`` for this field.

      Required  

    When true, users who sign up or are created must set a value for the attribute.

      NumberAttributeConstraints  

    The minimum and maximum length of accepted values for a ``Number``-type attribute.

      StringAttributeConstraints  

    The minimum and maximum length of accepted values for a ``String``-type attribute.

      DeveloperOnlyAttribute  

    This legacy option creates an attribute with a ``dev:`` prefix. You can only set the value of a developer-only attribute with administrative IAM credentials.

    

  
    - *(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 a ``dev:`` prefix. For more information, see `User pool attributes <https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-attributes.html>`__.

       

      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.

      

    
      - **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 of ``MyAttribute``, Amazon Cognito creates the custom attribute ``custom:MyAttribute``. When ``DeveloperOnlyAttribute`` is ``true``, Amazon Cognito creates your attribute as ``dev:MyAttribute``. In an operation that describes a user pool, Amazon Cognito returns this value as ``value`` for standard attributes, ``custom:value`` for custom attributes, and ``dev: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 <https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_UserPoolClientType.html#CognitoUserPools-Type-UserPoolClientType-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 <https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-specifying-attribute-mapping.html>`__.

        

      
      - **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.

          

        
      
    

  
  :rtype: dict
  :returns: 
    
    **Response Syntax**

    
    ::

      {}
      
    **Response Structure**

    

    - *(dict) --* 

      Represents the response from the server for the request to add custom attributes.

      
  
  **Exceptions**
  
  *   :py:class:`CognitoIdentityProvider.Client.exceptions.ResourceNotFoundException`

  
  *   :py:class:`CognitoIdentityProvider.Client.exceptions.InvalidParameterException`

  
  *   :py:class:`CognitoIdentityProvider.Client.exceptions.TooManyRequestsException`

  
  *   :py:class:`CognitoIdentityProvider.Client.exceptions.NotAuthorizedException`

  
  *   :py:class:`CognitoIdentityProvider.Client.exceptions.UserImportInProgressException`

  
  *   :py:class:`CognitoIdentityProvider.Client.exceptions.InternalErrorException`

  