Your mobile app, your online store, your integrations with payment gateways, with the ERP, or with a marketplace: everything talks through APIs. And an API is, in essence, a direct door to your data and your business logic, without the interface that might slow an attacker down. That is why OWASP maintains a specific list, the OWASP API Security Top 10, in addition to the web application Top 10.
Short answer: API security is about controlling who accesses your data and what they can do. The keys are authenticating with standards such as OAuth 2.0, validating authorization for each object on every request, limiting usage volume, validating inputs, and logging activity to detect abuse.
Why are APIs an attractive target?
An API (application programming interface) is the channel through which one system requests data or actions from another, and its security is the set of controls that decides who can use it and for what.
- They return structured data that is easy to extract in bulk.
- Many were built quickly, for a mobile app, and assume that "only the app will use them."
- They change frequently and old versions get left open.
- Attackers can automate tests at large scale.
1. How do I authenticate users and services in an API?
- Use standards: OAuth 2.0 and OpenID Connect for delegation and user access; do not invent your own scheme.
- Short-lived tokens with protected, revocable renewal (refresh tokens).
- If you use JWT, validate signature, issuer, audience, and expiration; use strong algorithms and do not accept unsigned tokens. Keep in mind that an already-issued JWT is not easily revoked, so its lifetime must be short.
- For service-to-service communication, use per-service credentials and, where appropriate, mutual authentication.
- API keys identify applications, not users; do not treat them as the only control for sensitive data.
- Protect login and account recovery endpoints against brute force and user enumeration.
2. Authorization: what are you allowed to do?
This is where APIs fail most, by far.
Object-level authorization
If GET /api/invoices/873 returns the invoice, do you verify that it belongs to your company? The server must check ownership of each resource on every request. Do not base security on identifiers being hard to guess; UUIDs help, but they do not replace verification.
Function-level authorization
A regular user should not be able to call POST /admin/users just by knowing the route. Define explicit roles and permissions and deny by default.
Property-level authorization
Avoid returning extra fields (the full database object) and avoid accepting fields the user should not modify, such as role, balance, or is_admin. Define explicit allowlists of input and output fields; this prevents mass assignment.
3. How do I limit API usage?
Without limits, an API is vulnerable to abuse, bulk extraction, and resource exhaustion.
- Rate limiting per user, per key, and per IP, with stricter limits on login, password reset, and code sending (which cost money if they use SMS).
- Size limits on requests and file uploads.
- Mandatory pagination with a maximum per page.
- Timeouts and complexity limits, especially in GraphQL (query depth and cost).
- Quotas for third-party integrations.
- Protection of sensitive business flows, such as ticket purchases or promotions, against abusive automation.
4. Input and output validation
- Define schemas (OpenAPI, JSON Schema) and reject what does not comply: types, lengths, formats, and ranges.
- Validate on the server, always.
- Use parameterized queries to prevent database injection.
- Be careful with server requests to user-supplied URLs (SSRF): use allowlists of destinations.
- Validate and limit uploaded files: actual type, size, and storage outside the public directory.
- Do not return internal errors or stack traces; respond with generic messages and log the detail on the server.
5. Transport and configuration
- HTTPS everywhere and appropriate security headers.
- Restrictive CORS: specific origins, not
*with credentials. - Disable HTTP methods you do not use.
- Separate environments and do not use real data in testing.
- Keep dependencies and the server up to date.
6. Inventory management
Many incidents come from forgotten APIs: old versions, test endpoints, exposed documentation, internal routes. Keep an inventory:
- Which APIs exist, who uses them, and what data they handle.
- Current versions and a retirement plan for obsolete ones.
- Public documentation only for what should be public.
- Restricted access to test environments.
7. Third-party integrations
Consuming third-party APIs is also a risk:
- Store credentials in a secrets manager, not in code.
- Validate and sanitize what you receive, even if it comes from a known partner.
- Verify the signature of the webhooks sent to you (payment gateways, messaging) and avoid processing the same event twice.
- Define timeouts and controlled retries, so as not to cascade failures.
- Review the permissions you grant to each integration; keep them to the minimum necessary.
8. Logging and monitoring
- Log failed authentications, denied access, permission changes, and traffic spikes.
- Do not log passwords, full tokens, or unnecessary personal data.
- Define alerts for anomalous patterns (many requests to different identifiers from the same source).
- Keep logs for a reasonable period for investigations.
Common mistakes
- Assuming only the mobile app will call the API.
- Validating permissions only in the interface.
- Returning the full object and "letting the app filter."
- No limits on login or on code sending.
- Tokens that never expire.
- Leaving old versions open.
- Public documentation and test environments with real data.
What should I check in an API before publishing it? Checklist
- All routes require authentication, except justified public ones.
- Every resource validates user or company ownership.
- Roles and permissions defined and tested with different accounts.
- Rate and size limits active.
- Input and output schemas defined.
- Secrets kept out of code and rotatable.
- API and version inventory up to date.
- Logging and alerts configured.
- Automated security tests in the development cycle and a periodic penetration test depending on risk.
When an external review makes sense
Before opening an API to third parties, when it handles payments or sensitive data, or after major architectural changes. The cost is indicative and depends on the number of endpoints and the scope.
At DaltoAura we design APIs with authentication, role-based permissions, limits, and automated tests from the start, because adding security at the end is usually more expensive and less effective.
For more context, see the guide to the OWASP Top 10 for web applications, secure CI/CD pipelines, and security with AI and LLMs.
Frequently asked questions
What is the BOLA vulnerability in an API?
BOLA stands for broken object-level authorization: the server does not verify that the requested resource belongs to the user. For example, changing the number in a URL and seeing another company's invoice. It is prevented by checking ownership of each resource on every request, on the server side.
Is an API key enough to protect my endpoints?
Not for sensitive data. A key identifies an application, not a person, and it can leak from a mobile app or a repository. Combine it with user authentication, object- and function-level authorization, usage limits, and key rotation.
What is rate limiting and why does it matter?
It is a limit on the number of requests a client can make in a period. It stops brute force, mass scraping, and abuse that drives up costs or takes the service down. It should be applied per user, per IP, and per endpoint, with stricter limits on login.
How often should I audit my APIs?
Keep a continuous inventory of endpoints and versions, run automated tests on every deployment, and do an external review at least annually or after major changes. The frequency depends on how sensitive the data it exposes is and how many third-party integrations depend on it.
Let's talk
If your business exposes or consumes APIs (mobile app, payment integrations, ERP, or third parties), we can review their design and harden them. Tell us what integrations you have.