Best Practices for API Security Every Team Should Know
- Bryan Wilks
- Aug 27
- 11 min read
84% of security professionals experienced an API security incident in the previous 12 months, up from 78% in 2023, according to Akamai's 2024 API Security Study. That change matters because APIs don't merely display pages. They expose customer records, payment actions, partner workflows, internal services, and increasingly, AI tools.
The best practices for API security therefore go beyond adding an authorization header or placing a gateway in front of an endpoint. A durable program connects each control to a threat, assigns ownership, and verifies behavior against realistic user workflows. The standard to aim for is simple: an API that looks secure in a design document must remain secure when real clients, attackers, partners, bots, and automated agents interact with it.
Table of Contents
Why API Security Is Now a Board-Level Concern - Why APIs create a different risk profile
The OWASP API Security Framework and Standards - Use standards as design anchors - Build the security program in layers
Designing Authentication, Authorization, and Identity - Put authorization beside the resource decision
Hardening Requests, Responses, and Runtime Behavior - Enforce the contract before business logic - Match throttling to the threat - Protect transport and evidence
Governing Shadow APIs and Third-Party Integrations - Make discovery continuous
Testing, Monitoring, and Responding to Incidents - Build gates into delivery - Test the workflows attackers target - Practice response, not just detection
Why API Security Is Now a Board-Level Concern
An API is the contract that lets a client read data, write data, or trigger a business action. When that contract is abused, the impact can reach far beyond a technical defect. An attacker might retrieve another customer's records, manipulate an order, automate account takeover attempts, or use a trusted integration as a path into sensitive systems.
The same Akamai study found that only 27% of organizations had a full API inventory and knew which APIs exchanged sensitive data, down from 40% in 2023. The report also cited an average U.S. remediation cost of $591,404 per API incident, rising to $832,801 in financial services. Those figures turn API inventory, data classification, and ownership into executive concerns, not housekeeping tasks.
Why APIs create a different risk profile
Traditional web applications usually expose a user interface designed for human interaction. APIs expose reusable capabilities that can be called directly, repeatedly, and at machine speed.
Dimension | Traditional Web App | Public API |
|---|---|---|
Primary consumer | Human using a browser | Applications, partners, mobile clients, bots, and agents |
Exposure pattern | Pages and interactive workflows | Structured endpoints and reusable business functions |
Common failure impact | Affected page or session | Data aggregation, automated abuse, or unauthorized transactions |
Trust relationships | Usually controlled by one organization | Often shared across partners and third parties |
Security challenge | Protect the interface and session | Protect identity, objects, functions, workflows, and data flows |
An API can also aggregate information efficiently. A single broken object-level check may let a caller enumerate records that the interface never links to directly. A partner integration can spread an exposed credential across systems. Machine-to-machine automation can repeat a profitable abuse pattern long after a human attacker would have been noticed.
Executive question: Can the organization identify every API, the data it handles, its owner, and the workflows it can trigger?
That question introduces the four lenses used throughout this guide: threats, controls, governance, and production-like verification. Threats explain what can go wrong. Controls reduce the likelihood or impact. Governance ensures those controls apply across teams and environments. Verification proves that the controls work under realistic flows.
The failure mode to prevent is design-doc security. A team can document OAuth, validation, and rate limits while an overlooked endpoint trusts a client-supplied user ID, returns unnecessary fields, or bypasses authorization during a checkout workflow. Secure API engineering begins when those assumptions meet actual traffic.
The OWASP API Security Framework and Standards

