- Developers
- Rate limits
Rate limits
The Ferry API throttles request frequency by real client IP address to protect platform stability while preventing any single noisy caller from exhausting shared capacity. This page documents the global rate limit, per-booking isolation on ticket confirmation, optional per-API-key limits, response headers, and other technical ceilings.
Global limits
Section titled “Global limits”Ferry enforces a default rate-limiting policy across public and partner API routes: 5,000 requests per 10 seconds (500 req/s), counted per client IP address per route and per API replica.
On Production, where 2 API replicas sit behind round-robin load balancing, the effective cluster ceiling per client IP and route is roughly 2×. This ceiling blocks runaway loops and abuse from a single source while preserving generous headroom for multi-user OTAs and BFF proxies.
The diagram below traces a request through Ferry’s throttling layers and each branch’s response:
flowchart TB CALL["A call from your system"] KEY{"Per-API-key limit configured?<br/>10 to 10,000 req per minute"} IP{"Global layer — per IP per route<br/>5,000 calls per 10 seconds"} OVER{"Ticket confirmation step?<br/>5 calls / 60s per IP + bookingId"} LOCK{"Per-booking issuance lock<br/>held up to 600 seconds"} SOFT{"Per-bookingId soft limit<br/>5 attempts per 60 seconds"} OK["Ferry processes normally"] E429["HTTP 429 with Retry-After<br/>wait then retry"] LOCKED["Business error 120100<br/>wait then poll booking status"] SOFTED["Business error 120140<br/>wait out 60s window"]
CALL --> KEY KEY -->|"over key limit"| E429 KEY -->|"within limit or unset"| IP IP -->|"over IP route cap"| E429 IP -->|"within cap"| OVER OVER -->|"not confirmation step"| OK OVER -->|"over 5 calls / 60s for booking"| E429 OVER -->|"within cap"| LOCK LOCK -->|"issuance already in flight"| LOCKED LOCK -->|"booking unlocked"| SOFT SOFT -->|"over 5 attempts / 60s cluster-wide"| SOFTED SOFT -->|"within cap"| OKBehavior and headers when throttled
Section titled “Behavior and headers when throttled”Responses evaluated by the IP/route throttler include X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset. When a caller exceeds the allowance, Ferry returns HTTP 429 (Too Many Requests) accompanied by Retry-After (in seconds).
Two operational notes:
- Do not match error body text: Parse the HTTP 429 status code and
Retry-Afterheader rather than matching framework strings inside the response body. - Ferry does not page on 429 responses: Server-side error alerting fires only on 5xx responses. Tracking 429 rates is the integrating partner’s responsibility.
Recommended retry strategy: honour Retry-After (seconds) when present, falling back to randomized exponential backoff (starting at 1 second, doubling per attempt, capped at 30 seconds, up to 5 retries).
Per-API-key rate limits
Section titled “Per-API-key rate limits”Alongside global IP limits, agency administrators can set rate_limit_per_minute on individual keys under Settings → API Keys (10 to 10,000 requests/minute). Each key uses an independent fixed 1-minute counter regardless of source IP.
| Key configuration | Response headers | When exceeded |
|---|---|---|
| No per-key limit | X-RateLimit-* from the IP layer only | Only per-IP/route limits apply |
| Per-key limit set | Adds RateLimit-Limit, RateLimit-Remaining, RateLimit-Reset on every 2xx response | HTTP 429, error ApiKeyRateLimited, RateLimit-Remaining: 0, and Retry-After (seconds) |
Notes:
- Per-key limits supplement rather than replace global IP limits; both apply simultaneously.
- Fixed 1-minute windows permit up to 2× burst across a minute boundary (end of minute N plus start of minute N+1).
- If Ferry’s Redis cluster suffers an outage, per-key rate limiting fails open and logs internally without blocking live requests.
- Daily throttled counts appear in the key detail drawer on the Dashboard (7-day usage chart).
Per-group exceptions
Section titled “Per-group exceptions”Most routes inherit the global 5,000 req / 10s per-IP policy. Specific route groups override the key or window:
| Call group | Limit applied | Counting key | Practical meaning |
|---|---|---|---|
| Platform default | 5,000 calls / 10 seconds | client IP per route/replica | Applies to lookups, booking creation, general operations (~500 req/s) |
Ticket confirmation (confirmToIssue) | 5 calls / 60 seconds | client IP + bookingId | Stops retry storms on one failing booking while leaving other bookings untouched |
| Public booking lookup | 60 calls / 60 seconds | client IP | Protects public end-customer booking lookup pages |
| Real-time SSE stream | Exempt | Not applicable | Reserved for web JWT sessions; closed to API keys |
Two complementary 5-per-60-seconds caps on ticket confirmation
Section titled “Two complementary 5-per-60-seconds caps on ticket confirmation”POST /api/v1/bookings/confirmToIssue/{id} combines two per-booking 5-attempts-per-60-seconds safeguards:
| Mechanism | Counting basis | Response when exceeded |
|---|---|---|
| HTTP throttler cap | client IP + bookingId (per replica) | HTTP 429 with X-RateLimit-* and Retry-After |
| Service soft cooldown | bookingId in Redis across all replicas | HTTP 422 with business code 120140 (not 429) |
Because both mechanisms key on bookingId, a single failing booking stops after 5 attempts and waits 60 seconds, while every other booking from the same OTA keeps its own independent 5/60s budget.
Retry rules:
- On HTTP 429: Wait
Retry-Afterseconds, then poll booking status before retrying. - On HTTP 422 (
120140or120100): PollGET /bookings/{id}after 60 seconds; immediate retries simply repeat the same business error.
Other limits you will run into
Section titled “Other limits you will run into”Beyond request rate limits, account for these structural ceilings:
| Limit | Ceiling | Behavior when exceeded |
|---|---|---|
| Inbound request body | Maximum 1 MB | Rejected immediately at the HTTP perimeter |
| Page size in pagination | Maximum 50 (100 on select HTML/route endpoints) | Silently clamped to the ceiling without throwing an error |
| Booking issuance lock | Held for 600 seconds | Concurrent confirmation returns HTTP 422 code 120100 |
| Booking payment lock | Held for 180 seconds, independent of issuance lock | Concurrent payment returns HTTP 422 code 120100 |
| Email verification OTP | 5 attempts / 15 minutes per email | Sixth attempt onward is rejected |
| Outbound webhook timeout | 2,000 milliseconds per attempt | Exceeding 2s triggers retry (30s, 5m, 30m); dropped after 4 total attempts |
Two critical reminders:
- Silent pagination clamping: Requesting 200 items and receiving 50 is expected behavior; always follow
next_cursoruntil empty rather than assuming fewer records mean end-of-list. - Webhook 2-second deadline: Acknowledge with 2xx after enqueueing; slow synchronous receivers cause duplicate retries and eventual drops after 4 attempts.
What to do when you are throttled
Section titled “What to do when you are throttled”Follow these five steps in order:
- Honour
Retry-Afterand reduce concurrency: Spawning extra worker threads while throttled saturates the counter faster and extends lockouts. - Add random jitter to backoff delays: Spread retry timestamps so concurrent workers do not synchronize into retry waves.
- Never hammer
confirmToIssueon a slow booking: Switch to pollingGET /bookings/{id}instead of repeatingconfirmToIssue. - Log
x-request-idand rate-limit headers: Record timestamps,x-request-id,X-RateLimit-*/RateLimit-*, and egress IP on every 429 for fast diagnosis. - Coordinate with Ferry on shared NAT gateways: If multiple high-volume workloads must egress through a single shared NAT IP and approach 5,000 req / 10s on one route, contact Ferry operations.
Common misconceptions
Section titled “Common misconceptions”| Misconception | Reality | Consequence |
|---|---|---|
| Default quotas are isolated per API key | Default limit runs per client IP per route; per-key limits are opt-in | Workloads behind one NAT share the per-route IP bucket |
The 5/60s cap on confirmToIssue throttles an entire OTA | It is keyed by client IP + bookingId, not IP alone | Building overly serialized single-threaded issuance queues unnecessarily |
| Every rate limit returns HTTP 429 | Cluster-wide per-booking cooldown returns HTTP 422 code 120140 | Retry logic ignores 120140 or retries immediately |
| Ferry alerts you when your client hits 429 | Ferry does not page on 429 responses | Throttling persists unnoticed without client-side monitoring |
| Adding worker threads recovers throughput faster | Extra threads exhaust the IP bucket faster | Prolonged 429 lockouts |
| Receiving 50 items when asking for 200 is a bug | Page sizes clamp silently at 50–100 items | Truncated data syncs when cursor pagination is skipped |
| Late webhooks mean Ferry dispatched slowly | Receiver responses over 2s trigger retries | Fixing the wrong layer while events retry and eventually drop |
Where to look in Scalar
Section titled “Where to look in Scalar”Dynamic rate limits operate in runtime middleware rather than static OpenAPI schemas on https://api.ferry.vn/docs:
| Inspection target | Group in API reference |
|---|---|
Ticket issuance confirmation (5 calls / 60s per IP + bookingId) | Bookings |
| Write endpoints subject to the 1 MB payload ceiling | Bookings, Transactions |
| Read endpoints governed by the 5,000 calls / 10s per-IP policy | Voyages, Disruptions, Organizations, Customers |
Read next
Section titled “Read next”| Page | When to read |
|---|---|
| Errors and how to handle them | Parse HTTP 429 alongside business codes 120100 and 120140 |
| Authentication with an API key | Configure optional rate_limit_per_minute per API key |
| General conventions | Review cursor pagination and silent clamping rules |
| The booking flow | Design resilient confirmation and polling loops |
| Ticket issuance and order legs | Understand locks and cooldowns during ticket issuance |
| Webhooks | Build receivers answering well under 2,000 ms |
| Before you go live | Include 429 and header monitoring in launch readiness checks |
Open questions
Section titled “Open questions”- Contractual throughput SLA: The default 5,000 requests per 10 seconds per route/replica is a technical safeguard baseline rather than a contractual SLA; Ferry may tune thresholds according to cluster load.