CreateApiKey - Amazon API Gateway

CreateApiKey

Create an ApiKey resource.

Request Syntax

POST /apikeys HTTP/1.1 Content-type: application/json { "customerId": "string", "description": "string", "enabled": boolean, "generateDistinctId": boolean, "name": "string", "stageKeys": [ { "restApiId": "string", "stageName": "string" } ], "tags": { "string" : "string" }, "value": "string" }

URI Request Parameters

The request does not use any URI parameters.

Request Body

The request accepts the following data in JSON format.

customerId

An AWS Marketplace customer identifier, when integrating with the AWS SaaS Marketplace.

Type: String

Required: No

description

The description of the ApiKey.

Type: String

Required: No

enabled

Specifies whether the ApiKey can be used by callers.

Type: Boolean

Required: No

generateDistinctId

Specifies whether (true) or not (false) the key identifier is distinct from the created API key value. This parameter is deprecated and should not be used.

Type: Boolean

Required: No

name

The name of the ApiKey.

Type: String

Required: No

stageKeys

DEPRECATED FOR USAGE PLANS - Specifies stages associated with the API key.

Type: Array of StageKey objects

Required: No

tags

The key-value map of strings. The valid character set is [a-zA-Z+-=._:/]. The tag key can be up to 128 characters and must not start with aws:. The tag value can be up to 256 characters.

Type: String to string map

Required: No

value

Specifies a value of the API key.

Type: String

Required: No

Response Syntax

HTTP/1.1 201 Content-type: application/json { "createdDate": number, "customerId": "string", "description": "string", "enabled": boolean, "id": "string", "lastUpdatedDate": number, "name": "string", "stageKeys": [ "string" ], "tags": { "string" : "string" }, "value": "string" }

Response Elements

If the action is successful, the service sends back an HTTP 201 response.

The following data is returned in JSON format by the service.

createdDate

The timestamp when the API Key was created.

Type: Timestamp

customerId

An AWS Marketplace customer identifier, when integrating with the AWS SaaS Marketplace.

Type: String

description

The description of the API Key.

Type: String

enabled

Specifies whether the API Key can be used by callers.

Type: Boolean

id

The identifier of the API Key.

Type: String

lastUpdatedDate

The timestamp when the API Key was last updated.

Type: Timestamp

name

The name of the API Key.

Type: String

stageKeys

A list of Stage resources that are associated with the ApiKey resource.

Type: Array of strings

tags

The collection of tags. Each tag element is associated with a given resource.

Type: String to string map

value

The value of the API Key.

Type: String

Errors

For information about the errors that are common to all actions, see Common Errors.

BadRequestException

The submitted request is not valid, for example, the input is incomplete or incorrect. See the accompanying error message for details.

HTTP Status Code: 400

ConflictException

The request configuration has conflicts. For details, see the accompanying error message.

HTTP Status Code: 409

LimitExceededException

The request exceeded the rate limit. Retry after the specified time period.

HTTP Status Code: 429

TooManyRequestsException

The request has reached its throttling limit. Retry after the specified time period.

HTTP Status Code: 429

UnauthorizedException

The request is denied because the caller has insufficient permissions.

HTTP Status Code: 401

Examples

Create an API key

The following example creates an API key.

Sample Request

POST /apikeys HTTP/1.1 Content-Type: application/json Host: apigateway.us-east-1.amazonaws.com X-Amz-Date: 20170223T222156Z Authorization: AWS4-HMAC-SHA256 Credential={access_key_ID}/20170223/us-east-1/apigateway/aws4_request, SignedHeaders=content-length;content-type;host;x-amz-date, Signature={sig4_hash} { "name" : "my_api_key", "description" : "My API key", "enabled" : "false", "stageKeys" : [ { "restApiId" : "uycll6xg9a", "stageName" : "beta" } ] }

Sample Response

{ "_links": { "curies": { "href": "https://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-apikey-{rel}.html", "name": "apikey", "templated": true }, "self": { "href": "/apikeys/a2TprUZuzf2EKbbmMUotDaHYGg8kgxFypcarGved6" }, "apikey:delete": { "href": "/apikeys/a2TprUZuzf2EKbbmMUotDaHYGg8kgxFypcarGved6" }, "apikey:update": { "href": "/apikeys/a2TprUZuzf2EKbbmMUotDaHYGg8kgxFypcarGved6" } }, "createdDate": "2016-06-08T22:21:56Z", "description": "My API key", "enabled": false, "id": "a2TprUZuzf2EKbbmMUotDaHYGg8kgxFypcarGved6", "lastUpdatedDate": "2016-06-08T22:21:56Z", "name": "my_api_key", "stageKeys": "uycll6xg9a/beta" }

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: