Keep your API key safe
What an API key is, what someone could do with yours, how to keep it private, and what to do if it leaks. This page as Markdown.
🔗What an API key is
An API key is like a password for your account's API access. Every call that carries it acts as you, on your plan and with your credits. Anyone who holds the key can do the same, and nothing else is checked.
We show each key once, when you create it. We keep only a scrambled copy (a hash), so we can never show it to you or anyone else again.
🔗If someone else gets your key
They can make calls as you, and every call they make spends your credits.
- If you turned on Keep going past my limit in Settings > Billing, their calls can also spend the money on your balance, up to the monthly limit you set.
- A Read and write key also lets them change your saved searches, company lists, and saved and tracked jobs. We email you about every change made with an API key.
- A Read key can search and read, and change nothing. Make a Read key unless your app needs to make changes.
🔗Keep it private
- Never put it in code you commit, in a public repo or a private one. People scan code for keys all day.
- Never put it in a web page or a mobile app. Anyone can read a page's code in their browser. Call the API from your own server.
- Never put it in a URL. We refuse a key sent in a URL (401
key_in_url), because URLs end up in logs and browser history. - Never share it in a screenshot, a chat, an email or a support message. If someone needs to call the API, they make their own key on their own account.
- Give each app its own key with a clear name. Then you can stop one without stopping the others.
🔗Store it in an environment variable
Keep the key out of your code. Put it in an environment variable, or in your host's secrets manager, and have your code read it by name.
export CA_API_KEY="paste your key here"
Your code then reads CA_API_KEY where the examples on these pages write YOUR_API_KEY. If you keep it in a .env file, add that file to .gitignore so it is never committed.
🔗If your key leaks
Act right away, even if you are not sure anyone saw it. Both of these are in Settings > API, and each takes effect at once.
- Revoke stops the key at once. It cannot be turned back on.
- Rotate gives you a new key and stops the old one right away. If your apps need time to switch, you can let the old key keep working for up to 7 days. After a leak, keep the default, Right away.
Then put the new key where the old one was. This is why Rotate and Revoke are there.
🔗Spot a key being misused
- Settings > API usage shows your requests and credits over time, split by key, and by endpoint. A key busy when your app is not is a sign.
- Settings > Usage shows the credits used this period. Under When you near your limit, set the levels at which we email you.
- Settings > API lists the changes made with your API keys.
- We email you each time a key is made or rotated on your account, with its name and last four characters. If you did not make it, revoke it.
If something looks wrong, revoke the key first and look into it after.