API key

A secret string that identifies and authorises a program calling an API, usually sent in a header.

Anyone holding the key can use the service as your application until it is revoked.

In more detail

Unlike a user token, an API key is often long-lived and tied to a set of permissions. Treat it as a secret: never commit it or log it, and rotate it if it leaks.

Examples

API_KEY = os.environ["API_KEY"]  # III: secrets from env
The course's fake key sk-live-4d1f-demo travels through a committed file, an environment variable, a log line and a secret manager to show each route a key can leak by.

Related terms

Taught in

References

Certification courses