canonical: https://jentic.com/apis/googleapis.com/apikeys

# Google API Keys API

The Google Cloud API Keys API manages the API keys associated with developer projects. It exposes operations to create, retrieve, update, delete, and undelete keys, look up a key by string, and fetch the key string itself. API keys can be restricted by API target, IP address, HTTP referrer, or Android and iOS application identifiers, giving teams least-privilege credentials for unauthenticated services.

## For AI agents

Create, restrict, and rotate Google Cloud API keys for projects. Useful for agents that need to provision scoped credentials for unauthenticated APIs like Maps, Translate, or Cloud Vision public quotas.

## Scope

Does not handle service account keys, OAuth client secrets, or non-Google API credentials - use for managing Google Cloud API keys and their restrictions only.

## Capabilities

- Create API keys scoped to specific Google APIs and clients
- Restrict keys by IP, HTTP referrer, Android package, or iOS bundle
- Rotate keys by creating a new key and deleting the old one
- Undelete a recently deleted key within the recovery window
- Look up the project and metadata for a given key string
- Retrieve the actual key string for an existing key resource

## Use cases

### Scoped API key provisioning for client apps

Mobile and web teams provision API keys restricted to a specific app identifier so that even if the key is extracted from the binary, it cannot be used elsewhere. The keys.create operation accepts API targets and client restrictions in one call, replacing console clicks with reproducible scripts.

Example prompt: Create an API key under projects/p restricted to Android package com.example.app with SHA-1 ABC123 and limited to API target maps-android-backend.googleapis.com.

### Scheduled key rotation

Security teams rotate API keys on a schedule. The agent creates a new key with the same restrictions, swaps it into the application config, then deletes the old key. The undelete endpoint provides a safety net inside the recovery window if rotation breaks something.

Example prompt: Create a new key cloning restrictions of key K-old, push the new key string to Secret Manager, then delete K-old.

### Leaked key triage

When a key shows up in a public repo or alert, security uses keys.lookupKey to find which project owns it, then deletes it from that project. Combined with audit logs the team can identify the leak source and rotate the affected service.

Example prompt: Call /v2/keys:lookupKey with the suspect key string, then delete the returned key resource and post the audit log link to the incident channel.

### AI agent credential lifecycle through Jentic

An AI agent acting on infra tickets handles 'rotate maps key' or 'create scoped key for new mobile build' by calling Jentic-mediated API Keys operations. The agent never holds the project's service account JSON, only short-lived scoped tokens at execution.

Example prompt: On ticket 'rotate maps key for android build', create a new restricted key, return its key string in an encrypted reply, and delete the previous key after the requester confirms.

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| GET | /v2/keys:lookupKey | Look up the project and metadata for a key string |
| DELETE | /v2/{+name} | Delete an API key |
| GET | /v2/{+name}/keyString | Retrieve the secret key string for a key resource |
| POST | /v2/{+name}:undelete | Undelete a recently deleted key |
| GET | /v2/{+parent}/keys | List API keys under a project |

## Key resources

- **Keys** — The API key resource itself, including its restrictions
- **KeyString** — The actual secret string used at call time
- **Operations** — Long-running operations for key creation and updates

## Why Jentic

- **Setup:** Wiring the API Keys API by hand means setting up Google OAuth2, granting a service account the right Cloud scopes, and refreshing access tokens for each key operation yourself. Through Jentic you install once, import the API Keys API from the API Directory, store the OAuth credential once, and your agent calls it.
- **Permission scoping:** This API puts the key resource name in the URL path (/v2/{name}/keyString, /v2/{parent}/keys), so a rule can pin your agent to one key or project: it can list keys and read a key string there and nothing else. You choose the operations it may call, so actions like deleting or undeleting a key are not included unless you add them.
- **Credential handling:** Your Google Cloud OAuth credential is stored once, encrypted, by your own Jentic One instance and injected at execution time. It never enters the agent's prompt, logs, or context.
- **Discovery method:** Agents search Jentic by intent such as 'create a restricted API key' or 'rotate an API key', and Jentic returns the matching operation with its input schema so the agent calls the right endpoint without decoding the key restriction model by hand.

## Related APIs

- **App Engine Admin API** — Hosts services that consume API keys for unauthenticated outbound calls.
- **API Gateway API** — Accepts API key auth for traffic into deployed gateways.
- **Apigee API** — Issues consumer keys with quotas for full-lifecycle API management.

## FAQ

### What authentication does the Google API Keys API use?

OAuth 2.0 with Google Cloud credentials. Note this is the management API for API keys themselves; the keys it produces are then used to authenticate calls to other Google APIs that accept API keys. Through Jentic, the management credentials are vaulted.

### Can I restrict an API key to a single Google API?

Yes. The key resource accepts a restrictions block with apiTargets, where each target lists the service name (e.g. translate.googleapis.com) and optional methods. Calls to other services with that key will be rejected.

### What are the rate limits for the Google API Keys API?

Standard Google Cloud per-project per-minute quotas apply to management calls. Key rotations are infrequent operations; the data-plane quota of services authenticated by the key is enforced separately by each target service.

### How do I create a restricted API key through Jentic?

Search Jentic for 'create google API key', load the schema for the keys.create operation, and execute it with the parent project, displayName, and restrictions block (apiTargets plus client restriction). Jentic returns the operation handle to poll until done.

### Is the Google API Keys API free?

Yes. Managing API keys carries no separate fee. Costs accrue only when the keys are used to call paid services like Maps, Translate, or Vision.

### Can I recover a deleted API key?

Yes, within the recovery window. Call /v2/{+name}:undelete on the deleted key resource. After the recovery window the key is purged and cannot be restored; create a new key instead.

### Can I limit what my agent is allowed to do with the Google API Keys API?

Yes. Because you self-host Jentic One and write the rules yourself, you decide which operations the agent may call and which credential it uses, and this API puts the key resource name in the URL path (like /v2/{parent}/keys and /v2/{name}/keyString) so a rule can pin the agent to a single project or key. For example, you can allow it to list keys and read a key string for one project while excluding everything else. Destructive operations such as deleting or undeleting a key are not available to the agent unless you explicitly add them. Your Google Cloud OAuth credential is injected at execution time and never enters the agent's prompt or logs.
