# API versioning The version is in the URL. Not in an `Accept` header, not in a query parameter, not implied by the auth flow. When you write `/api/v1/…`, you're calling v1 — permanently. ## URL structure ``` https://developers.gallantreecapital.com/api/v1/[/] ``` - **`v1`** is the current stable version. Everything under `/api/v1/*` is the public developer surface. - **``** is a plural noun. - **``** — for detail routes — is the resource's `id` field (a 24-character hex string). Anything **outside** `/api/v1/*` is internal to the platform and may change at any time without notice. Do not build against `/api/*` routes that aren't inside `/api/v1/*`. ## Version compatibility promise Within a version (`v1`, `v2`, …): - **Additive changes are allowed without notice.** New resources, new response fields, new optional request parameters, new webhook event types, new error codes. Design your client to ignore fields it doesn't recognise. - **Breaking changes require a new version.** Removing a field, changing a type, changing the meaning of a value, tightening a validation rule — any of these force a new URL prefix (`v2`). - **Deprecations are announced.** Endpoints that will be removed in the next version get a `Deprecation` header pointing at the successor. You'll have at least six months of warning before an endpoint disappears. ## Deprecation header When a v1 endpoint is being retired in a future version, its response carries: ``` Deprecation: true Sunset: 2027-01-15T00:00:00Z Link: ; rel="successor-version" ``` Watch for these headers in your integration's logs — the `Sunset` date is when the endpoint is removed, not when the deprecation was announced. ## Pagination Every list endpoint uses the same query-parameter shape: | Parameter | Type | Default | Notes | |-----------|------|---------|-------| | `page` | integer | `1` | 1-indexed | | `limit` | integer | `20` | Min `1`, max `100`. Values outside that range return `400`. | Results are returned newest first, by creation time. There is no sort parameter, and unrecognised query parameters (for example `sort`) are **silently ignored**, not rejected. Don't rely on result order between pages for anything that changes while you page. ### Filtering The list endpoints for records you can create (`/loans`, `/organisations`, `/collaterals`, `/capital-programs`, `/products`) also accept: | Parameter | Type | Notes | |-----------|------|-------| | `externalId` | string | Only the record with this `externalId`: your own identifier, as sent when you created it. Every record in these responses carries an `externalId` field (`null` for records created inside the platform). | | `updatedSince` | ISO 8601 date-time | Only records updated at or after this time. Use it to reconcile with your system after downtime, alongside webhooks. | `/loans` also accepts: | Parameter | Type | Notes | |-----------|------|-------| | `status` | comma-separated list | Loans in any of these statuses, e.g. `status=current,arrears30`. See [Loans → Status lifecycle](resources/loans/README.md#status-lifecycle). | | `mainStatus` | comma-separated list | Loans in any of these main statuses: `pending`, `active`, `closed`, `withdrawn` and so on. | Filters combine with AND, and only ever narrow results to your own lender's records. An unrecognised `status` or `mainStatus` value, or an `updatedSince` that isn't a date, returns `400` rather than an empty list. ```bash # Find your loan by your own id curl -sS -H "x-api-key: $KEY" "https://developers.gallantreecapital.com/api/v1/loans?externalId=loan-001" # Everything that changed since your last sync, in arrears or not curl -sS -H "x-api-key: $KEY" "https://developers.gallantreecapital.com/api/v1/loans?updatedSince=2026-11-14T00:00:00Z&limit=100" ``` Every list response wraps the array in a `data` field and includes a `pagination` object: ```json { "data": [ ... ], "pagination": { "page": 2, "limit": 20, "total": 132, "totalPages": 7 } } ``` Iterate by incrementing `page` until `page > totalPages`, or track `total` yourself. ## Content negotiation - **Request:** send `Accept: application/json`. Anything else is ignored. - **Response:** `Content-Type: application/json; charset=utf-8`. All timestamps are ISO 8601 in UTC. ## Runnable example — walk every page ```bash page=1 while : ; do body=$(curl -sS "https://developers.gallantreecapital.com/api/v1/loans?page=$page&limit=100" \ -H "x-api-key: $GALLANTREE_API_KEY") echo "$body" | jq -r '.data[].id' totalPages=$(echo "$body" | jq -r '.pagination.totalPages') if [ "$page" -ge "$totalPages" ]; then break; fi page=$((page + 1)) done ```