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.
Google Maps Platform key types
| Type | Prefix | Secret? | Scope | Expiry |
|---|---|---|---|---|
| Maps Platform API key Web keys are visible in page source, so restrictions are the control. | — | 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
- Open the Google Maps Platform Credentials page in the Google Cloud console.
- Create an API key.
- Add one application restriction and the API restrictions it needs.
Open Google Maps Platform's key settings
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
- Open the Credentials page and open the key.
- Select Rotate key, optionally rename it, and select Create.
- Update your apps.
- Check usage, then use Delete the previous key in the Previous Key section.
The new key copies the old key's restrictions and both keys work during the transition. Google advises restricting the key first and rotating only when restriction is not possible or you must act quickly. Mobile apps need a user update before a replacement key takes effect.
How to revoke a Google Maps Platform key
- Delete the key on the Credentials page.
If your Google Maps Platform key leaked
- Check usage in the Metrics explorer to see which services the key is calling.
- Restrict the key and use a separate key per app.
- Rotate or replace the key only if it cannot be restricted and you must stop abuse quickly.
- Contact Maps Platform support if you still need help.
Things that catch people out
- 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.
Common Google Maps Platform authentication errors
InvalidKeyMapError
The API key in the script element is not recognised.
RefererNotAllowedMapError
The page URL is not on the key's allowed referrers list.
ApiNotActivatedMapError
The Maps JavaScript API is not enabled for the project.
Using your Google Maps Platform key with AI agents
A coding agent that can read your .env file or your shell history can read the key, and anything in its context can end up in logs, transcripts or a prompt-injected request. The safer pattern is to keep the key in a credential broker that performs the authenticated step for the agent and hands back only the result.
BotPassword works this way. For a Google Maps Platform key, these intents fit:
| Intent | What BotPassword does |
|---|---|
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. |
Set it up in your agent: Aider · Amp · Claude Code · Claude Desktop · Cline · OpenAI Codex CLI · all agents
Frequently asked questions
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.