# API keys explained: a long string that works for whoever holds it

> An API key is a long string that lets whoever holds it call a service. Why keys work like bearer secrets, how they leak and what to use instead.

- URL: https://iamops.dev/api-keys-explained/
- Language: en
- Author: Argo
- Published: 2026-12-04
- Category: Knowledge
- Depth: Explainer
- Audience: Security leaders and architects
- Time: 5 min
- Topics: API keys, secrets, basics

## TL;DR

- A [key](https://iamops.dev/api-keys-explained/#what-an-api-key-is) is a string that proves a program may call a service, and nothing more.
- A key works for [whoever holds it](https://iamops.dev/api-keys-explained/#a-wristband-at-a-festival), so a copied key is a working key.
- Keys reach [public code and logs](https://iamops.dev/api-keys-explained/#how-keys-leak) more often than teams expect, and bots search for them.
- The fix is to [rotate, move and narrow](https://iamops.dev/api-keys-explained/#what-to-do-instead) keys, or to replace them with short-lived identity.

**Audience: Beginners.** Anyone who has pasted a key into a config file to make something work, and wondered what it could do in the wrong hands.

**Before you start:** an <abbr title="application programming interface">API</abbr> key is a simpler cousin of the [access token](https://iamops.dev/access-refresh-id-tokens-explained/). Read that one first if the word "token" is new to you.

## What an API key is

An <abbr title="application programming interface">API</abbr> is the door a program uses to ask a service for something: send a message, read a file, start a job. An API key is a long random string the service gives you so it can tell your program apart from everyone else's.

You put the key in a script, an app or an environment variable. The service checks it on every call. If the string matches an active key, the call goes through. That is the whole check.

## A wristband at a festival

Think of a festival wristband. Whoever wears it gets in. The gate staff do not look at your face or your ticket. If someone photographs your wristband and posts the photo, the photo gets in too.

An API key behaves the same way. The service checks the string, not the person holding it. The standard for bearer tokens says the same about tokens in general: anyone who holds one can use it, without proving they are the one it was issued to. Most API keys are used this way, so treat every copy as the real thing.

## How keys leak

Keys end up in places they should not be: a config file pushed to a public repository, a screenshot in a bug report, a chat message, a build log. Nobody meant to publish them. The file was just convenient.

Microsoft Threat Intelligence reported on 5 November 2026 that threat actors were using an agentic AI tool to search public GitHub repositories for exposed secrets, including AI inference API keys. In at least one case, Microsoft says an agent went from scanning GitHub to pulling data from Azure Key Vault in five minutes. No break-in was needed. The keys were already public.

The sequence below shows that path in four steps. The one that matters is the call that still works with the copied key.

![Sequence diagram: a developer commits a config file with an API key to a public repository, a scanner finds the key and calls the cloud API with it, and the call succeeds.](https://iamops.dev/img/api-keys-explained.svg)

*Committed once, used by anyone. The key checks the string, not the person.*

## What to do instead

Start with the key you already have. If it was ever in a repository, a log or a chat, treat it as leaked. Revoke it and issue a new one, then check what the old one touched. Revoking is the step that stops the copy from working.

Next, move the key out of the code. A secret store or the platform's built-in vault keeps the string out of the repository, and push protection can block a key before it is committed. Turn on secret scanning for every repository that holds configuration.

Then narrow it. One key should serve one service, with the fewest permissions that work, and it should be rotated on a schedule. A key that can do everything is the one a scanner wants.

Where the platform allows it, skip the key altogether. A workload can prove who it is with a short-lived token instead of a string it keeps. The [secrets or federation article](https://iamops.dev/secrets-vs-federated-credentials/) shows how a <abbr title="continuous integration">CI</abbr> job does this with no stored secret.

## Key or token?

A key says which program is calling. A user token says which person signed in, and what that person agreed to. A key usually carries no user at all, and many keys never expire unless someone rotates them. That is why a leaked key can be worse than a stolen sign-in: nobody sees a login prompt, and no timeout runs out on its own.

## Where to go next

- [Secrets or federation](https://iamops.dev/secrets-vs-federated-credentials/): how a CI job proves who it is with no stored password.
- [Access, refresh and <abbr title="identifier">ID</abbr> tokens](https://iamops.dev/access-refresh-id-tokens-explained/): the three tokens you will meet next, and what each one is for.
- [<abbr title="Open Authorization">OAuth</abbr> 2.0 flows explained](https://iamops.dev/oauth-2-flows-explained/): how a user-facing app gets a token in the first place.
- [Infostealers now take AI agent tokens](https://iamops.dev/infostealer-identities-ai-agents/): what to revoke when a token or key is stolen from a laptop.

## Sources

- [Microsoft Threat Intelligence: threat actors use agentic AI tooling to find and abuse exposed secrets (5 November 2026)](https://www.microsoft.com/en-us/security/blog/2026/11/05/threat-actors-use-agentic-ai-tooling-to-find-and-abuse-exposed-secrets/)
- [RFC 6750: The OAuth 2.0 Authorization Framework: Bearer Token Usage](https://datatracker.ietf.org/doc/html/rfc6750)
- [GitHub Docs: secret scanning](https://docs.github.com/en/code-security/concepts/secret-security/secret-scanning)

Discuss: [X](https://x.com/iamopsdev) | [LinkedIn](https://www.linkedin.com/company/iamops-dev/)
