Limit actions that can be abused
An API can let one user send messages, request password resets, search large datasets or start expensive work. Set limits that match the cost and business purpose of each action.
A single limit per IP address can affect a shared office or mobile network. Use account, token, device and network signals where they fit the design.
Return clear limits to clients
Use a consistent response when the client reaches a limit. Tell the client when it can try again where that information is safe to provide.
Use queues or quotas for long-running work. Set limits on request size, page size, query cost and concurrent jobs as well as request count.
Monitor and tune the policy
Log limit events and review patterns that affect real users. Alert on large changes or repeated attempts to bypass a control.
Test normal traffic, bursts and abusive patterns in a test environment. Review limits when product behaviour or traffic changes.
