# API Key

> A long secret string. It tells an API which app or account is calling.

**Field:** Software Development  
**Category:** Auth  
**Also known as:** API Keys, Secret Key, x-api-key

## Think of it like

Think of it like a members' card for a club. It shows which member is at the door.

## Definition

An API key is a long secret string that tells an API which app or account is calling. You get it from the service's dashboard and send it with each request. The service uses it to know who to bill, how many calls to allow and when to block. Unlike a login, a key usually does not expire on its own. Anyone who copies it can spend your quota and your money.

## Example

Jack signs up for a weather API and gets a key. His app sends it with each call, and the service counts his 1,000 free calls a day.

## Example code

```http
GET /v1/forecast?city=Leeds HTTP/1.1
X-API-Key: 3f9a2c71d8e04b6a
```

The key in a header tells the service whose account to charge.

## Why it matters

It is the easiest way to call a paid API. It is also the easiest secret to leak by mistake.

## Common mistake

Committing an API key to a public Git repo. Bots scan for them within minutes and run up the bill.

## Three principles

- **Says who is calling.** An app or account.
- **Used to bill and limit.** Quota and rate limits.
- **Lasts until revoked.** So guard it well.

## Related terms

- [Access Token](https://learn.benibix.com/term/development/access-token)
- [Bearer Token](https://learn.benibix.com/term/development/bearer-token)
- [Rate Limiting](https://learn.benibix.com/term/development/rate-limiting)
- [Environment Variable](https://learn.benibix.com/term/infrastructure/environment-variable)
- [Third-Party API](https://learn.benibix.com/term/development/third-party-api)

## Told apart from

- [API Key vs Access Token](https://learn.benibix.com/compare/api-key-vs-access-token): People think an API key and an access token are the same thing, and they are not. An API key names your app, and it lasts until someone turns it off. An access token is short-lived, and it often acts for one user who logged in. Both go in a header, and both must stay secret.

## Taught in

- [Claude Code and Its Surfaces](https://learn.benibix.com/learn/ai-claude-code/claude-code-and-its-surfaces): Claude Code, 1/16
- [Claude Code Login Commands](https://learn.benibix.com/learn/ai-claude-code-commands/claude-code-login-commands): Claude Code Commands, 3/17

---

Source: https://learn.benibix.com/term/development/api-key
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
