Skip to content

ApiKeyResource

Source: src/AWS/AppSync/ApiKey.ts

An AppSync API key for API_KEY-authenticated GraphQL APIs.

The key’s id attribute is the secret value (da2-…) sent in the x-api-key request header. It is wrapped in Redacted; unwrap with Redacted.value(key.id) where the raw header value is needed.

Key with the default 7-day expiry

const key = yield* AppSync.ApiKey("Key", { api });
// Redacted.value(key.id) → "da2-…" — send as the x-api-key header

Key with a managed expiry

const key = yield* AppSync.ApiKey("Key", {
api,
description: "mobile clients",
expires: 1893456000, // rounded down to the hour by AWS
});