Skip to content
IT glossary
SecurityUpdated December 3, 2026

API key

API-ключ

An application sends this string with API requests so the service can associate them with a project, account, or app. The service may use it to control access, track usage, or enforce limits.

What an API key identifies

Suppose your store's backend uses an email provider to send order confirmations. The backend includes an API key with each request so the provider can attribute the traffic to the store's account. The key tells the provider which account is making the call, not which shopper placed the order.

A secret API key typically works by possession: anyone who has it can make calls with the permissions it carries. Not every API key is meant to be secret, though. A provider may issue a publishable key for a browser feature, such as displaying a map. That key can associate requests with a project for usage tracking, but it should not grant access to private data or privileged operations.

How the server uses it

The provider issues a key and associates it with a project, account, or integration. The client follows the provider's instructions for sending it. Many HTTP APIs use a header such as X-API-Key, but there is no universal API key header. The API or its gateway checks whether the key is active, then applies any permissions and usage limits. A valid read-only key still cannot authorize a write, and a valid key can receive 429 Too Many Requests if its rate limit is exceeded.

Example: requesting a forecast

curl -H "X-API-Key: ${WEATHER_API_KEY}" \
  'https://weather.example/v1/forecast?city=Boston'

In this example, the host is fictional and the shell reads the key from an environment variable. The city belongs in the query string; a secret key is better sent in a header when the API supports it. URLs routinely appear in logs and traces. Use HTTPS to protect the request in transit, and configure proxies and monitoring tools to redact secret headers: HTTPS does not stop a server from logging them.

Common mistakes

Don't commit private keys to source control or bundle them in web or mobile apps. A build-time environment variable is not a safeguard if the build copies its value into code delivered to users. Keep private keys on a trusted backend, load them from a secrets manager, and give each integration and environment its own key with only the permissions it needs. That way, revoking a development key doesn't interrupt production traffic.

What interviewers ask

Would you use a single API key to let a third-party app read individual users' data? A shared project key doesn't tell the API which user delegated access. OAuth 2.0 is designed for delegated authorization and can provide short-lived access tokens with limited permissions.

How would you rotate a production key without downtime? If the provider supports overlapping keys, issue a replacement, switch clients, verify that requests succeed with the new key, and revoke the old one. If the old key is known to have leaked, revoke it as quickly as possible rather than waiting for a routine rotation.