:doc:`IoT <../../iot>` / Client / create_policy

*************
create_policy
*************



.. py:method:: IoT.Client.create_policy(**kwargs)

  

  Creates an IoT policy.

   

  The created policy is the default version for the policy. This operation creates a policy version with a version identifier of **1** and sets **1** as the policy's default version.

   

  Requires permission to access the `CreatePolicy <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions>`__ action.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/iot-2015-05-28/CreatePolicy>`_  


  **Request Syntax**
  ::

    response = client.create_policy(
        policyName='string',
        policyDocument='string',
        tags=[
            {
                'Key': 'string',
                'Value': 'string'
            },
        ]
    )
    
  :type policyName: string
  :param policyName: **[REQUIRED]** 

    The policy name.

    

  
  :type policyDocument: string
  :param policyDocument: **[REQUIRED]** 

    The JSON document that describes the policy. **policyDocument** must have a minimum length of 1, with a maximum length of 2048, excluding whitespace.

    

  
  :type tags: list
  :param tags: 

    Metadata which can be used to manage the policy.

     

    .. note::

      

      For URI Request parameters use format: ...key1=value1&key2=value2...

       

      For the CLI command-line parameter use format: &&tags "key1=value1&key2=value2..."

       

      For the cli-input-json file use format: "tags": "key1=value1&key2=value2..."

      

    

  
    - *(dict) --* 

      A set of key/value pairs that are used to manage the resource.

      

    
      - **Key** *(string) --* **[REQUIRED]** 

        The tag's key.

        

      
      - **Value** *(string) --* 

        The tag's value.

        

      
    

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

    
    ::

      {
          'policyName': 'string',
          'policyArn': 'string',
          'policyDocument': 'string',
          'policyVersionId': 'string'
      }
      
    **Response Structure**

    

    - *(dict) --* 

      The output from the CreatePolicy operation.

      
      

      - **policyName** *(string) --* 

        The policy name.

        
      

      - **policyArn** *(string) --* 

        The policy ARN.

        
      

      - **policyDocument** *(string) --* 

        The JSON document that describes the policy.

        
      

      - **policyVersionId** *(string) --* 

        The policy version ID.

        
  
  **Exceptions**
  
  *   :py:class:`IoT.Client.exceptions.ResourceAlreadyExistsException`

  
  *   :py:class:`IoT.Client.exceptions.MalformedPolicyException`

  
  *   :py:class:`IoT.Client.exceptions.InvalidRequestException`

  
  *   :py:class:`IoT.Client.exceptions.ThrottlingException`

  
  *   :py:class:`IoT.Client.exceptions.UnauthorizedException`

  
  *   :py:class:`IoT.Client.exceptions.ServiceUnavailableException`

  
  *   :py:class:`IoT.Client.exceptions.InternalFailureException`

  