Skip to main content

api_keys

Creates, updates, deletes, gets or lists an api_keys resource.

Overview

Nameapi_keys
TypeResource
Idaws.appsync.api_keys

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringThe API key ID.
deletesinteger (int64)The time after which the API key is deleted. The date is represented as seconds since the epoch, rounded down to the nearest hour.
descriptionstringA description of the purpose of the API key.
expiresinteger (int64)The time after which the API key expires. The date is represented as seconds since the epoch, rounded down to the nearest hour.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
list_api_keysselectapi_id, regionnextToken, maxResultsLists the API keys for a given API. API keys are deleted automatically 60 days after they expire. However, they may still be included in the response until they have actually been deleted. You can safely call DeleteApiKey to manually delete a key before it's automatically deleted.
create_api_keyinsertapi_id, regionCreates a unique key that you can distribute to clients who invoke your API.
update_api_keyupdateapi_id, id, regionUpdates an API key. You can update the key as long as it's not deleted.
delete_api_keydeleteapi_id, id, regionDeletes an API key.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
api_idstringThe API ID.
idstringThe ID for the API key.
regionstringAWS region (default: us-east-1)
maxResultsintegerThe maximum number of results that you want the request to return.
nextTokenstringAn identifier that was returned from the previous call to this operation, which you can use to return the next set of items in the list.

SELECT examples

Lists the API keys for a given API. API keys are deleted automatically 60 days after they expire. However, they may still be included in the response until they have actually been deleted. You can safely call DeleteApiKey to manually delete a key before it's automatically deleted.

SELECT
id,
deletes,
description,
expires
FROM aws.appsync.api_keys
WHERE api_id = '{{ api_id }}' -- required
AND region = '{{ region }}' -- required
AND nextToken = '{{ nextToken }}'
AND maxResults = '{{ maxResults }}'
;

INSERT examples

Creates a unique key that you can distribute to clients who invoke your API.

INSERT INTO aws.appsync.api_keys (
description,
expires,
api_id,
region
)
SELECT
'{{ description }}',
{{ expires }},
'{{ api_id }}',
'{{ region }}'
RETURNING
api_key
;

UPDATE examples

Updates an API key. You can update the key as long as it's not deleted.

UPDATE aws.appsync.api_keys
SET
description = '{{ description }}',
expires = {{ expires }}
WHERE
api_id = '{{ api_id }}' --required
AND id = '{{ id }}' --required
AND region = '{{ region }}' --required
RETURNING
api_key;

DELETE examples

Deletes an API key.

DELETE FROM aws.appsync.api_keys
WHERE api_id = '{{ api_id }}' --required
AND id = '{{ id }}' --required
AND region = '{{ region }}' --required
;