API Security

What is API Security?

API security is the protection of application programming interfaces through authentication, authorization, encryption, input checks, rate limits and monitoring. Its main concern is that callers reach only the data they are entitled to.

Updated November 2026 · 4 min read


API security is the set of practices, controls and tools that protect application programming interfaces from misuse and attack, so that only the right clients can call them, each caller can reach only the data and actions it is entitled to, and the API keeps working under hostile traffic. It covers authentication, authorization, encryption, input validation, rate limiting, monitoring and the management of every API an organization exposes.

APIs need their own security focus because they expose business logic and data directly. A web page might hide another customer's record, but the API behind it will return that record to anyone who changes an ID in the request if authorization is not checked on the server. Many API breaches involve no exotic exploit at all: an attacker simply calls a legitimate endpoint in a way its designers did not expect.

The OWASP API security top 10

The Open Worldwide Application Security Project (OWASP) publishes a list of the most critical API risks. The first edition appeared in 2019 and was updated in 2023. The 2023 list is:

  1. Broken object level authorization. Users can access other users' objects by changing an ID.
  2. Broken authentication. Weak or flawed login, token or session handling.
  3. Broken object property level authorization. The API exposes or allows changes to fields the caller should not see or edit.
  4. Unrestricted resource consumption. No limits on request volume, payload size or cost, enabling denial of service or runaway bills.
  5. Broken function level authorization. Ordinary users can call administrative functions.
  6. Unrestricted access to sensitive business flows. Automated abuse of flows such as sign-up, checkout or ticket purchase.
  7. Server-side request forgery. The API fetches a URL supplied by the caller without validating it.
  8. Security misconfiguration. Missing hardening, verbose errors, open CORS policies and similar gaps.
  9. Improper inventory management. Old, undocumented or forgotten API versions and hosts left running.
  10. Unsafe consumption of APIs. Trusting data from third-party APIs without validating it.

How to secure an API: Core controls

ControlWhat it doesCommon approaches
AuthenticationProves who or what is callingOAuth 2.0 and OpenID Connect tokens, mutual TLS, API keys for low-risk cases
AuthorizationChecks what the caller may do, on every requestScopes, role-based access control, attribute-based policies, object-level ownership checks
EncryptionProtects data in transitTLS for all traffic, no plain HTTP
Input validationRejects malformed or malicious requestsSchema validation against an API specification, allow-lists for fields
Rate limiting and quotasLimits abuse and resource exhaustionPer-client limits, payload size limits, timeouts
Inventory and lifecycleKeeps track of every API and versionAPI catalog, deprecation policy, retiring old versions
Logging and monitoringDetects attacks and supports investigationCentralized logs, alerts on unusual call patterns

An API gateway can enforce authentication, rate limits and logging in one place, which is one reason API management and API security are closely linked. Authorization on individual objects, however, usually has to be implemented in the service itself, because the gateway does not know who owns each record.

Building security into the API lifecycle

  • Design. Threat-model new APIs, define scopes and data exposure up front, and return only the fields clients need.
  • Build. Use shared libraries for authentication and authorization rather than reimplementing them in each service.
  • Test. Include authorization tests (user A cannot read user B's data), fuzzing and automated security scans in the pipeline, an approach often called DevSecOps.
  • Operate. Monitor for unusual patterns, rotate credentials and patch dependencies.
  • Retire. Shut down deprecated versions on a published schedule instead of leaving them running.

API security in practice

Consider a hypothetical fitness app whose mobile client calls GET /users/{id}/workouts. The API checks that the request carries a valid token but not that the token belongs to the user in the URL. A researcher notices that changing the ID returns other people's workout histories, including GPS routes. That is broken object level authorization, the first item on the OWASP list.

The fix has three parts. The service now compares the user ID in the token with the owner of the requested records and returns an error on a mismatch. The team adds automated tests that try cross-user access on every endpoint that takes an ID. And an inventory review turns up an older version of the same API, still live for an unsupported app release, with the same flaw, so it is shut down. The team also adds rate limits so that a script cannot walk through millions of IDs in minutes.

Common pitfalls

  • Relying on the client to hide data. Anything the API returns can be read, whatever the app displays.
  • Checking authentication but not authorization. A valid token says who the caller is, not what they may access.
  • Treating API keys as user identity. Keys identify an application, are often embedded in code and leak easily.
  • Forgetting old versions. Unlisted or deprecated endpoints are a common route into otherwise well-protected systems.
  • Logging secrets. Tokens, passwords and personal data in logs create a second breach waiting to happen.

API security is part of a wider security architecture. Product teams building an API as part of an API-first strategy should treat it as a product requirement from the first design review, alongside privacy by design.

Frequently asked questions

What is the OWASP API Security Top 10?

It is a list of the most serious API risks published by the Open Worldwide Application Security Project, first released in 2019 and updated in 2023. The 2023 list starts with broken object level authorization and also covers broken authentication, unrestricted resource consumption, server-side request forgery, security misconfiguration, improper inventory management and unsafe consumption of third-party APIs.

What is the difference between authentication and authorization in API security?

Authentication proves who or what is calling the API, typically with OAuth 2.0 or OpenID Connect tokens, mutual TLS, or API keys for low-risk cases. Authorization decides what that caller may do and must be checked on every request, down to individual objects. A valid token says who the caller is, not whether they should see a given record.

Can an API gateway handle API security on its own?

No. An API gateway can enforce authentication, rate limits and logging in one place, which is why API management and API security are closely linked. Object-level authorization usually has to live in the service itself, because the gateway does not know who owns each record. Services still need their own ownership checks, input validation and tests.

How do you test an API for security flaws?

Add authorization tests that confirm one user cannot read or change another user's data, run fuzzing and automated security scans in the build pipeline, and threat-model new APIs at design time, an approach often called DevSecOps. In production, monitor for unusual call patterns, rotate credentials, patch dependencies and retire deprecated API versions on a published schedule.