- Developers
- Authentication with an API key
Authentication with an API key
This page explains how to authenticate with the Ferry system using an API key: passing the HTTP header, key structure, resource permission scopes, key lifecycle states (pause, revoke, zero-downtime rotation with grace, expiration), optional per-key rate limits, and how to distinguish authentication error codes.
How to send a key
Section titled “How to send a key”Every request sent to partner-tier endpoints must include the API key in the HTTP request header using standard Bearer format:
Authorization: Bearer <API_KEY>The Ferry system reads only the Authorization header. X-API-Key or any other custom header has no authentication effect.
Key format
Section titled “Key format”A complete API key consists of 3 parts joined by underscores (_):
- System prefix: A prefix string configured by Ferry per environment. Partners do not need to parse or split the prefix; simply send the issued key string verbatim.
- Key identifier: A 24-character hexadecimal string identifying the key record in the system.
- Secret token: A 64-character cryptographically random hexadecimal string. Ferry stores only its SHA-512 hash and compares secrets in constant time.
This documentation never prints a sample key string. Always send the issued key string verbatim without trimming, prepending, or modifying any character.
The diagram below illustrates the authentication, lifecycle validation, rate-limit, and authorization flow for an API request:
sequenceDiagram autonumber participant Partner as Partner System participant Gateway as Ferry API Gateway participant Auth as Key Auth Layer participant Perm as Permission Layer participant Core as Business Layer Partner->>Gateway: Send request with Authorization header Gateway->>Auth: Lookup key, verify hash, check status and expiry alt Missing header, wrong secret, or not found Auth-->>Partner: 401 Unauthorized (Invalid API Key) else Valid secret but revoked, disabled, or expired Auth-->>Partner: 401 with ApiKeyRevoked / ApiKeyDisabled / ApiKeyExpired else Source IP outside allowlist Auth-->>Partner: 403 with ApiKeyIpNotAllowed else Per-key rate limit exceeded Auth-->>Partner: 429 with ApiKeyRateLimited and Retry-After else Key valid Auth->>Perm: Pass organization context and key scopes alt Missing scope or transient authorization outage Perm-->>Partner: 403 (ApiKeyScopeDenied / Access denied) else Authorized Perm->>Core: Execute business logic Core-->>Partner: 200 OK with response payload end endWho creates keys and how
Section titled “Who creates keys and how”Partners cannot create API keys through public API endpoints. Key creation is restricted to agency users holding the admin role on the web Dashboard interface.
Steps to create a key on the Dashboard:
-
An administrator signs in to the agency Dashboard, opens the Settings menu, switches to the API Keys tab, and clicks Add New.

API Keys tab in Dashboard Settings showing the Add New button -
Enter a descriptive name for the key (such as the integrating service name), select scopes, optional expiration date, per-minute rate limit, and IP allowlist if needed, then click Create New.

Create API Key dialog with key name field and Create New action -
A confirmation dialog displays the newly generated key. Click the copy icon to save the full key string into your secret manager.

