Skip to content

CreateApiKey

Source: src/AWS/ApiGateway/CreateApiKey.ts

Runtime binding for issuing API Gateway API keys (apigateway:POST on /apikeys). Account-scoped — takes no resource.

The response’s value is Redacted<string> (distilled marks it sensitive), so the plaintext key never leaks into logs. Provide ApiGateway.CreateApiKeyHttp on the Function effect to implement the binding.

import * as Redacted from "effect/Redacted";
// init — account-level binding takes no resource
const createApiKey = yield* ApiGateway.CreateApiKey();
// runtime
const key = yield* createApiKey({
name: `customer-${customerId}`,
enabled: true,
});
const plaintext = Redacted.isRedacted(key.value)
? Redacted.value(key.value)
: key.value;