What is API security? API security is the practice of protecting application programming interfaces from misuse, abuse and attack by controlling who can call them, what they can do, what data they return and how traffic is monitored. APIs expose business logic and data directly, so they have become a primary target for attackers, with risks such as broken object level authorisation, weak authentication, excessive data exposure and abuse of business flows. Effective API security combines strong authentication and authorisation, input validation, rate limiting, encryption, inventory and monitoring across the whole API lifecycle. This guide explains the main threats, a layered defence model, concrete controls, testing practices and how to build API security into delivery.
Short answer: API security protects APIs through authentication, fine grained authorisation, validation, rate limiting, encryption, an accurate inventory and continuous monitoring, guided by the OWASP API Security Top 10 risks.
What is API security?
The OWASP API Security Project documents the most critical risks for APIs. API security applies across APIs, the API gateway and microservices, and relies on standards such as OAuth and OpenID Connect. It is a core part of cyber security and cloud security.
Top API security risks

| Risk | What goes wrong | Primary defence |
|---|---|---|
| Broken object level authorisation | User changes an ID and reads another record | Check ownership on every object access |
| Broken authentication | Weak tokens, credential stuffing, missing MFA | Strong auth, token validation, lockouts |
| Broken object property level authorisation | Excessive data returned or fields modified | Explicit response schemas and allowed fields |
| Unrestricted resource consumption | Floods or expensive queries cause outages | Rate limits, quotas, pagination, timeouts |
| Broken function level authorisation | Normal users call admin functions | Role checks per function |
| Unrestricted access to sensitive business flows | Bots abuse purchase or signup flows | Behaviour limits and bot controls |
| Server side request forgery | API fetches attacker chosen URLs | Allow lists and network egress controls |
| Security misconfiguration | Open debug, permissive CORS, default settings | Hardened baselines and review |
| Improper inventory management | Forgotten and shadow APIs stay exposed | Catalogue and retire old versions |
| Unsafe consumption of third party APIs | Trusting upstream data blindly | Validate and limit external responses |
A layered defence model
| Layer | Controls |
|---|---|
| Edge and gateway | TLS, authentication, rate limiting, schema validation, WAF and bot protection. See what is API management |
| Identity | OAuth 2.0, OIDC, short lived tokens, MFA for sensitive access |
| Authorisation | Object, property and function level checks in the service |
| Data | Minimal responses, masking, encryption at rest and in transit |
| Network | Segmentation, private endpoints, mutual TLS between services |
| Operations | Logging, anomaly detection, alerting and incident response |
Essential API security controls
- Authenticate every request and prefer short lived tokens over static keys.
- Authorise on the server for each object and function, never trusting client supplied IDs or roles.
- Validate input against a schema and reject unexpected fields and types.
- Return only needed fields and avoid verbose error messages.
- Apply rate limits, quotas and request size limits per consumer.
- Encrypt traffic with TLS and consider mutual TLS between services.
- Keep secrets out of code and URLs, and rotate keys and tokens.
- Log security relevant events without storing sensitive payloads.
How to build API security into delivery
- Maintain an inventory. Discover all APIs, owners, versions and data classes, including shadow and legacy APIs.
- Design securely. Threat model new APIs and define authentication, authorisation and data rules in the specification.
- Automate checks. Lint OpenAPI files, scan code and dependencies and run dynamic tests in pipelines.
- Test authorisation deliberately. Write tests that try cross user and cross tenant access.
- Protect at runtime. Use a gateway, rate limits and anomaly detection for abuse and fraud.
- Monitor and respond. Alert on unusual patterns, rehearse incident response and revoke credentials quickly.
- Retire safely. Version, deprecate and remove old endpoints with notice.
Our API development service builds secured, well governed APIs, and our DevOps service adds automated security testing to your pipelines.
A worked example: closing an object level authorisation gap
A customer portal API exposes an endpoint to fetch invoices by invoice number. A penetration test shows that any signed in user can change the number and read other customers invoices, because the service checked that the user was logged in but not that the invoice belonged to them. The fix adds an ownership check in the data access layer so every query is scoped to the caller tenant and user.
The team then adds automated tests that call each endpoint with another tenant token, a gateway rule that limits request rates per customer and monitoring that alerts when one token requests many sequential identifiers. A review of the inventory finds two old API versions still online without these protections, and they are retired after notifying the few remaining consumers.
Testing and continuous assurance
Combine several kinds of testing. Static analysis and dependency scanning catch code and library issues early. Dynamic testing and fuzzing exercise running APIs with malformed and hostile input. Manual penetration tests focus on business logic and authorisation, which tools miss. Schedule tests regularly and after major changes, track findings to closure and measure trends such as time to fix and the share of APIs with automated authorisation tests.
Governance, compliance and data protection
APIs often move regulated data, so connect API security to privacy and compliance programmes. Classify the data each API handles, apply the strictest rules to the most sensitive endpoints, keep audit logs for access to personal data and respect retention limits. Review third party and partner APIs before integration, set contractual security requirements and make security part of the definition of done for every release, so controls are maintained as the estate grows.
Authentication and authorisation in practice
Authentication answers who is calling, and authorisation answers what that caller may do. Many API breaches come from getting the second part wrong while the first looks sound. A valid token proves identity, but every request still needs a check that this identity may access this specific object and perform this specific action. Put that logic in a shared layer so developers cannot forget it, express it as policy where possible and test it with cases that deliberately cross user, tenant and role boundaries.
For machine to machine calls, use short lived credentials issued through a standard flow, scope them narrowly and rotate them automatically. Avoid long lived API keys in client code, mobile apps and repositories, and treat any key that appears in a log or ticket as compromised.
Protecting against abuse and automation
Not every attack exploits a bug. Attackers script legitimate calls to scrape catalogues, stuff credentials, reserve inventory or exploit promotions. Defences include per consumer quotas, limits on sensitive flows such as login and password reset, device and behaviour signals, challenge steps for suspicious traffic and monitoring of business metrics, not only technical ones. Work with product and fraud teams to define what abnormal looks like, so alerts reflect real business harm.
Key takeaways
- API security protects the interfaces that expose business logic and data.
- The biggest risks include broken object level authorisation, weak authentication and unrestricted resource use.
- Defence in depth combines gateway controls, strong identity, server side authorisation and monitoring.
- An accurate API inventory and retirement process prevent forgotten attack surface.
- Automate testing in pipelines and test authorisation deliberately.
Quick glossary
| Term | Meaning |
|---|---|
| BOLA | Broken object level authorisation |
| Rate limiting | Restricting how often a consumer can call an API |
| Shadow API | An API running without inventory or oversight |
| mTLS | Mutual TLS where both sides present certificates |
| Schema validation | Rejecting requests that do not match the API contract |
Read next: What Is API Management? Lifecycle, Features, Tools · What Is a Message Queue? Patterns and Best Practices · What Is RabbitMQ? Exchanges, Queues and Use Cases
Frequently asked questions
What is API security in simple terms?
It is protecting APIs so only the right users and systems can call them, only for the right data and actions, and abuse is detected and stopped.
What are the top API security risks?
Broken object level authorisation, broken authentication, excessive data exposure, unrestricted resource consumption, function level authorisation flaws and poor inventory management.
How do I authenticate APIs securely?
Use standards such as OAuth 2.0 and OpenID Connect with short lived tokens, validate tokens on every call and add MFA for sensitive user access.
What is rate limiting for?
It caps the number of requests a consumer can make, protecting backends from overload, brute force attacks and scraping.
Is an API gateway enough for security?
No. A gateway adds important controls, but services must still enforce authorisation, validate data and avoid exposing excessive information.
What is a shadow API?
It is an API that exists and is reachable but is not in the official inventory, so it is rarely reviewed, patched or monitored.
How often should APIs be tested?
Automate checks in every build and perform deeper manual testing regularly and after major changes or new features.
Do internal APIs need security?
Yes. Internal APIs can be reached by compromised accounts or systems, so apply authentication, authorisation and monitoring there too.
