Set up API keys using the API Gateway REST API - Amazon API Gateway

Set up API keys using the API Gateway REST API

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. After you create an API key value, it cannot be changed.

For the REST API calls to create and deploy an API, see restapi:create and deployment:create, respectively.

Note

For best practices to consider, see Best practices for API keys and usage plans.

Require an API key on a method

To require an API key on a method, do one of the following:

  • Call method:put to create a method. Set apiKeyRequired to true in the request payload.

  • Call method:update to set apiKeyRequired to true.

Create or import API keys

To create or import an API key, do one of the following:

You cannot change the value of the new API key. To learn how to configure a usage plan, see Create, configure, and test usage plans using the API Gateway CLI and REST API.