Skip to content

Rate limits

8 min read

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.

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"| OK

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-After header 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).

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 configurationResponse headersWhen exceeded
No per-key limitX-RateLimit-* from the IP layer onlyOnly per-IP/route limits apply
Per-key limit setAdds RateLimit-Limit, RateLimit-Remaining, RateLimit-Reset on every 2xx responseHTTP 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).

Most routes inherit the global 5,000 req / 10s per-IP policy. Specific route groups override the key or window:

Call groupLimit appliedCounting keyPractical meaning
Platform default5,000 calls / 10 secondsclient IP per route/replicaApplies to lookups, booking creation, general operations (~500 req/s)
Ticket confirmation (confirmToIssue)5 calls / 60 secondsclient IP + bookingIdStops retry storms on one failing booking while leaving other bookings untouched
Public booking lookup60 calls / 60 secondsclient IPProtects public end-customer booking lookup pages
Real-time SSE streamExemptNot applicableReserved 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:

MechanismCounting basisResponse when exceeded
HTTP throttler capclient IP + bookingId (per replica)HTTP 429 with X-RateLimit-* and Retry-After
Service soft cooldownbookingId in Redis across all replicasHTTP 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-After seconds, then poll booking status before retrying.
  • On HTTP 422 (120140 or 120100): Poll GET /bookings/{id} after 60 seconds; immediate retries simply repeat the same business error.

Beyond request rate limits, account for these structural ceilings:

LimitCeilingBehavior when exceeded
Inbound request bodyMaximum 1 MBRejected immediately at the HTTP perimeter
Page size in paginationMaximum 50 (100 on select HTML/route endpoints)Silently clamped to the ceiling without throwing an error
Booking issuance lockHeld for 600 secondsConcurrent confirmation returns HTTP 422 code 120100
Booking payment lockHeld for 180 seconds, independent of issuance lockConcurrent payment returns HTTP 422 code 120100
Email verification OTP5 attempts / 15 minutes per emailSixth attempt onward is rejected
Outbound webhook timeout2,000 milliseconds per attemptExceeding 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_cursor until 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.

Follow these five steps in order:

  1. Honour Retry-After and reduce concurrency: Spawning extra worker threads while throttled saturates the counter faster and extends lockouts.
  2. Add random jitter to backoff delays: Spread retry timestamps so concurrent workers do not synchronize into retry waves.
  3. Never hammer confirmToIssue on a slow booking: Switch to polling GET /bookings/{id} instead of repeating confirmToIssue.
  4. Log x-request-id and rate-limit headers: Record timestamps, x-request-id, X-RateLimit-* / RateLimit-*, and egress IP on every 429 for fast diagnosis.
  5. 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.
MisconceptionRealityConsequence
Default quotas are isolated per API keyDefault limit runs per client IP per route; per-key limits are opt-inWorkloads behind one NAT share the per-route IP bucket
The 5/60s cap on confirmToIssue throttles an entire OTAIt is keyed by client IP + bookingId, not IP aloneBuilding overly serialized single-threaded issuance queues unnecessarily
Every rate limit returns HTTP 429Cluster-wide per-booking cooldown returns HTTP 422 code 120140Retry logic ignores 120140 or retries immediately
Ferry alerts you when your client hits 429Ferry does not page on 429 responsesThrottling persists unnoticed without client-side monitoring
Adding worker threads recovers throughput fasterExtra threads exhaust the IP bucket fasterProlonged 429 lockouts
Receiving 50 items when asking for 200 is a bugPage sizes clamp silently at 50–100 itemsTruncated data syncs when cursor pagination is skipped
Late webhooks mean Ferry dispatched slowlyReceiver responses over 2s trigger retriesFixing the wrong layer while events retry and eventually drop

Dynamic rate limits operate in runtime middleware rather than static OpenAPI schemas on https://api.ferry.vn/docs:

Inspection targetGroup in API reference
Ticket issuance confirmation (5 calls / 60s per IP + bookingId)Bookings
Write endpoints subject to the 1 MB payload ceilingBookings, Transactions
Read endpoints governed by the 5,000 calls / 10s per-IP policyVoyages, Disruptions, Organizations, Customers
PageWhen to read
Errors and how to handle themParse HTTP 429 alongside business codes 120100 and 120140
Authentication with an API keyConfigure optional rate_limit_per_minute per API key
General conventionsReview cursor pagination and silent clamping rules
The booking flowDesign resilient confirmation and polling loops
Ticket issuance and order legsUnderstand locks and cooldowns during ticket issuance
WebhooksBuild receivers answering well under 2,000 ms
Before you go liveInclude 429 and header monitoring in launch readiness checks
  • 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.