Dialog displaying the newly created API key with one-time copy warning
For complete Dashboard operational instructions, see API Key Management on Dashboard.
Key lifecycle and characteristics
Section titled “Key lifecycle and characteristics”Each key carries a primary state and several optional constraints:
| State | Meaning | Reversible |
|---|---|---|
active | Operational (subject to expiration, IP allowlist, rate limit, and scope checks) | — |
disabled | Paused; every request returns 401 ApiKeyDisabled | Yes, via Re-enable on Dashboard |
revoked | Revoked; every request returns 401 ApiKeyRevoked | No. Record is retained for audit history |
Key metadata on the Dashboard also exposes a computed effective_status of active, disabled, revoked, or expired (expired when a key is active but past expires_at).
Optional attributes:
- Expiration (
expires_at): Up to 2 years from when it is set; leaving it blank means no expiration. Expired keys return 401ApiKeyExpired. Legacy keys and keys created with only a name have no expiration. - Permission scopes (
scopes): Detailed in the next section. - Per-key rate limit (
rate_limit_per_minute): 10–10,000 requests/minute; leaving it blank applies only the global per-IP rate limits. - IP allowlist (
allowed_ips): Up to 50 IPv4/IPv6/CIDR entries; leaving it blank allows any source IP.
Key revocation is a soft revocation: the record and audit trail remain visible under the Revoked tab on the Dashboard, while the original hash is moved aside and the primary hash overwritten so the key can never authenticate again even across rollbacks. Pausing, re-enabling, and revoking are performed by agency administrators on the Dashboard; invalid state transitions (such as re-enabling an already active key) return HTTP 409.
API key permissions
Section titled “API key permissions”Each API key is bound to a single agency organization and acts on behalf of that organization. Alongside organization-level authorization (deciding which organization a key can access), the key carries resource scopes deciding what kind of work it may perform.
Permission scopes
Section titled “Permission scopes”A key holds a list of scopes formatted as <resource>:read or <resource>:write. Core rules:
writeimpliesreadon the same resource: a key withbookings:writecan also read bookings.*grants full access across all resources, matching legacy key behavior.*cannot be mixed with explicit scopes on the same key.
| Resource | Coverage |
|---|---|
auth | Sign-up, sign-in, OTP verification, social login (supports write only) |
voyages | Voyage schedules, seat counts, boat layouts, ticket price additions, and voyage disruption lookups (/api/v1/disruptions, /api/v1/disruptions/{id}, /api/v1/bookings/{id}/disruptions) |
bookings | Bookings, booking email notifications, orders, ticket cancellation requests |
customers | Customers, companies, leads |
payments | Financial transactions, debt ledgers |
vouchers | Vouchers and voucher applicability checks |
reports | Revenue and operational reports |
organizations | Organization profile, settings, and child organizations |
files | Stored file assets |
By default, required access follows the HTTP method: GET, HEAD, and OPTIONS require read, while other methods require write. Several read-only queries that use POST are explicitly mapped to read: vouchers/check-aplicability, ticket-price-additions/check, organizations/settings/check-slug, and files/getFile/:id. By contrast, organizations/settings/check-smtp-config requires write because it opens an outbound SMTP connection using supplied parameters.
Querying voyage disruption endpoints (/api/v1/disruptions, /api/v1/disruptions/{id}, /api/v1/bookings/{id}/disruptions) requires both the voyages:read scope (or voyages:write / *) on the API key and the view_disruption permission on the organization; missing the organization permission returns 403 Access denied (see Voyage search and remaining seats).
Presets
Section titled “Presets”When creating a key on the Dashboard, you can pick a preset instead of selecting individual scopes:
| Preset | Included scopes |
|---|---|
full | * — full access, matching legacy keys |
read_only | Every readable partner resource (voyages:read, bookings:read, customers:read, payments:read, vouchers:read, reports:read, organizations:read, files:read) |
tenant_website | The 4 partner scopes called with an organization key by a branded booking website: auth:write, voyages:read, vouchers:read, organizations:read. Bookings, payments, customers, and files are called from the browser with the visitor’s session JWT rather than the org key, so this preset omits them |
partner_ota | voyages:read, bookings:write, payments:read |
No restricted preset other than full includes organizations:write.
Widening permissions requires admin authority
Section titled “Widening permissions requires admin authority”Adding scopes (or switching to *), removing IP allowlist entries, raising or removing rate_limit_per_minute, or extending/removing expires_at constitutes permission widening and requires administrator authority equivalent to creating a key. Non-admin users delegated to edit keys can only narrow constraints; widening attempts return 403 ApiKeyWideningForbidden.
Important authorization boundaries and risks:
- Risk of
*: A full-access key can create, modify, and delete child organizations within your agency hierarchy. A leaked*key can be abused to delete sub-agencies. - No access to internal areas: API keys cannot perform Ferry system administration or invoke Dashboard endpoints requiring user session JWTs.
- Missing response fields due to role serialization: API keys belong to the
api-keyserialization group. Responses include only fields explicitly exposed to this group. If a field appears on the Dashboard (such as detailed commission breakdowns) but is absent from an HTTP 200 API response, that field is not exposed toapi-key. This is not a scope error (no 403 is returned); contact Ferry to expose required fields rather than retrying with query parameters.
Per-key rate limits
Section titled “Per-key rate limits”Alongside global per-IP throttling (see Rate limits), each key can configure rate_limit_per_minute between 10 and 10,000. The counter uses a fixed 1-minute window evaluated independently per key.
- Keys without a per-key limit: responses omit
RateLimit-*headers. - Keys with a per-key limit: every successful response includes
RateLimit-Limit,RateLimit-Remaining, andRateLimit-Reset. - When exceeded: HTTP 429 with error code
ApiKeyRateLimited, accompanied byRetry-After(seconds),RateLimit-Limit,RateLimit-Remaining: 0, andRateLimit-Reset. - Fixed windows allow up to 2× burst across a minute boundary (end of one minute plus start of the next). This is an intentional trade-off to keep counting predictable.
- If Ferry’s Redis cluster experiences an outage, per-key rate limiting fails open and logs internally so live partner traffic is not blocked.
Seven-day usage statistics (daily request counts and throttled counts) are visible in the key detail drawer on the Dashboard.
IP allowlist
Section titled “IP allowlist”A key can restrict callers to specific IPv4/IPv6 addresses or CIDR blocks. When allowed_ips is non-empty and the feature is enabled for the environment, requests from unlisted IPs receive 403 ApiKeyIpNotAllowed.
This feature is disabled by default until client IP forwarding is verified for the environment. While disabled, submitting allowed_ips returns 422 ApiKeyIpAllowlistDisabled.
Safe key rotation workflow
Section titled “Safe key rotation workflow”There are two ways to rotate an API key; prefer the first method.
Method 1 — Rotate with grace (zero downtime)
Section titled “Method 1 — Rotate with grace (zero downtime)”The Rotate key action on the Dashboard creates a replacement key inheriting the same name, scopes, IP allowlist, and per-minute rate limit, returning the new key string once. The previous key continues authenticating during the chosen grace window:
| Grace | Behavior |
|---|---|
none | Previous key is revoked immediately; calls using it receive 401 ApiKeyRevoked |
1h, 24h, 7d | Previous key remains valid for that duration, never exceeding its original expires_at |
Procedure:
- An administrator clicks Rotate key with grace
24h(or7dfor slower rollouts) and saves the new key string. - Deploy the new key to environment variables across all backend instances.
- Verify that 100% of live workers and background jobs have switched to the new key.
- Once the grace window elapses, the old key expires automatically with no further action needed.
The new key becomes active before the rotation response returns (permissions are committed synchronously), so deploying it immediately never causes transient 403 errors.
Only active keys can be rotated. Disabled, revoked, expired, or already-rotated keys return 409 — re-enable a paused key first or create a fresh key instead.
Method 2 — Create a new key, then revoke the old key
Section titled “Method 2 — Create a new key, then revoke the old key”- Create a new key (matching scopes and limits) and store the key string.
- Deploy the new key across your backend servers.
- Confirm all traffic has migrated to the new key.
- Click Revoke on the old key in the Dashboard (this action is irreversible).
With this method, the old key stays alive until manually revoked, giving manual cutover control without automatic expiration.
If a key is leaked and active compromise is suspected, prioritize stopping abuse: pause the key immediately (if brief downtime is acceptable) or rotate with grace none, then deploy the replacement key.
Understanding authentication error codes
Section titled “Understanding authentication error codes”Once the secret hash matches, Ferry evaluates checks in strict order: revoked → disabled → expired → IP allowlist → per-key rate limit → resource scope. Whenever the secret itself is wrong, Ferry returns a single generic 401 response, never revealing whether a key ID exists or its current state.
| HTTP Code | Error code (error) | Root cause | Resolution |
|---|---|---|---|
| 401 | (none) — Invalid API Key | Missing header, bad format, unknown key ID, or wrong secret | Check Authorization: Bearer <key> syntax; paste the full key verbatim |
| 401 | ApiKeyRevoked | Key was revoked, or rotation grace window ended | Switch to the rotated replacement key or create a new key |
| 401 | ApiKeyDisabled | Key is currently paused | Ask an agency administrator to re-enable it on the Dashboard |
| 401 | ApiKeyExpired | Current time passed expires_at | Create a new key (expired keys cannot be rotated and return 409) |
| 403 | ApiKeyIpNotAllowed | Source IP is outside allowed_ips | Send requests from an approved egress IP or update the allowlist |
| 429 | ApiKeyRateLimited | Exceeded rate_limit_per_minute | Wait for Retry-After seconds before retrying |
| 403 | ApiKeyScopeDenied | Key lacks required scope; includes required field (e.g. bookings:write) | Add the required scope (admin required) or use an appropriately scoped key |
| 403 | ApiKeyScopeUnmapped | Target route lacks a resource mapping on Ferry | Report to Ferry; this indicates a server-side route declaration issue |
| 403 | Access denied | Organization permission layer denied access or suffered a transient glitch | If sudden on a previously working route, retry once with backoff, then contact Ferry |
Important notes:
- Generic 401 responses on wrong secrets intentionally omit whether the format, key ID, or secret failed.
- 403
Access deniedfrom the organization authorization layer does not distinguish missing organization permissions (such asview_disruption) from transient authorization service glitches. If 403 errors appear suddenly on working endpoints, retry briefly with backoff before concluding permissions changed. - Lifecycle 401 codes (
ApiKeyRevoked,ApiKeyDisabled,ApiKeyExpired) appear only when the secret hash matched; never rely on them to probe keys.
Common misconceptions
Section titled “Common misconceptions”| Misconception | Reality | Correct practice |
|---|---|---|
| Sending the key via custom headers | Ferry reads only the Authorization header | Always send Authorization: Bearer <key> |
| Embedding keys in mobile or browser apps | Keys act on behalf of your agency organization | Keep keys strictly on backend servers |
| Revoking the old key before deploying the new one | Revocation is immediate and breaks live traffic | Use Rotate with grace, or deploy a new key first |
| Assuming every key has full access | Scoped keys (e.g. bookings:read) return 403 on other resources | Inspect required in ApiKeyScopeDenied and choose matching scopes/presets |
| Assuming keys expire automatically by default | Only keys configured with expires_at expire | Set expires_at when policy requires it and monitor effective_status |
| Assuming 403 always means a revoked key | 403 also signals missing scope, unlisted IP, or authorization glitches | Inspect the error code to identify the exact cause |
| Assuming missing response fields mean missing scopes | Certain fields are not serialized for the api-key role group | Contact Ferry to expose required fields for the API key role |
| Assuming revoking a key erases audit logs | Soft revocation disables the key permanently while keeping history in Revoked | Use Pause on the Dashboard if you only want a temporary halt |
Where to look in Scalar
Section titled “Where to look in Scalar”This guide corresponds to the Authorize button in the top bar of the Scalar UI — Ferry VN API portal.
To test endpoints in the Scalar interface:
- Click the Authorize button.
- Paste your API key into the Bearer token input.
- Call a simple read endpoint such as
VoyagesorBookingsto verify that your key authenticates properly.
Read next
Section titled “Read next”| Guide | Recommended next reading |
|---|---|
| Integration surface overview | Review permission boundaries and partner-accessible business groups |
| Rate limits | Global per-IP throttling and optional per-key rate limits |
| Environments | Managing separate keys across the UAT sandbox and Production |
| Webhooks | Standard Webhooks signature verification, deduplication, and retry schedule |
| API Key Management on Dashboard | Step-by-step Dashboard guide for agency administrators |