Developers and AI

What is an API key?

Definition

An API key is a secret string that lets a script or app act on your account without your password. Treat it like a password: keep it out of public code, and delete it when you no longer need it.

Also called: API token, Secret key, Developer key

How does an API key work?

You create the key in the service's dashboard, and your code sends it with every request. Most services expect it in a header, often as Authorization: Bearer followed by the key. The server looks the key up, finds the account it belongs to and runs the request as that account.

Anything done with the key counts as you: uploads use your plan and show up in your account. Unlike a signed URL, which opens one file for a short time, a key acts on your whole account until you delete it. Careful services store only a one-way hash of each key, so they show it to you once and never again.

How do you keep an API key safe?

Keep it where only your code can read it. The most common leak is a key pasted into source code and pushed to a public repository, where anyone can find it.

  • Store it in an environment variable or a secret manager.
  • Never put it in a URL, a chat message or JavaScript that runs in the browser.
  • Use one key per tool or machine, named after where it lives.
  • Give each AI tool its own key, so one MCP server connection can be cut off without touching the rest.
  • Delete a key the moment you think it leaked, then make a new one.

What is the difference between an API key and OAuth?

An API key is one secret you copy by hand, and OAuth is a sign-in flow that hands an app a limited token for you. A key suits your own scripts and developer tools, where you control the machine. OAuth suits apps used by many people, such as an AI assistant, because nobody copies a secret and you approve access on a page you trust.

Both can be revoked. A key usually works until you delete it, while an OAuth token tends to expire soon and renew in the background.

Password, API key and OAuth token
Who uses itHow long it lastsHow you stop it
PasswordA person signing inUntil you change itChange the password
API keyYour own code or toolsUntil you delete itDelete the key
OAuth tokenAn app you approvedA short time, renewed in the backgroundDisconnect the app

API key: common questions

What happens if my API key leaks?

Anyone who has it can act on your account within what the key allows. Delete it right away, which stops it for every request, then create a new one and update your tools.

Can I see my API key again after I create it?

Usually not. Many services store only a hash of the key, so they can check it but can't show it again. If you lose it, delete it and make a new one.

Is it safe to put an API key in front-end JavaScript?

No. Anything sent to a browser can be read by anyone who opens the page. Keep the key on a server or in a tool that runs on your own machine.

Why use an API key instead of my password?

A key can be named, limited and deleted on its own, without changing your password or signing you out anywhere. It also keeps your password out of scripts and config files.

How many API keys should I have?

One per tool or machine is a good rule. Then you can delete a key that leaked without breaking everything else that uses the service.

Go deeper

Updated

Share a file as a link in seconds

Upload any file and get one clean link, with every setting on this page.

Try Link in Seconds

Optional cookies for analytics, ads and session replay.