Menu
Amazon API Gateway
Developer Guide

Create, Configure, and Test Usage Plans with the API Gateway Console

Before creating a usage plan, make sure you have set up the desired API keys. For more information, see Set Up API Keys Using the API Gateway Console.

This section describes steps needed to create and use a usage plan using the API Gateway console.

Migrate to Default Usage Plans

If you start to use API Gateway after the Usage Plans feature was rolled out on August 11, 2016, you will automatically have usage plans enabled for you in all supported regions.

If you started to use API Gateway before then, you will be prompted with the Enable Usage Plans option before using Usage Plans for the first time in the selected region. By enabling this option, you will have default usage plans created for every unique API stage associated with existing API keys. In the default usage plan, no throttle and quota limits are set initially, existing API keys are converted to a collection of UsagePlanKey resources, and existing API keys are converted to API stage Ids. The API will behave the same as before. However, you must use the UsagePlan apiStages property to associate specified API stage values (apiId and stage) with included API keys (via UsagePlanKey), instead of using the ApiKey stageKeys property.

Create Usage Plans

The following procedure describes how to create a usage plan.

To create a usage plan

  1. In the Amazon API Gateway main navigation pane, choose Usage Plans, and then choose Create.

  2. Under Create Usage Plan, do the following:

    1. For Name, type a name for your plan (e.g., Plan_A).

    2. For Description, type a description for your plan.

    3. Select Enable throttling and set Rate (e.g., 100) and Burst (e.g., 200).

    4. Choose Enable quota and set its limit (e.g., 5000) for a selected time interval (e.g., Month).

    5. Choose Save.

    
                                    API usage plan entities
  3. To add a stage to the plan, do the following in the Associated API Stages pane:

    1. Choose Add API Stage.

    2. Choose an API (e.g., PetStore) from the API drop-down list.

    3. Choose a stage (e.g., Stage_1) from the Stage drop-down list.

    4. Choose the check-mark icon to save.

    5. Choose Next.

    
                                    API usage plan entities
  4. To add a key to the plan, do the following in the Usage Plan API Keys pane:

    1. To use an existing key, choose Add API Key to Usage Plan.

    2. For Name, type a name for the key you want to add (e.g., MyFirstKey).

    3. Choose the check-mark icon to save.

    4. If desired, repeat the preceding steps to add other existing API keys to this usage plan.

    
                                    API usage plan entities

    Note

    To add a new API key to the usage plan, choose Create API Key and add to Usage Plan and follow the instructions.

  5. To finish creating the usage plan, choose Done.

  6. If you want to add more API stages to the usage plan, choose Add API Stage to repeat the preceding steps.

Test a Usage Plan

To test the usage plan, you can use an AWS SDK, AWS CLI, or a REST API client like Postman. For an example of using Postman to test the usage plan, see Test Usage Plans.

Maintain Plan Usage

Maintaining a usage plan involves monitoring the used and remaining quotas over a given time period and extending the remaining quotas by a specified amount. The following procedures describe how to monitor and extend quotas.

To monitor used and remaining quotas

  1. In the API Gateway main navigation pane, choose Usage Plans.

  2. Choose a usage plan from the list of the usage plans in the secondary navigation pane in the middle.

  3. From within the specified plan, choose API Keys.

  4. Choose an API key. Then choose Usage to view Subscriber's Traffic from the plan you are monitoring.

  5. Optionally, choose Export, choose a From date and a To date, choose JSON or CSV for the exported data format, and then choose Export.

    The following example shows an exported file.

    Copy
    { "thisPeriod": { "px1KW6...qBazOJH": [ [ 0, 5000 ], [ 0, 5000 ], [ 0, 10 ] ] }, "startDate": "2016-08-01", "endDate": "2016-08-03" }

    The usage data in the example shows the daily usage data for an API client, as identified by the API key (px1KW6...qBazOJH), between August 1, 2016, and August 3, 2016. Each daily usage data shows used and remaining quotas. In this example, the subscriber has not yet used any allotted quotas and the API owner or administrator has reduced the remaining quota from 5000 to 10 on the third day.

To extend the remaining quotas

  1. Repeat steps 1-3 of the previous procedure.

  2. On the usage plan page, choose Extension from the usage plan window.

  3. Type a number for the Remaining request quotas.

  4. Choose Save.