Authentication with API keys
Every request to /api/v1/* carries an API key in the x-api-key header. This guide covers what a key is, how the API validates one, and the error responses you can expect.
For OAuth 2.0 client credentials (used for server-to-server flows where an access token is preferable to a long-lived key), see OAuth 2.0 client credentials.
Request format
GET /api/v1/loans HTTP/1.1
Host: developers.gallantreecapital.com
x-api-key: gt_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Accept: application/json
The key goes in the x-api-key header — never in a query string (it would leak into server access logs) and never in the request body.
What the API validates
On every request, the auth middleware runs the following checks in order:
- Key present. No
x-api-keyheader →401with"API key is required". - Key matches an active app. The key is compared against every unrevoked key on every active app. No match →
401with"The API key you provided is not valid."(deliberately generic — the response never tells you whether the key existed, was expired, or belonged to another environment). - Key not expired. Keys expire after 90 days by default. An expired key →
401with"API key has expired". - App still active. Suspended or deleted apps →
403with"Application is not active". - IP allowlist matches (if configured). If the app or key has a CIDR allowlist and your source IP isn't in it →
403with"IP address not permitted". - Required scopes present (per route). If the route needs a scope your app doesn't have →
403with"Insufficient scopes".
If every check passes, the request continues to the handler.
The gt_ prefix
Every developer key starts with gt_ followed by a random suffix. The first 12 characters of the key — its prefix — is safe to display in dashboards, logs, and error triage tools. The rest of the key is a secret and must be treated like a password.
Storage is one-way: Gallantree stores a bcrypt hash of the full key, not the key itself. If you lose a key, the portal cannot show it again — generate a new one and revoke the old.
Scopes
Apps declare their required data as scopes, following the pattern <resource>:<operation>. These are the scopes the v1 routes check today:
| Scope | What it allows |
|---|---|
loans:read |
List and read individual loans |
loans:write |
Create loans (POST /loans) |
organisations:read |
List and read organisations, and list individuals |
organisations:write |
Create organisations, and create individuals |
capital-programs:read |
List and read capital programs |
products:read |
List and read products |
collaterals:read |
List and read collaterals |
base-rates:read |
List base rates |
webhooks:manage |
Create, update, delete and test webhook subscriptions, and read their delivery logs |
documents:write |
Upload documents against a loan |
There are no separate individuals:* scopes: individuals are covered by the organisation scopes. The portal may also offer scopes such as loans:delete, documents:read, investments:read, treasury:read and portfolio:read. They are reserved for upcoming endpoints and grant nothing today.
A request that hits a route requiring a scope your app doesn't have returns 403 — regardless of whether the key itself is valid. Extending an app's scopes never invalidates its keys; it just widens what they're allowed to do.
Runnable example
curl -sS https://developers.gallantreecapital.com/api/v1/loans \
-H "x-api-key: $GALLANTREE_API_KEY" \
-H "Accept: application/json"
For write endpoints you'll also need an Idempotency-Key header — see Idempotency.