Amazon API Gateway REST API Reference

usageplankey:create

Creates a UsagePlanKey resource to associate an existing API key to the specified usage plan.

HTTP Request

POST /usageplans/<usageplanId>/keys

Request Body

{
  "keyId" : "String",
  "keyType" : "String"
}

Request Body Fields

The request accepts the following fields in JSON format.

  • keyId
  • The identifier of a UsagePlanKey resource for a plan customer.

  • keyType
  • The type of a UsagePlanKey resource for a plan customer.

Response

UsagePlanKey

Remarks

When creating a UsagePlanKey resource, you must specify a known ApiKey Id as the keyId value in the payload.

Error Code

The request may throw the following exceptions:

Example

The following example creates a UsagePlanKey resource to associate an ApiKey (q5ugs7qjjh) to a UsagePlan (n371pt).

Request
POST /usageplans/n371pt/keys HTTP/1.1
Content-Type: application/json
Host: apigateway.us-east-1.amazonaws.com
X-Amz-Date: 20160805T181755Z
Authorization: AWS4-HMAC-SHA256 Credential={access_key_ID}/20160805/us-east-1/apigateway/aws4_request, SignedHeaders=content-length;content-type;host;x-amz-date, Signature={sigv4_hash}

{
    "keyId": "q5ugs7qjjh",
    "keyType": "API_KEY"
}
Response

The successful response returns a 201 Created status code and a payload similar to the following:

{
  "_links": {
    "self": {
      "href": "/usageplans/n371pt/keys/q5ugs7qjjh"
    }
  },
  "id": "q5ugs7qjjh",
  "name": " importedKey_2",
  "type": "API_KEY"
}

See Also

Create and Use Usage Plans