The OWASP API Security Top 10 gives developers a shared vocabulary for API failures. Its categories cover broken authentication, broken object-level authorization, excessive data exposure, lack of resources and rate limiting, broken function-level authorization, unrestricted access to sensitive business flows, server-side request forgery, security misconfiguration, improper inventory management, and unsafe consumption of APIs.
Each category points to a different testable failure:
Broken authentication: A stolen or malformed token reaches a protected endpoint.
Broken object-level authorization: A user changes an object identifier and reads another customer's order.
Excessive data exposure: A profile endpoint returns internal fields the client does not need.
Lack of resources and rate limiting: Repeated search or login requests degrade the service.
Broken function-level authorization: A regular user invokes an administrative operation.
Unrestricted access to sensitive business flows: A bot abuses a coupon, payment, booking, or password-reset workflow.
Server-side request forgery: An endpoint fetches an attacker-controlled destination from inside the network.
Security misconfiguration: Debug errors, permissive cross-origin rules, or unsafe defaults reveal implementation details.
Improper inventory management: A deprecated or undocumented endpoint remains reachable in production.
Unsafe consumption of APIs: A service trusts a partner response without validating its origin, structure, or content.
Use standards as design anchors
NIST's Special Publication 800-228 presents a risk-based approach to protecting cloud-native APIs across their lifecycle. It addresses request and response validation, resource-consumption controls, and basic and advanced safeguards before runtime and during runtime.
OWASP helps teams name and prioritize attack categories. NIST helps organize controls across design, deployment, and operation. Use both as starting points, then verify each control in production-like flows. A checklist can say that object authorization exists, while a replayed request can reveal whether it protects every object and workflow.
Build the security program in layers
An API platform works like a building:
Foundations: Discover APIs, maintain an inventory, classify data, and assign owners.
Walls: Enforce authentication, authorization, input validation, and safe response handling.
Roof: Add rate limits, quotas, resource controls, and abuse detection.
Operations: Log security events, monitor behavior, rehearse incident response, and retire unsafe interfaces.
A strong wall cannot compensate for a missing foundation. If a shadow endpoint is absent from the inventory, its authentication and authorization policies may never receive review. If operations cannot detect unusual object access or data movement, a sound design can still fail in production. Teams should also examine business-logic abuse and emerging MCP or AIML integrations, where trusted automation may trigger sensitive actions at machine speed.
For practical background on unauthorized data movement, see this data exfiltration security overview.
Designing Authentication, Authorization, and Identity
Authentication answers, “Who is calling?” Authorization answers, “What may that caller do to this particular resource, function, or workflow?” These are separate gates. A valid identity does not grant ownership of every object or permission to trigger every business action.
For delegated user access and service identities, OAuth 2.0 and OpenID Connect provide a strong default. OAuth handles delegated access, while OpenID Connect adds an identity layer for user authentication. Mutual TLS suits service-to-service trust when both systems should prove identity with certificates. Scoped API keys can serve simple machine consumers if teams restrict permissions, protect the keys, and support revocation. High-value operations may also need signed request tokens or another integrity mechanism.
Put authorization beside the resource decision
OWASP identifies broken object-level authorization, or BOLA, as a top API risk. Every endpoint that accepts an object ID must perform an object-level check on the server, using policy tied to the authenticated user or service. GUIDs and other unpredictable identifiers make enumeration harder, but they do not replace authorization.
A secure handler takes identity from the verified token or connection context, loads the requested object, and evaluates whether that identity may perform the requested action. It must not treat a user ID in the request body, query string, or URL as proof of ownership. Production-like tests should replay requests against another tenant's object, then verify both the denial and the absence of sensitive detail in the response. This catches BOLA that a design document can miss.
Consumer Type | Recommended AuthN | AuthZ & Object-Level Check | Common Anti-Pattern |
|---|---|---|---|
First-party user apps | OAuth 2.0 with OpenID Connect | User scopes plus server-side object and function checks | Long-lived bearer tokens |
Partner integrations | OAuth 2.0 client credentials or scoped keys | Partner scope, tenant policy, and object ownership checks | One shared credential for every partner |
Internal microservices | mTLS with workload identity | Service identity, endpoint policy, and resource-level authorization | Trusting network location alone |
Batch jobs | Short-lived service credentials | Job-specific scope and data partition checks | Permanent, broad administrative keys |
AI agents calling tools | Short-lived delegated tokens | Tool allowlists, user policy, object checks, and workflow limits | Treating the agent as a fully trusted user |
Identity design also needs executive ownership. Guidance on policy design for IT directors connects conditional-access decisions with broader governance. Treat identity as a contract with consumers. Changing token claims, scopes, certificate trust, or ownership rules can require coordinated updates across applications and partners.
Secure transport and privacy controls belong in the same review, especially when credentials or customer data cross service boundaries. This illustration of identity and transport controls for API security decisions reinforces that identity decisions affect more than login. Teams should also apply the same checks to tool-calling AI agents, limiting available tools, delegated authority, objects, and workflow steps rather than treating the agent as a fully trusted user.
Hardening Requests, Responses, and Runtime Behavior
A secure API specification is only a starting point. Runtime defenses must control what enters the application, how much work each caller can demand, what leaves the service, and what the team can observe afterward.
Enforce the contract before business logic
Use schema-first parsing against an OpenAPI or equivalent schema. Reject malformed requests before they reach business logic, and validate types, lengths, ranges, formats, content types, and required fields. Reject unknown fields when they could alter behavior or hide an attacker's intent.
Response validation matters too. Return only the fields the consumer needs, avoid stack traces and internal service names, and apply consistent error formats. A profile request should not expose internal notes just because the database object contains them.
Match throttling to the threat
Rate limiting protects availability, but a global IP throttle is too blunt for many attacks. Credential stuffing can spread across addresses. A partner may legitimately send heavy traffic while an individual token behaves suspiciously. Use per-client, per-endpoint, per-token, and, where appropriate, per-account controls.
An independent systematic analysis reported a 94% reduction in successful DDoS attempts against context-aware controls compared with traditional IP-based approaches, while sliding-window algorithms showed a 2.3% false-positive rate in high-traffic scenarios. See the rate-limiting analysis for the cited findings.
Strategy | Granularity | Primary Use Case | Key Trade-off |
|---|---|---|---|
Global IP throttle | Network source | Basic flood reduction | Misses distributed abuse and can block shared networks |
Per-client bucket | Application identity | Partner and service quotas | Requires reliable client identity |
Per-token bucket | Credential or session | Credential theft and token abuse | Attackers may rotate tokens |
Per-endpoint policy | Route and operation | Protecting login, payment, or search flows | More policy maintenance |
Context-aware sliding window | Identity, route, behavior, and time | Adaptive abuse prevention | Needs telemetry and tuning |
Protect transport and evidence
Use current TLS configurations, preferably TLS 1.3, and consider mTLS for sensitive service-to-service paths. Payload-level encryption can protect particularly sensitive fields beyond transport boundaries. Signed responses can add integrity assurance when a consumer must detect tampering.
Structured logs should include correlation IDs, authentication outcomes, authorization failures, validation errors, and rate-limit events. Redact tokens, passwords, payment data, and other sensitive fields before logs reach a SIEM. Metrics should feed anomaly detection and response workflows, not remain as an unused dashboard.
Governing Shadow APIs and Third-Party Integrations
Inventory management is the least glamorous API control and one of the most important. The 2025 State of API Security report reports that organizations use an average of 131 third-party APIs, while only 16% say they can strongly mitigate external API risk. The same report estimates that shadow APIs create a 10% to 20% larger active API footprint than teams believe they have.
Those conditions make one-time certification unreliable. The same source reports that only 19% of organizations rate legacy defenses as highly effective for API protection, and 53% say WAFs and WAAPs don't effectively identify or prevent fraud at the API layer. A gateway can enforce useful policies, but it can't protect an endpoint the organization doesn't know exists or understand.

