How APIs and API Keys Work in Plain English
What an API is, what an API key does, how keys differ from sign-in tokens, and how makers say to look after keys.
An API is the door one program leaves open so other programs can talk to it. An API key is a long code that proves who's knocking.
What an API is
API stands for application programming interface. One reference entry describes it as "a connection between computers or between computer programs".1 The same entry explains that "It allows two software systems to communicate across a boundary", using signals both sides have agreed on.1
People use the word loosely. It can mean the written rules for the connection or the working version that answers requests. Either way, it isn't something you click on. The entry describes APIs as "used for machine-to-machine communication".1
A request to an API is like a form with set fields. It might ask for a customer record, add a new one or change an address. The reply comes back in a fixed layout the asking app can read.
What an API key is
A lot of APIs only answer callers they can identify. A key is the way they do that. It's a string of letters and numbers that you generate in one app and paste into another, or that a connector tool stores for you.
One payment company's documentation describes the job. Its keys "authenticate requests from your integration and determine which Stripe resources it can access".2 Two things are happening there. The key proves who's asking, and it sets how much they may see or change.
So a key works a lot like a password for software, and it needs the same care. It also isn't tied to a person's sign-in. Anyone who holds the key can make the requests it allows.
Keys with different powers
Many makers offer more than one kind of key. The same documentation names publishable, restricted and secret keys.2 A restricted key carries only the permissions you choose. A secret key has no such limit.
Makers differ, so the names and rules vary between apps. The pattern holds, though: give a connection only what it needs. The documentation says to "grant server-side keys only the permissions your integration needs".2
Keys and sign-in tokens aren't the same
Some connections never ask you to paste a key. Instead you see a sign-in window with an Allow button, and the apps swap temporary codes called tokens behind the scenes. Google's developer documentation says access tokens have limited lifetimes.3 It also says they're valid only for the operations and resources described in the request.3
This is called OAuth. It's why you can connect two apps without handing either one your password. What the Allow screen asks for is covered on the permissions page.
Looking after a key
The advice from the maker's documentation, in short:
- Store sensitive keys in a secure place, such as a secrets vault, and keep them out of an app's code.2
- Where the maker allows it, create separate keys for separate jobs. That documentation says you can "assign them to different parts of your application".2
- Rotate keys, meaning replace them with new ones, when people who had access leave. The documentation says: "Rotate keys when team members with access to the keys leave your organisation."2
Expiring a key has a cost. The documentation warns that code using an expired key can no longer make API calls.2 Any connection using that key stops until you give it the new one. That's one of the usual reasons a link goes quiet, and why integrations stop working lists the others.
Where you'll see a key
In your app's settings, usually under a heading like Developer, API or Integrations. Some makers show a secret key only once, when you create it. Check your own app's help pages, because rules differ by maker.2
If you don't write code, a connector tool or a built-in link normally handles the key for you. See built-in integrations vs. connector tools.
Notes and sources
- API, Wikipedia
- API keys, Stripe Documentation
- Using OAuth 2.0 to Access Google APIs, Google for Developers