Vezi pagina în română

IT Glossary

What is an API key?

A secret code with which one application identifies itself when using another's services — the password between programs.

6
sections
5
questions answered

An API key is a unique string of characters, issued by an online service, that your application sends with every request so the provider knows who is asking, what it may do and how much it has used. Think of a hotel key card: it opens your room and the gym at permitted hours, and reception can deactivate it at any moment. When your application requests data from an external service — a courier, a payment processor, a mapping provider — it presents the key. Billing, rate limits and permissions all hang off that key. Why this concerns you directly: API keys are the equivalent of company passwords and a favourite target for attackers, since a leaked payment key means money spent in your name. The hygiene rules are not complicated. Keys never go into the public code of a website, they are held in a secrets manager, they are rotated on a schedule, and each one gets only the minimum permissions it needs. It is entirely reasonable to ask your development team for evidence that all four are true.

Why it matters for your business

Granular control over access

Each integration gets its own key with exactly the permissions it needs, so compromising one does not open every door and revocation stays surgical.

Accurate traceability and billing

Consumption is measured per key, so you can see which integration generates cost, which one is being abused, and where the API subscription money goes.

Incidents stopped in one move

On any suspicion of a leak, the key is revoked and reissued within minutes — no company-wide password resets and no downtime for the other integrations.

What an API key looks like and how it is sent

A key is a long string of characters, often with a prefix that tells you its type, for example sk_live_… at Stripe. The application sends it with every request in an HTTP header, never in the URL (?apiKey=…): URLs end up in server logs, and the key would stay written there. The key ties the request to a project or account for billing and quota.

Mind the limit: a standard key identifies the application, not a person. Access to a specific user's data uses OAuth, and for sensitive resources a key alone is not enough.

Public key, secret key, test key

Stripe example: the publishable key (pk_…) may sit in browser code, because it cannot create charges or read account data. The secret key (sk_…) and the restricted key (rk_…) stay on the server only. The _test_ and _live_ prefixes separate test keys from production keys, and objects created in one mode do not appear in the other.

Google's browser keys (Maps, for example) sit in the page's code, so they are protected with HTTP-referrer, IP or app restrictions plus API restrictions. Google states that unrestricted API keys are insecure. The simple rule: anything visible in the browser is public, and only a key built to be public goes there.

Want an estimate for your project?

Message us on WhatsApp. We reply the same working day, and the first 30-minute call is free.

Book a free call

Where to find or how to generate an API key

The steps are the same at most providers: sign in to the provider's account, open the developers, API or settings section, choose "Create key", give it a name and the minimum permissions, then copy it immediately. Many services show it only once: Stripe does not let you reveal again a live key you created. A lost key is not recovered, it is replaced (rotated).

Store it in a secrets manager or a server-side environment variable, not in code and not in a document, and note where you saved it. Use a separate key for each integration and each environment.

What to do if an API key leaks

1) Revoke or rotate the key at once; for a leak choose expiration "Now", not a grace period (up to 7 days at Stripe) as in a planned rotation. 2) Put the new key in the secrets manager and redeploy. 3) Check the provider's request logs for what the old key did. 4) Remove it from the code and the Git history, but treat it as compromised even after deletion.

5) If the key gave access to personal data, the personal-data breach rules apply, with notification within 72 hours. The procedure is on the Data breach page, and our API integration service keeps keys out of the code.

Frequently asked questions

What is the difference between an API key and an OAuth token?

A key identifies an application and is usually static and long-lived. An OAuth token represents the consent of a specific user, expires quickly and carries fine-grained permissions. Server-to-server integrations use keys; access to customer data uses OAuth.

How does an API key end up leaked on the internet?

Most often through accidental publication in code on GitHub, or inside the site's visible JavaScript. GitHub scans public repositories and notifies the provider when it finds a key in that provider's format. Treat any key that ever appeared publicly as compromised, even if you deleted it.

How often should API keys be rotated?

At the interval your security policy sets, immediately when someone with access leaves or changes role, and instantly on any suspicion of compromise. Periodic rotation limits the damage from a key nobody knows has leaked. Rotation should be a rehearsed procedure, not an emergency improvisation.

Can I put an API key in my website or mobile app code?

Only a key built to be public: Stripe's publishable key (pk_) or a Google browser key restricted by domain. Secret keys (sk_) stay on the server: the site or app calls your server, and your server calls the provider. Anything shipped to a browser or installed app can be extracted.

Can I send an API key to a contractor by email or chat?

No. Stripe advises against sharing keys over email, chat or other unencrypted channels. Give the contractor their own key with minimum permissions, delivered through a secrets manager or password manager, and revoke it when the work ends. Messages linger in archives and on phones.