Abuse prevention
API Bot Protection Without Blocking Real Users
Published: 19 September 2026
Protect the business action that a bot abuses, then measure whether the control also hurts legitimate clients.
Identify the abused outcome
API bot protection should begin with a specific business harm. A scraper might copy a catalogue faster than licensed clients can, a credential-stuffing bot might test leaked passwords, or an automated buyer might reserve scarce stock. These flows have different signals and acceptable friction. Name the action, asset, normal user journey, and impact before choosing a generic block rule.
Map endpoints involved in the flow, including login, search, detail pages, checkout, and callbacks. A bot can spread activity across IP addresses and accounts, so a single endpoint rate limit may miss it. Conversely, a shared corporate network may put many legitimate users behind one IP. Build controls around identity, session, device, and behavioural context with privacy review where necessary.
Set layered quotas
Use a small burst allowance and a sustained quota for inexpensive endpoints, with stricter budgets for costly searches and sensitive actions. Apply per-account and per-client limits when identities are reliable, plus coarse network limits for anonymous traffic. Make the limit key and reset behaviour explicit to clients. A 429 response should tell well-behaved callers how to back off without revealing the full detection policy.
Bound work per request as well as request count. Pagination maxima, query-cost caps, and export concurrency limits reduce the damage of one call. Keep authentication attempts and password reset flows under separate policies because their harm is different from general read traffic. Test distributed attempts and account rotation in a controlled environment.
Use challenges selectively
Interactive challenges may help on browser flows, but they can be inappropriate for machine-to-machine APIs, accessibility needs, or mobile clients. Decide which clients can complete a challenge and provide a documented recovery path. Do not add a CAPTCHA to every request simply because a bot is possible. Use risk signals to add friction where it protects a meaningful action.
For credential stuffing, combine breached-password controls, multi-factor authentication where suitable, account and network throttling, and alerts for repeated failures. Avoid revealing whether an account exists through different messages or timing. For scraping, consider client contracts, scoped keys, quotas, caching, and legal or commercial terms alongside technical controls. No one signal perfectly distinguishes automation from a valuable customer.
Measure effectiveness and collateral damage
Track the number of protected business actions, rejected attempts, successful legitimate sessions, support complaints, and client errors after a rule change. A drop in traffic is not automatically a security win if authorised partners were blocked. Roll out controls in observation mode when possible, then tighten with a rollback path. Review false positives by client type and region without storing unnecessary fingerprint data.
Keep incident response practical. When an attack begins, operators need a way to change quotas, revoke compromised keys, and communicate with affected clients. Time-limit emergency blocks and preserve enough evidence to understand what happened. After the event, update the flow model and add a regression test for the bypass that worked.
Document what static review can see
An OpenAPI contract can describe 429 responses, page limits, and authentication schemes. APISAST may flag absent rate-limit documentation or unbounded collection design signals in that file. It cannot detect a bot, enforce a quota, inspect live account behaviour, or judge whether a challenge blocked a human. Separate design review from operational evidence.
Review protection when a new client or business feature changes normal usage. A quota suited to individual users may be too small for an approved batch integration. Give legitimate high-volume clients a scoped plan and measure it separately. Good bot protection preserves the intended API experience while making abusive automation costly and visible.
Example: protecting a reservation flow
A reservation API may let a user hold a scarce item for a short period. An attacker can create many accounts and hold inventory without completing purchases. An IP limit helps only partly because traffic can be distributed. Limit simultaneous holds per account and payment instrument where lawful and practical, set a short hold expiry, and monitor the ratio of holds to completed orders. Make it easy for a legitimate customer to recover from an accidental limit.
Test a normal purchase, repeated holds from one account, distributed holds across several test identities, and expiry cleanup. Verify that the system releases inventory and does not charge twice when a client retries. Review whether a fraud rule would block families or organisations sharing a network. The meaningful metric is available inventory and completed legitimate orders, not the raw count of requests blocked.
Handle credential abuse separately
Login and token endpoints need their own protection because a successful credential-stuffing attempt gives an attacker a valid identity. Rate limit failed attempts across account and network signals, alert users when appropriate, and require stronger verification for suspicious sessions. Avoid permanent account lockouts that an attacker can use to deny service to a victim.
Measure both prevented attacks and genuine account recovery. If a challenge or reset flow fails for legitimate users, they may abandon the service or contact support in ways that create new risk. Keep support procedures resistant to social engineering and log privileged overrides. This flow deserves a threat model separate from catalogue scraping. Keep error messages consistent for known and unknown accounts. During an identity-provider outage, retries from real clients can resemble an attack; responders need deployment and provider context before applying a broad block. Test whether legitimate users can recover after a temporary limit expires and whether suspicious sessions are still challenged. Record the outcome.
Continue the work
Use these guides to put the checks into your API review process:
Primary reference: OWASP API6 Sensitive Business Flows.
APISAST reviews OpenAPI and Swagger contracts for documented design signals. Confirm authorization, enforcement, performance, and abuse controls against a running service.
More API security guides