# Google Maps Platform API keys: find, store, rotate, and use them safely with AI agents

Source: https://botpassword.com/keys/google-maps
Last checked: 2026-10-25

Google Maps Platform API keys are created and managed in the Google Cloud console. Google says to always restrict a key with one application restriction (websites, IP addresses, Android apps or iOS apps) plus one or more API restrictions, and states you are financially responsible for charges from abuse of unrestricted keys.

## Key types

| Type | Prefix | Secret | Scope | Expiry |
|---|---|---|---|---|
| Maps Platform API key | — | Yes | Whatever APIs and applications the key is restricted to | Does not expire unless rotated and deleted |

## How to create a Google Maps Platform key

1. Open the Google Maps Platform Credentials page in the Google Cloud console.
2. Create an API key.
3. Add one application restriction and the API restrictions it needs.

## Limiting what the key can do

Use one type of application restriction and one or more API restrictions. A key with an application restriction cannot be used on other platform types.

## How to rotate a Google Maps Platform key

1. Open the Credentials page and open the key.
2. Select **Rotate key**, optionally rename it, and select **Create**.
3. Update your apps.
4. Check usage, then use **Delete the previous key** in the Previous Key section.

## How to revoke a Google Maps Platform key

1. Delete the key on the Credentials page.

## If the key leaked

1. Check usage in the Metrics explorer to see which services the key is calling.
2. Restrict the key and use a separate key per app.
3. Rotate or replace the key only if it cannot be restricted and you must stop abuse quickly.
4. Contact Maps Platform support if you still need help.

## Gotchas

- An unrestricted key makes you financially responsible for abuse charges.
- A key restricted to one platform type will not work on another.
- Replacement keys in Android and iOS apps only work after users update.

## Using this key with AI agents (BotPassword)

- `run_with`: Runs a command with the key injected as an environment variable or a 0600 temporary file, never on the command line, and redacts the key from the output.
- `http_request`: Makes an authenticated API call after checking the destination against the hosts this key may be sent to. The response comes back with credential-shaped values redacted, and one that holds the key itself is refused.
- `rotate`: Partly built: creates a new key, stores it as pending, verifies it, promotes it, then revokes the old key after a grace period. Today it works for Cloudflare tokens and AWS IAM keys you have set up, and an agent can start it only under a grant with autopilot; other providers cannot be rotated through their API yet.

## FAQ

### How do I restrict a Google Maps API key?

Set one application restriction (websites, IPs, Android or iOS apps) and one or more API restrictions on the key.

### How do I rotate a Google Maps API key?

Open the key, choose **Rotate key**, update your apps, then delete the previous key.

### What do I do if my Maps key leaked?

Check usage in Metrics explorer, restrict the key, and rotate only if it cannot be restricted.

### Can an AI agent use my Google Maps Platform key without seeing it?

Yes, if the key never enters the agent's context. Instead of pasting the key into a chat or leaving it in a `.env` file the agent can read, keep it in a credential broker that injects it into the command or request on the agent's behalf. BotPassword does this with `run_with`, `http_request`, so the agent gets the result and never the value.

## Sources

- https://developers.google.com/maps/api-security-best-practices
- https://developers.google.com/maps/documentation/javascript/get-api-key
- https://developers.google.com/maps/documentation/javascript/error-messages
