API key

A secret string that identifies an application when it calls an API. If it is exposed or has too many permissions, it gives access without any login, so keys need limited scope, rotation and monitoring.

Reading Time:

3 min

An API key is a secret string that identifies an application or user when it calls an API. It works like a password for software: whoever holds the key can usually make the calls it allows, often without any further login.

How does an API key work?

An application sends the key with each request. The service checks it, applies the permissions linked to that key and may record the activity under its name. Keys are easy to create, which is why they appear in scripts, integrations, cloud services and automation.

Why are API keys a security risk?

An API key is a non-human identity: it has access, acts on its own and is rarely reviewed. It needs no password, no MFA and no interaction, so it can be copied once and used from anywhere, at any hour, until someone revokes it.

If a key is exposed, an attacker can use it as a valid identity. Nothing needs to be broken, and the calls look legitimate.

How do API keys get exposed?

  • Hard-coded in source code that is shared or published.
  • Stored in configuration files or pipelines with weak protection.
  • Pasted into tickets, chats or documents.
  • Left active after a project ends or a person leaves.
  • Granted wide permissions that go well beyond the task.

Attackers scan public repositories and shared files for exposed keys, so a leak can be found and used quickly.

How is an API key different from a token or a password?

A key identifies an application. An OAuth token represents delegated access and usually expires. A password identifies a person and can be backed by MFA. All three are credentials that an attacker can use if they leak, but keys tend to live longest and be watched least.

An API key also often sits behind a service account. The account holds the permissions and the key is the way to use them, so reviewing one without the other leaves a gap.

Should you use API keys at all?

Keys are fine for simple, low-risk cases. For sensitive access, short-lived tokens, certificates or federated identity are safer, because they expire and can be tied to a specific workload.

Why are API keys hard to monitor?

Because a key identifies the application, not the person or the context. Logs show that the key was used, not who used it or why. Without a baseline of normal use for each key, a stolen one is hard to tell from the real application.

How can you detect API key misuse?

  • Calls from unfamiliar locations or networks.
  • Sudden spikes in volume.
  • Requests for data the key never used before.
  • Activity outside its normal schedule.
  • Use after the project or its owner is gone.

A key created for a one-off export keeps working after the project ends and nobody owns it. Two years later it appears in a shared document. Nobody notices when it starts being used from a new location.

What should you do if a key is exposed?

Revoke it first, then create a replacement with a narrower scope. Review the key’s recent activity to see what was accessed, check connected systems for changes and find out how it leaked, so the same path is closed.

What is the life of a key?

  1. Create it with a clear owner and purpose.
  2. Scope it to the minimum permissions.
  3. Store it in a secrets manager.
  4. Rotate it on a schedule.
  5. Retire it when the integration ends.

How often should keys be rotated?

As often as the risk and the platform allow, and always after a suspected exposure. Short-lived credentials reduce the need to rotate by hand.

How do you manage API keys safely?

Start with an inventory, because you cannot protect keys you do not know about. Then give each key an owner and the narrowest scope, store it in a secrets manager, rotate it on a schedule and after any suspected exposure, and retire it when the integration ends. Prefer short-lived credentials where the platform supports them.

Sharelock brings non-human identities into the same view as people, shows which ones hold excessive access and watches how they behave after authentication, so unusual use of a key stands out against its normal pattern.

‍

Explore more terms

Sharelock investigates identity alerts in 31 seconds. Autonomously

See the Autopilot in action, no slides, no pitch.

Get in Touch

Request a demo or get more details of how our product works.

Thank you! Your submission has been received!

Oops! Something went wrong while submitting the form.