layman/terms
Apps talking to apps

API key / secret

ay · pee · eye kee

In shortA long secret code an app uses to prove who it is when it asks another service's API for something.

When your app knocks on another service's door, it needs to prove who it is. An API key is its key card.

At a hotel, your key card opens your room, maybe the gym, but not anyone else’s room. If you lose it, the desk cancels it and gives you a new one.

An API key works the same way for software. It’s a long secret code an app sends with every request, to prove which account it belongs to. The service then knows who’s asking, what they’re allowed to do and who to bill.

What it looks like

A long jumble of letters and numbers, often with a little label at the start, like sk-live-.... It’s meant to be impossible to guess.

Keeping it safe

What it isn’t

It isn’t your login password. It’s for software, not for a person signing in. Many services let you make lots of keys, each with different permissions.

Where the comparison breaks down

A stolen key card gets noticed quickly. A stolen API key can be quietly used for weeks, running up bills, until someone spots it.

How the words fit together

An API key unlocks an API. Its permissions decide which doors it opens. Keep it secret, like any password.

Watch out

Treat an API key like a password. Never paste it into chats, emails or public code. If one leaks, cancel it and make a new one straight away.

When you'll hear it

“Don't commit the API key.” Don't save the secret into the project's shared code where others can see it.

“Rotate the key.” Swap the old secret for a new one, so the old one stops working.

“The key leaked.” Someone who shouldn't have it may now be able to use our account.

Say it in a meeting

“Where are our API keys kept? Who gets told if one leaks?”

Try it yourselfReady to use it? The exact commands are on my other site, devcmds: Set an environment variable for good ↗