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.
For the REST API calls to create and deploy an API,
see restapi:create
and deployment:create
, respectively.
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. SetapiKeyRequired
totrue
in the request payload. -
Call
method:update
to setapiKeyRequired
totrue
.
Create or import API keys
To create or import an API key, do one of the following:
-
Call
apikey:create
to create an API key. -
Call
apikey:import
to import an API key from a file. For the file format, see API Gateway API key file format.
With the API key created, you can now proceed to Create, configure, and test usage plans using the API Gateway CLI and REST API.