Skip to content

GCP.ApiKeys reference

Source: src/GCP/ApiKeys/GetKeyString.ts

Runtime binding for API Keys keys.getKeyString.

Bind this operation to a Key in a Function/Action init phase. Provide GetKeyStringHttp. The key string is not included on keys.get — this is the only way to read it.

const getKeyString = yield* GCP.ApiKeys.GetKeyString(maps);
const { keyString } = yield* getKeyString();

Source: src/GCP/ApiKeys/GetKeyStringHttp.ts Kind: Layer · Provides: GCP.ApiKeys.GetKeyString

HTTP implementation of GetKeyString.

Source: src/GCP/ApiKeys/Key.ts

A Google Cloud API key (the API Keys API, apikeys.googleapis.com).

Keys are global (locations/global). They have no labels — Alchemy stamps ownership into annotations so read, list, and pnpm nuke:gcp can find them. keyId and serviceAccountEmail are immutable; changing either replaces the key. Deletes are soft: the key can be undeleted for 30 days, then it is purged.

Generated name

const maps = yield* GCP.ApiKeys.Key("Maps", {
displayName: "maps browser key",
});

Named key with annotations and API-target restrictions

const maps = yield* GCP.ApiKeys.Key("Maps", {
keyId: "maps-browser",
displayName: "maps browser key",
annotations: { env: "prod" },
restrictions: {
apiTargets: [{ service: "geocoding-backend.googleapis.com" }],
browserKeyRestrictions: {
allowedReferrers: ["https://example.com/*"],
},
},
});
const getKeyString = yield* GCP.ApiKeys.GetKeyString(maps);
const { keyString } = yield* getKeyString();