:doc:`APIGateway <../../apigateway>` / Client / create_api_key

**************
create_api_key
**************



.. py:method:: APIGateway.Client.create_api_key(**kwargs)

  

  Create an ApiKey resource.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/apigateway-2015-07-09/CreateApiKey>`_  


  **Request Syntax**
  ::

    response = client.create_api_key(
        name='string',
        description='string',
        enabled=True|False,
        generateDistinctId=True|False,
        value='string',
        stageKeys=[
            {
                'restApiId': 'string',
                'stageName': 'string'
            },
        ],
        customerId='string',
        tags={
            'string': 'string'
        }
    )
    
  :type name: string
  :param name: 

    The name of the ApiKey.

    

  
  :type description: string
  :param description: 

    The description of the ApiKey.

    

  
  :type enabled: boolean
  :param enabled: 

    Specifies whether the ApiKey can be used by callers.

    

  
  :type generateDistinctId: boolean
  :param generateDistinctId: 

    Specifies whether ( ``true``) or not ( ``false``) the key identifier is distinct from the created API key value. This parameter is deprecated and should not be used.

    

  
  :type value: string
  :param value: 

    Specifies a value of the API key.

    

  
  :type stageKeys: list
  :param stageKeys: 

    DEPRECATED FOR USAGE PLANS - Specifies stages associated with the API key.

    

  
    - *(dict) --* 

      A reference to a unique stage identified in the format ``{restApiId}/{stage}``.

      

    
      - **restApiId** *(string) --* 

        The string identifier of the associated RestApi.

        

      
      - **stageName** *(string) --* 

        The stage name associated with the stage key.

        

      
    

  :type customerId: string
  :param customerId: 

    An Amazon Web Services Marketplace customer identifier, when integrating with the Amazon Web Services SaaS Marketplace.

    

  
  :type tags: dict
  :param tags: 

    The key-value map of strings. The valid character set is [a-zA-Z+-=._:/]. The tag key can be up to 128 characters and must not start with ``aws:``. The tag value can be up to 256 characters.

    

  
    - *(string) --* 

    
      - *(string) --* 

      


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

    
    ::

      {
          'id': 'string',
          'value': 'string',
          'name': 'string',
          'customerId': 'string',
          'description': 'string',
          'enabled': True|False,
          'createdDate': datetime(2015, 1, 1),
          'lastUpdatedDate': datetime(2015, 1, 1),
          'stageKeys': [
              'string',
          ],
          'tags': {
              'string': 'string'
          }
      }
      
    **Response Structure**

    

    - *(dict) --* 

      A resource that can be distributed to callers for executing Method resources that require an API key. API keys can be mapped to any Stage on any RestApi, which indicates that the callers with the API key can make requests to that stage.

      
      

      - **id** *(string) --* 

        The identifier of the API Key.

        
      

      - **value** *(string) --* 

        The value of the API Key.

        
      

      - **name** *(string) --* 

        The name of the API Key.

        
      

      - **customerId** *(string) --* 

        An Amazon Web Services Marketplace customer identifier, when integrating with the Amazon Web Services SaaS Marketplace.

        
      

      - **description** *(string) --* 

        The description of the API Key.

        
      

      - **enabled** *(boolean) --* 

        Specifies whether the API Key can be used by callers.

        
      

      - **createdDate** *(datetime) --* 

        The timestamp when the API Key was created.

        
      

      - **lastUpdatedDate** *(datetime) --* 

        The timestamp when the API Key was last updated.

        
      

      - **stageKeys** *(list) --* 

        A list of Stage resources that are associated with the ApiKey resource.

        
        

        - *(string) --* 
    
      

      - **tags** *(dict) --* 

        The collection of tags. Each tag element is associated with a given resource.

        
        

        - *(string) --* 
          

          - *(string) --* 
    
  
  
  **Exceptions**
  
  *   :py:class:`APIGateway.Client.exceptions.BadRequestException`

  
  *   :py:class:`APIGateway.Client.exceptions.ConflictException`

  
  *   :py:class:`APIGateway.Client.exceptions.LimitExceededException`

  
  *   :py:class:`APIGateway.Client.exceptions.NotFoundException`

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

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

  