Make discovery continuous
Build the catalog by combining signals rather than trusting a single source:
Traffic telemetry: Identify routes, methods, response shapes, and callers observed in production.
Cloud inventories: Compare deployed load balancers, functions, service meshes, and gateway routes with registered services.
Repository searches: Find OpenAPI files, route declarations, SDKs, and integration credentials.
Runtime capture: Use sidecars or eBPF-based observation where suitable to identify service-to-service traffic.
Owner confirmation: Require a responsible team, data classification, lifecycle status, and retirement date for each interface.
Deprecated endpoints deserve active attention because they often retain access to valuable data while receiving less maintenance. Partner-managed APIs need contract reviews, credential controls, and evidence that their data handling matches your policy.
The emerging MCP and AI or machine-learning ecosystem adds another layer. Model servers, tool connectors, and agent workflows inherit the authorization and inventory gaps of the APIs behind them. A 2025 threat report cited 270% quarter-over-quarter growth in MCP vulnerabilities and reported that 16% of CISA KEV additions were API-related. Discovery should come first, followed by classification, ownership, control assignment, and continuous retirement.
Testing, Monitoring, and Responding to Incidents
Security controls earn trust through evidence. A design review can confirm that an authorization function exists, but only testing can show whether it runs on every relevant route and workflow.
Build gates into delivery
Run SAST, dependency checks, secrets detection, and OpenAPI linting in CI/CD. Treat critical findings as merge gates rather than advisory messages. Contract tests should exercise authentication requirements, response schemas, error behavior, and compatibility between consumers and providers.
Schema-seeded fuzzing can then push malformed types, unexpected fields, boundary values, and unusual sequences through the API. It can expose parser failures, unsafe assumptions, and business-logic weaknesses that ordinary happy-path tests miss.

