Menu
Amazon API Gateway
Developer Guide

Set Up API Keys Using the API Gateway Console

To set up API keys, do the following:

  • Configure API methods to require an API key.

  • Create or import an API key for the API in a region.

Before setting up API keys, you must have created an API and deployed it to a stage.

For instructions on how to create and deploy an API using the API Gateway console, see Creating an API and Deploying an API, respectively.

Require API Key on a Method

The following procedure describes how to configure an API method to require an API key.

To configure an API method to require an API key

  1. Sign in to the AWS Management Console and open the API Gateway console at https://console.aws.amazon.com/apigateway/.

  2. In the API Gateway main navigation pane, choose Resources.

  3. Under Resources, create a new method or choose an existing one.

  4. Choose Method Request.

  5. Under the Authorization Settings section, choose true for API Key Required.

  6. Select the check-mark icon to save the settings.

  7. Deploy or redeploy the API for the requirement to take effect.

If the API Key Required option is set to false and you do not execute the steps above, any API key associated with an API stage will not used for the method.

Create an API Key

If you have already created or imported API keys for use with usage plans, you can skip this and the next procedure.

To create an API key

  1. Sign in to the AWS Management Console and open the API Gateway console at https://console.aws.amazon.com/apigateway/.

  2. In the API Gateway main navigation pane, choose API Keys.

  3. From the Actions drop-down menu, choose Create API key.

    
                                    Create API keys for usage plans
  4. In Create API Key, do the following:

    1. Type an API key name (e.g., MyFirstKey) in the Name input field.

    2. Choose Auto Generate to have API Gateway to generate the key value or choose Custom to enter the key manually.

    3. Choose Save.

    
                                    Create API keys for usage plans
  5. Repeat the preceding steps to create more API keys, if needed.

Import API Keys

The following procedure describes how to import API keys to use with usage plans.

To import API keys

  1. In the main navigation pane, choose API Keys.

  2. From the Actions drop-down menu, choose Import API keys.

  3. To load a comma-separated key file, choose Select CSV File. You can also type the keys manually. For information about the file format, see API Gateway API Key File Format.

    
                                    API usage plan entities
  4. Choose Fail on warnings to stop import when there is an error, or choose Ignore warnings to continue to import valid key entries when there is an error.

  5. To start importing the selected API keys, choose Import.

Now that you have set up the API key, you can proceed to create and use a usage plan.