API Rate Limits and Operational Limits¶
Understand how WhiteLotusAI should bound incoming requests, protect service resources, and handle throttling across external integrations.
Documentation status
Baseline: Source verification and runtime testing required.
This page distinguishes observed source declarations from verified enforcement. A configured default, plugin metadata field, or provider policy must not be treated as an enforced application limit without supporting evidence.
1. Purpose and Scope¶
Rate limits and operational bounds help prevent resource exhaustion, control dependency usage, and keep API behavior predictable under normal and abnormal workloads.
This document covers the following controls:
-
Request throttling
Limit request frequency by user, client, IP address, or another defined scope.
-
Bounded queries
Constrain result counts, pagination, request bodies, and expensive operations.
-
Timeouts and retries
Bound dependency waits and prevent uncontrolled retry behavior.
-
Abuse prevention
Protect application resources and handle external provider throttling safely.
The controls described here apply to the API gateway, application services, integration entry points, and external provider clients where relevant.
2. How Limits Fit Into the Request Flow¶
The following diagram illustrates the intended control points. It is a verification model, not a claim that every control is currently implemented in every service.
flowchart TB
CLIENT["Client or Frontend"]
GATEWAY["REST API Gateway"]
VALIDATE["Authentication and Input Validation"]
THROTTLE["Request Throttling"]
SERVICE["Application or Integration Service"]
BOUNDS["Result Bounds and Pagination"]
TIMEOUT["Timeout and Retry Policy"]
PROVIDER["External Provider API"]
RESPONSE["Response or Controlled Error"]
CLIENT --> GATEWAY
GATEWAY --> VALIDATE
VALIDATE --> THROTTLE
THROTTLE --> SERVICE
SERVICE --> BOUNDS
BOUNDS --> TIMEOUT
TIMEOUT --> PROVIDER
PROVIDER --> RESPONSE
THROTTLE -. "Rejected request" .-> RESPONSE
BOUNDS -. "Invalid or excessive input" .-> RESPONSE
TIMEOUT -. "Timeout or upstream failure" .-> RESPONSE
classDef entry fill:#E8F1FF,stroke:#3267A8,color:#17365D,stroke-width:1.5px
classDef control fill:#E4F5EA,stroke:#27804A,color:#174B2A,stroke-width:1.5px
classDef dependency fill:#FFF0D9,stroke:#B7791F,color:#704214,stroke-width:1.5px
classDef result fill:#F0E8FF,stroke:#7650A8,color:#45266B,stroke-width:1.5px
class CLIENT,GATEWAY entry
class VALIDATE,THROTTLE,BOUNDS,TIMEOUT control
class SERVICE,PROVIDER dependency
class RESPONSE result
Interpret the diagram correctly
Each stage represents a recommended or investigated control point. Confirm the actual request path, middleware order, and enforcement mechanism in the current source code before describing a control as implemented.
3. Types of Operational Limits¶
| Limit | Purpose | Evidence required |
|---|---|---|
| Request rate | Restricts requests over a defined time window | Middleware, limiter configuration, and threshold tests |
| Request body size | Prevents oversized payloads | Server configuration and application validation |
| Result count | Limits returned records | Endpoint defaults, minimums, maximums, and validation |
| Timeout | Bounds dependency wait time | Client configuration and timeout tests |
| Pagination | Bounds records retrieved across pages | Provider parameters, loop termination, and aggregate limits |
| Concurrency | Restricts simultaneous work | Semaphore, worker pool, queue policy, or equivalent mechanism |
| Provider throttling | Responds to external service quotas | Provider documentation, response handling, and retry tests |
| Resource consumption | Limits expensive operations | CPU, memory, queue, connection, or execution controls |
3.1 Distinguish defaults from enforced maximums¶
A default determines what happens when a caller omits a value. A maximum prevents the caller from exceeding a defined bound.
For example, a declaration equivalent to max_results=10 does not necessarily prevent a caller from requesting 1,000 results.
from fastapi import HTTPException, Query
async def list_events(
max_results: int = Query(default=10, ge=1, le=100),
):
# The framework validates the declared range.
# Provider-side and aggregate limits may still be needed.
...
The example demonstrates an explicit application-level input bound. It is illustrative and does not assert that this exact validation exists in WhiteLotusAI.
A complete limit policy should establish:
- The default value.
- The permitted minimum and maximum.
- Whether the bound is enforced at the API boundary.
- Whether downstream provider calls honor the same bound.
- Whether multiple pages can bypass the intended aggregate limit.
4. Integration-Specific Review¶
The following observations are based on the current documentation baseline and require confirmation against the relevant source revision.
| Integration | Observation or review area | Verification priority |
|---|---|---|
| Gmail | Inbox retrieval, search, thread access, attachment downloads, and pagination | Confirm bounded result counts, download sizes, and provider error handling |
| Google Drive | File search, folder listing, metadata retrieval, and pagination | Confirm server-side result bounds and termination of multi-page retrieval |
| Google Calendar | The inspected event-list declaration uses a default max_results of 10 without an explicit upper bound in that declaration |
Check additional validation, downstream parameters, and infrastructure restrictions |
| Jira | Issue search, project listing, pagination, and dependency timeouts | Confirm broad searches remain bounded and provider pagination terminates |
| Slack | Rate-limit metadata is declared for message sending; channel-history retrieval has a default message limit | Verify enforcement, route-level limits, and handling of provider throttling |
| Microsoft Teams | Rate-limit metadata is declared for selected message retrieval and sending operations | Verify enforcement across entry points and Microsoft Graph throttling behavior |
Declarations do not prove enforcement
Plugin metadata may describe a limit without applying it. A provider may impose its own quota even when the application has no corresponding limiter. Record these as separate controls and verify both independently.
4.1 Provider throttling and retries¶
Provider APIs can impose different quotas and communicate throttling through different response codes, headers, or retry instructions.
The integration layer should:
- Recognize documented throttling responses.
- Respect provider-specific retry guidance where applicable.
- Apply bounded retry counts and elapsed-time budgets.
- Use backoff and jitter where appropriate.
- Avoid retrying non-idempotent operations automatically unless the operation has an explicit safety design.
- Preserve useful diagnostics without logging credentials, access tokens, or sensitive request contents.
Do not assume every provider uses the same response headers or retry semantics.
5. Recommended Enforcement Policy¶
The following table describes a policy to validate and implement where appropriate. It is not an inventory of confirmed production controls.
| Control | Recommended behavior | Verification method |
|---|---|---|
| Request throttling | Define scope, threshold, and time window | Send requests above the threshold and inspect responses |
| Input validation | Reject invalid and out-of-range values | Test missing, malformed, negative, zero, and excessive values |
| Result bounds | Enforce maximum page sizes and aggregate work limits | Request oversized pages and follow multiple-page sequences |
| Timeouts | Set finite connection and read/operation timeouts | Simulate slow or unresponsive dependencies |
| Retries | Bound attempts and total elapsed time | Simulate transient errors and repeated throttling |
| Concurrency | Bound simultaneous expensive operations where necessary | Run controlled concurrent requests |
| Error responses | Return appropriate status codes without exposing secrets | Inspect response bodies and application logs |
| Observability | Record limit events and dependency failures safely | Verify structured logs and operational metrics |
5.1 Rate-limit response semantics¶
For HTTP APIs, use status codes according to the failure condition and the application's established error contract.
| Condition | Typical response | Notes |
|---|---|---|
| Request rate exceeded | 429 Too Many Requests |
Include retry guidance when it can be determined reliably |
| Invalid request parameters | 422 Unprocessable Content or the established validation response |
Follow the API's actual validation contract |
| Request body too large | 413 Content Too Large |
Enforce the limit at an appropriate server or application boundary |
| Upstream timeout | 504 Gateway Timeout where applicable |
Map the failure according to the gateway's documented behavior |
| Upstream service unavailable | 502 Bad Gateway or 503 Service Unavailable, as appropriate |
Avoid exposing internal provider details |
These are recommended response semantics, not confirmation that every listed response is currently returned by WhiteLotusAI.
6. Configuration and Testing Examples¶
The following examples are reference patterns. They are not drop-in production configuration and must be adapted to the actual middleware, HTTP client, and provider implementation.
Use explicit constraints on caller-controlled numeric parameters.
from fastapi import Query
async def search_items(
limit: int = Query(default=10, ge=1, le=100),
):
# Pass the validated limit to the downstream query.
...
Verify: the actual route uses the constraint and downstream code cannot silently replace it with an unbounded value.
Configure finite timeouts for external HTTP requests.
import httpx
timeout = httpx.Timeout(
10.0,
connect=3.0,
)
async with httpx.AsyncClient(timeout=timeout) as client:
response = await client.get(provider_url)
response.raise_for_status()
Verify: the selected values fit the provider operation, retries are included in the overall latency budget, and all relevant client paths use equivalent safeguards.
Test both sides of the configured threshold using the actual limiter and its intended scope.
def test_rate_limit_policy(client):
# Replace with the real route, authentication,
# configured threshold, and expected response.
first = client.get("/api/example")
assert first.status_code == 200
Verify: this illustrative test does not establish a rate limit by itself. Add tests for requests exceeding the configured threshold, reset behavior, and isolation between users or clients.
Example configuration is not evidence
Do not copy sample thresholds into production without load testing, capacity analysis, and an explicit product requirement. Document the real configuration and the environment in which it was verified.
7. Verification Checklist¶
Use this checklist during source reviews, releases, and security testing.
Application and gateway¶
- Identify request-throttling middleware and configuration.
- Determine whether limits are per user, IP, client, tenant, or shared instance.
- Verify limiter behavior across multiple workers or replicas.
- Confirm maximum request-body size.
- Inspect endpoint parameters for defaults, minimums, and maximums.
- Confirm errors use the established response format.
Integrations and dependencies¶
- Verify external connection and read timeouts.
- Inspect pagination loops for termination and bounded aggregate work.
- Verify attachment and file-download size controls where applicable.
- Test provider throttling and retry behavior.
- Confirm retry budgets and backoff behavior.
- Ensure non-idempotent operations are not retried unsafely.
- Confirm credentials and sensitive payloads are excluded from logs.
Runtime and release evidence¶
- Test malformed, negative, zero, and excessive limit values.
- Exercise slow dependencies and upstream failures.
- Test concurrent requests against expensive endpoints.
- Verify rejected requests do not trigger unintended external side effects.
- Record the source revision, environment, test date, and outcome.
- Update this page when implementation or deployment behavior changes.
8. Verification and Reporting¶
Use consistent classifications to distinguish implementation evidence from runtime evidence.
| Classification | Meaning |
|---|---|
| Source verified | The enforcing code or configuration has been identified in a specific source revision. |
| Runtime verified | Controlled tests demonstrate the expected behavior in a recorded environment. |
| Provider-defined | The limit originates from an external provider's policy or quota. |
| Not verified | Available evidence does not establish the limit or its enforcement. |
| Not applicable | The control does not apply to the component under review. |
A source-verified control is not automatically runtime-verified. A runtime test is also scoped to the tested version, configuration, and environment.
For each confirmed limit, record the following evidence:
| Evidence field | What to record |
|---|---|
| Component or endpoint | Exact service, route, or integration operation |
| Limit and scope | Threshold, unit, time window, and affected identity or resource |
| Enforcement point | Middleware, validation, client, provider, or infrastructure |
| Source revision | Commit or release identifier |
| Test environment | Deployment and relevant configuration |
| Test result | Expected behavior, observed behavior, and failure cases |
| Review date | Date of the latest successful verification |
9. Operational Guidance¶
When a limit is exceeded or a dependency becomes throttled:
- Identify whether the restriction originates in WhiteLotusAI, its infrastructure, or the external provider.
- Check the affected endpoint, integration, and configured request parameters.
- Inspect sanitized logs and metrics for repeated requests, timeout patterns, and retry amplification.
- Verify that retries remain within the configured attempt and elapsed-time budgets.
- Adjust limits only after evaluating service capacity, provider quotas, and user impact.
- Document the change and repeat the relevant verification tests.
Operational principle
Prefer predictable rejection and bounded work over allowing requests to consume resources indefinitely. Limits should be explicit, observable, testable, and appropriate to the operation they protect.
10. Maintenance¶
Review this document whenever any of the following changes:
- API routes, request schemas, or result-limit parameters.
- Rate-limit middleware or shared infrastructure.
- Integration clients, provider quotas, or pagination logic.
- Timeout, retry, or concurrency configuration.
- Deployment topology, worker counts, or resource limits.
Keep claims aligned with the current implementation. Do not invent numerical thresholds or describe unverified safeguards as enforced.
Related documentation: API Overview · API Endpoints · API Authentication · API Error Handling
-
Verification is scoped to the source revision, environment, and test conditions recorded in the evidence. Provider policies and deployment configuration can change independently of application code. ↩