Databases, search and data

Algolia API keys: find, store, rotate, and use them safely with AI agents

Algolia keys are managed on the dashboard API keys page at dashboard.algolia.com/account/api-keys. The Search-only key is safe for frontend code, while the Admin API key must stay confidential and never be used in an app.

Algolia key types

TypePrefixSecret?ScopeExpiry
Admin API key
Never use it in a client app.
—YesAll operations on the application—
Search-only API key
Predefined; safe for production frontend code.
—NoSearch on all indices in the application—
Secured API key
Generated with generateSecuredApiKey; virtual and not stored or shown in the dashboard.
—YesInherits the base key's restrictions and can only add moreOptional, set with `validUntil`

How to create a Algolia key

  1. Sign in to the Algolia dashboard.
  2. Open API keys.
  3. Create a key, set its ACL (permissions) and optional restrictions, and save it.

Open Algolia's key settings

Limiting what the key can do

Each key has an ACL (search, add or delete records, settings, analytics, logs and more). Optional restrictions are accessible indices, rate limit per hour, records retrieved, expiration, HTTP referrers and enforced query parameters.

How to rotate a Algolia key

  1. Create a new key with the same ACL and restrictions.
  2. Update your apps to use it.
  3. Delete the old key.

Algolia recommends regenerating keys at least once a year and limiting each key's validity to one year. Deleting a main key also deletes its secured keys. Deleted keys can be restored with their restrictions, up to 1,000 are kept.

How to revoke a Algolia key

  1. Open the API keys page and delete the key. Update your apps to a new key first so they do not break.

If your Algolia key leaked

  1. Create a replacement key and deploy it.
  2. Delete the leaked key.
  3. Remember that deleting a main key also removes the secured keys derived from it.

Things that catch people out

  • Never put the Admin key or any write-access key in frontend or mobile code.
  • Secured API keys do not appear in the dashboard; revoke the base key to revoke them.

Using your Algolia 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 Algolia key, these intents fit:

IntentWhat BotPassword does
run_withRuns 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_requestMakes 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.
rotatePartly 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

Where do I find my Algolia API key?

On the dashboard API keys page, dashboard.algolia.com/account/api-keys.

What is the difference between the Admin and Search-only key?

The Admin key can do everything and must stay secret. The Search-only key can only search and is safe for frontend code.

How often should I rotate Algolia keys?

Algolia recommends at least once a year.

Can an AI agent use my Algolia 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.

Stop pasting Algolia keys into agents

BotPassword is in early access. Request an invite and we'll email you when your spot opens.