Test the workflows attackers target
Create production-like scenarios with separate identities and realistic data relationships:
BOLA tests: Authenticate as one user and request another user's object. Confirm the server denies access without revealing metadata.
Function checks: Attempt administrative actions with a lower-privilege identity.
Business-logic tests: Repeat coupon, payment, booking, refund, and password-reset sequences to detect abuse that individual endpoint tests miss.
Credential abuse tests: Simulate failed logins, token refresh anomalies, and rapid attempts across accounts.
Scraping tests: Request records in patterns that reveal enumeration, aggregation, or excessive traversal.
Runtime monitoring should baseline normal behavior by client, route, token, account, and data sensitivity. Alert on authorization failures, unusual object access, credential stuffing, scraping, impossible travel, and velocity spikes during token refresh. Detection must connect to an owner who can investigate.
Practice response, not just detection
An API incident workflow should be rehearsed:
Declare: Assign an incident lead and define the affected interfaces.
Contain: Revoke tokens, block routes, restrict clients, or deploy a carefully scoped WAF rule.
Eradicate: Remove the flaw, rotate exposed credentials, and close related paths.
Communicate: Coordinate customer, legal, compliance, and partner notifications.
Learn: Write a blameless postmortem and update tests, detection rules, and the control catalog.
Enterprise Checklist and Compliance Mapping
An enterprise API program needs named deliverables, not a document that says “secure the API.” Organize the work into five phases and assign each phase to accountable owners.
Inventory: Security engineering owns the catalog, while platform teams provide deployment and traffic signals.
Classify: Data owners label sensitivity, business criticality, consumer type, and retention requirements.
Harden: Development teams implement authentication, object and function authorization, validation, encryption, resource controls, and safe responses.
Verify: Product security runs automated tests, contract checks, fuzzing, and production-like authorization scenarios.
Respond: Security operations monitors behavior, incident response maintains playbooks, and service owners rehearse containment.
NIST SP 800-228 provides a risk-based lifecycle structure, while the OWASP categories help teams connect findings to recognizable attack patterns. Regulatory mapping should show evidence rather than claim that one framework automatically satisfies every obligation. PCI DSS 4.0, HIPAA, GDPR, and SOC 2 each require careful interpretation within the organization's scope.
Control | OWASP API Top 10 | NIST SP 800-228 | PCI DSS 4.0 | HIPAA | GDPR | SOC 2 |
|---|---|---|---|---|---|---|
Scoped OAuth 2.0 with object checks | Broken authentication, BOLA, broken function authorization | Identity, authorization, and runtime protection | Access control and authentication evidence | Access control and audit evidence | Data protection and privacy by design evidence | Logical access and change-control evidence |
Request and response validation | Excessive data exposure, injection-related abuse, misconfiguration | Validation controls before and during runtime | Secure development and testing evidence | Integrity and security safeguards | Data minimization and security evidence | Processing integrity and security evidence |
Inventory with owners and retirement status | Improper inventory management | Lifecycle governance | Asset and service scope evidence | System inventory evidence | Records and accountability evidence | Risk and control inventory evidence |
Monitoring with redacted structured logs | Unusual abuse, authentication and authorization failures | Runtime monitoring and response | Logging and monitoring evidence | Audit controls | Breach detection and accountability evidence | Monitoring and incident-response evidence |
Use this cloud security assessment resource when organizing evidence across cloud-hosted API services.
Re-run the checklist quarterly, after every new integration, and after each significant incident. A launch gate catches defects before release, but a governance committee that reviews ownership, inventory changes, exceptions, incidents, and retirement progress quarterly can catch drift that a one-time certification misses.
Freeform Company offers compliance assessments, data protection guidance, and bespoke AI integration services that can help teams connect API security controls with broader governance and digital transformation work. Visit Freeform Company to explore its technology and compliance resources and apply a discovery-first approach to your API security program.
