Amazon API Gateway REST API Reference

apikey:import

Imports one or more API keys.

HTTP Request

POST /apikeys?mode=import{?format,failonwarnings}

Template Variable

Request Body

// raw byte array representing the api definition

Response

ApiKeyIds

Remarks

The request payload must be of the supported API key file format.

Error Codes

The following exception may be thrown when the request fails.

  • UnauthorizedException
  • NotFoundException
  • TooManyRequestsException
  • LimitExceededException
  • BadRequestException

For detailed error code information, including the corresponding HTTP Status Codes, see API Gateway Error Codes

Example: Import an API key in a CSV format

Request

The following request imports an API key in a CSV format.

POST /apikeys?mode=import&format=csv&failonwarnings=false HTTP/1.1
Content-Type: text/csv
Host: apigateway.us-east-1.amazon.com
X-Amz-Date: 20160804T210241Z
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}

key,name, description
y9tXe4GwrU65cug8QyQKE8pRwIzUFznda7iO73Gn, importedKey_1, firstone
abcdef1234ghijklmnop0123456789, importedKey_2, secondone
abcdefghij, importedKey_3,
Response

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

{
  "_links": {
    "curies": {
      "href": "http://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-apikey-{rel}.html",
      "name": "apikey",
      "templated": true
    },
    "apikey:by-key": {
      "href": "/apikeys/{api_Key}?include_value=false",
      "templated": true
    },
    "apikey:create": {
      "href": "/apikeys"
    },
    "apikey:delete": {
      "href": "/apikeys/{api_Key}",
      "templated": true
    }
  },
  "ids": [
    "q5ugs7qjjh",
    "cs9f69caxa"
  ],
  "warnings": "Skipped invalid record: 3. API Key value should be at least 30 characters"
}

In this example, because we set failonwarnings=false in the request, the last input key is not correctly formatted (the key size is too small) and, thus, skipped from being imported. The response returns a warning message. If failonwarnings is set to true, the operation will be aborted and no keys will be imported.

See Also