API Security Best Practices: A Practical Guide for 2026
API security best practices mapped to the OWASP API Top 10 and NIST SP 800-228: authorization per object, OAuth hardening, rate limits and API inventory.
API security comes down to one question asked on every request: is this caller allowed to do this to this specific object? Most serious API flaws are failures of authorization rather than encryption. The OWASP API Security Top 10 puts broken object-level authorization first [1]. The practical playbook is to keep an inventory of every API, authenticate with standard protocols, check authorization per object and per field, validate input against a schema, and rate-limit everything [2].
This guide is organized around what to do, in roughly the order NIST suggests adopting it. For the identity side, see our explainers on identity and access management and zero trust architecture.
Why APIs need their own security playbook
A web page hides most of its logic on the server. An API exposes it directly: endpoints take object IDs, return structured data and are designed to be called by machines at high volume. That shape creates specific risks, which OWASP tracks in a list last revised in 2023 [1]:
OWASP API risk (2023) | What goes wrong |
|---|---|
API1 Broken Object Level Authorization | The API accepts an object ID from the caller without checking the caller may access that object |
API2 Broken Authentication | Token or login flaws let attackers assume other identities |
API3 Broken Object Property Level Authorization | Callers can read or write fields they shouldn't (it merges 2019's "excessive data exposure" and "mass assignment") |
API4 Unrestricted Resource Consumption | No limits on requests, payload size or paid downstream actions such as SMS |
API5 Broken Function Level Authorization | Regular users can reach admin functions |
API6 Unrestricted Access to Sensitive Business Flows | A legitimate flow (buying tickets, posting comments) is abused at automated scale |
API7 Server Side Request Forgery | The API fetches a user-supplied URL and can be steered to internal targets |
API8 Security Misconfiguration | Unsafe defaults and configuration gaps across the API stack |
API9 Improper Inventory Management | Forgotten versions and debug endpoints stay exposed |
API10 Unsafe Consumption of APIs | Data from third-party APIs is trusted more than user input |
Four of the ten are about authorization or business logic, and a fifth is about authentication. Firewalls and TLS don't fix any of them.
The pressure on patching is also rising. Verizon's 2026 Data Breach Investigations Report found that exploiting vulnerabilities (31% of breaches) overtook stolen credentials as the top way in, for the first time in the report's 19 years. It said AI is "shrinking the window for defense from months to mere hours" [4]. For a public API, a known flaw left unpatched is a short-lived gamble. Our coverage of a 2026 ServiceNow API security incident shows how quickly API flaws become headlines.
1. Know every API you run
You can't protect an endpoint you don't know exists. NIST SP 800-228 (June 2025, updated in March 2026 with appendices that list API risks and controls by lifecycle stage) treats inventory and governance as basic controls. Every API should have a specification. Specs should use a well-defined interface language such as OpenAPI or gRPC. The organization should keep an inventory that includes internal, "shadow" and "zombie" APIs, along with a versioning and deprecation plan [2].
In practice:
- Generate or require an OpenAPI (or protobuf) spec for every service, and fail builds that ship undocumented endpoints.
- Use discovery tools or gateway logs to find traffic to endpoints that aren't in the inventory.
- Retire old versions on a schedule. OWASP's API9 exists because deprecated versions and debug endpoints linger [1].
2. Authenticate with standards, not home-grown schemes
NIST recommends standard mechanisms: OpenID Connect, OAuth 2.0 or SAML for end users, and SPIFFE identities, JWTs or API keys for services. Tokens must be cryptographically verifiable. That rules out JWTs with "alg: none", weak algorithms and long expiry times. Signing keys must be rotated [2].
If you use OAuth 2.0, the IETF's January 2025 security best current practice, RFC 9700, is the reference [3]. Its headline rules:
- The resource owner password credentials grant "MUST NOT be used." It exposes user passwords to the client and doesn't work with multi-factor authentication [3].
- Avoid the implicit grant. Clients "SHOULD NOT" use response types that put access tokens in the authorization response, because those tokens leak [3].
- Use PKCE. Public clients such as mobile and single-page apps must use it, and it's recommended for confidential clients too, with the S256 method [3].
- Match redirect URIs exactly. Authorization servers must use exact string matching, except for port numbers on localhost [3].
- Sender-constrain tokens where possible. Mutual TLS or DPoP binds a token to a key, so a stolen token is useless on its own [3].
NIST adds a subtle point. Don't hand internal JWTs, with their embedded permission claims, to untrusted outside callers. Use opaque tokens externally so you don't leak how your system models permissions [2].
3. Authorize every object and every field
This is where most API breaches live. Authentication tells you who is calling. Authorization must then answer, on every request, whether this caller may touch object 4815 and may see the field salary.
NIST's guidance is to authorize both the end user and the calling service. Use an access control model such as attribute-based access control, standard schemes such as OAuth scopes, and an auditing tool that checks regularly for missing or wrong policies [2]. Its advanced controls go further. They annotate each endpoint and field in the schema with the permission it requires, then enforce resource-level and field-level authorization as a cross-cutting policy instead of hand-written checks scattered through code [2].
Practical patterns:
- Never trust an ID just because it's in the URL. Look up the object, then check ownership or policy before returning or changing it. That's OWASP API1 [1].
- Return explicit field lists. Don't serialize whole database objects; this prevents the property-level exposure in API3 [1].
- Deny mass assignment. Reject or ignore writable fields the caller isn't entitled to set, such as
roleoris_admin. - Separate admin APIs. Put them on different routes with different authorization, so a regular token can't reach them (API5) [1].
Order matters too. NIST recommends authenticate, then authorize, then validate. Detailed validation errors returned to an unauthorized caller can leak whether a resource exists [2].
4. Validate requests and responses against a schema
A schema doubles as a security control. NIST recommends defining request and response schemas for each endpoint, and validating every request and response against the schema before the application processes it [2]. That blocks malformed payloads, unexpected fields and oversized inputs early.
Response validation is underused. It catches the case where a code change starts returning a field that should never leave the service.
5. Limit usage, and design for abuse of legitimate flows
OWASP's API4 and API6 both concern scale: requests that are individually valid but harmful in bulk [1]. NIST's controls are specific [2]:
- Rate-limit all API access for all callers, per user, service or network parameter, over short windows such as per minute.
- Treat rate limits and quotas as separate tools. A quota caps total usage over a long period, while a rate limit protects the system from bursts.
- Apply timeouts to every request, including at the gateway.
- Set payload size and bandwidth limits, and cap user-supplied query parameters such as page size.
- Limit concurrent requests.
For business flows, such as checkout, account creation or one-time-password sending, add flow-specific controls. Examples are device fingerprinting, step-up verification and per-account velocity limits. Generic rate limits miss a bot that buys every ticket at one request per second.
6. Encrypt everything, monitor everything
NIST says all runtime API traffic must be encrypted, even for "public data" or unauthenticated endpoints, to protect integrity as well as confidentiality [2]. It also recommends monitoring API access and being able to block specific callers or requests quickly, by network address, credentials or payload pattern [2]. Logs should record who called what, on which object, with what result. That's what you need to investigate an authorization flaw after the fact.
7. Treat third-party APIs as untrusted input
OWASP's API10 flips the usual direction: your service consuming someone else's API [1]. Validate responses from partners as strictly as user input. Use TLS. Don't follow redirects blindly. Set timeouts and resource limits on outbound calls. The same reasoning drives the SSRF risk in API7. Any feature that fetches a URL on a caller's behalf needs an allowlist [1].
A phased plan
NIST splits its controls into basic ones, which every organization should adopt now, and advanced ones that add deeper inspection [2]. A practical sequence:
Phase | Controls |
|---|---|
Now | Inventory and specs, TLS everywhere, standard authentication, object-level authorization checks, rate limits and timeouts |
Next | Schema validation of requests and responses, field-level authorization, OAuth hardening per RFC 9700, central logging |
Mature | Policy-as-code authorization from schema annotations, sender-constrained tokens, automated authorization audits, business-flow abuse detection |
Most of these controls run in a gateway, a service mesh or a shared library rather than in each service. NIST discusses the trade-offs between those options [2]. If you run on Kubernetes, our upcoming Kubernetes security architecture guide covers the platform side, and a dedicated piece on secrets management covers storing the keys your APIs depend on.
Frequently asked questions
What is the most common API vulnerability?
OWASP ranks broken object-level authorization first in its 2023 list. The API accepts an object identifier from the caller without checking whether that caller may access the object [1]. It's common because the check has to be written for every endpoint that takes an ID.
Are API keys secure enough?
API keys identify a calling application, and NIST lists them among acceptable service authentication mechanisms [2]. They don't identify an end user and are often long-lived. Pair them with per-user authorization, rotate them, and prefer short-lived, verifiable tokens for user-facing access.
Is the OAuth implicit flow still acceptable?
The IETF's OAuth security best current practice says clients should not use the implicit grant, or other flows that return access tokens in the authorization response, unless specific leakage risks are mitigated. It recommends the authorization code flow with PKCE instead [3].
Does an API gateway make my API secure?
A gateway is a good place to enforce authentication, rate limits, TLS and schema validation. It usually can't know whether user A owns order 4815, so object-level authorization still needs application context or a policy engine with that data [2].
How often should API security be tested?
Continuously, as part of the build. Breaking changes, new endpoints and new fields are when authorization gaps appear. Pair automated checks for undocumented endpoints and schema drift with periodic manual testing focused on authorization logic [1][2].
Sources
- OWASP Foundation, "OWASP Top 10 API Security Risks โ 2023." https://api-security.owasp.org/editions/2023/en/0x11-t10/
- Ramaswamy Chandramouli and Zack Butcher, NIST, "SP 800-228 upd1, Guidelines for API Protection for Cloud-Native Systems," June 2025, with updates as of March 13, 2026. https://csrc.nist.gov/pubs/sp/800/228/upd1/final
- T. Lodderstedt, J. Bradley, A. Labunets and D. Fett, IETF, "RFC 9700, Best Current Practice for OAuth 2.0 Security," January 2025. https://www.rfc-editor.org/rfc/rfc9700.html
- Verizon, "Vulnerability exploitation top breach entry point, 2026 industry-wide DBIR finds," May 19, 2026. https://www.verizon.com/about/news/breach-industry-wide-dbir-finds