# Subscribe to events Webhooks let you react to changes in Gallantree data without polling. Register a subscription, and the platform will `POST` a signed event to your endpoint whenever one of the events you're interested in occurs. ## Prerequisites - A registered [developer app](../../getting-started/register-an-app.md) with the `webhooks:manage` scope. - An **HTTPS endpoint** you control. HTTP is rejected — the platform will not deliver over an insecure transport. - A shared **signing secret** you can retrieve from the portal after creating the subscription. You'll use it to verify signatures on every delivery. ## Events you can subscribe to ### Delivered today | Event | When it fires | |-------|---------------| | `loan.created` | A loan is created through `POST /api/v1/loans` (or the equivalent handover ingest). Re-sending a payload that updates an existing loan in place does **not** fire it. Loans created by hand inside the platform do not fire it. | | `loan.assessment_completed` | The automatic credit assessment that runs when a loan is ingested through `POST /api/v1/loans` produces a result. Fires once, when the loan is created; re-sending the same loan doesn't run the assessment again. | | `loan.status_changed` | A loan's status is changed through the platform's loan workflow (for example, a credit decision). Automated servicing transitions, such as arrears rolls, do **not** fire it yet. Re-read the loan if you need to reconcile. | | `organisation.kyb_completed` | A KYB verification for an organisation is completed by a reviewer. Fires for any final result; check `data.result`. | ### Accepted but not yet delivered You can subscribe to these events today, and the platform accepts them on a subscription, but **nothing sends them yet**. Don't build a flow that waits on them. They will be announced in the [changelog](../../changelog/README.md) when they start firing. | Event | Intended meaning | |-------|------------------| | `loan.updated` | Fields on an existing loan change | | `document.generated` | A document (loan doc, credit memo, statement) is generated | | `collateral.valuation_updated` | A collateral valuation is updated | | `coverage_test.breach` | A capital-program coverage test breaches its threshold | New events are added over time; design your handler to log-and-ignore unknown `X-Gallantree-Event` values. ## Create a subscription From the portal, open your app → **Webhooks** → **New subscription**. Provide: - **URL** — the HTTPS endpoint that will receive deliveries. It must be **publicly reachable**: the hostname is resolved when you register it, and every address it returns has to be routable on the public internet. Private ranges, loopback, and link-local addresses are refused, whether you give them as a hostname or as a literal address. Credentials embedded in the URL (`https://user:pass@…`) are refused too — authenticate the delivery with the signature instead. The same check runs again immediately before **every** delivery, so a hostname that stops resolving publicly after registration stops receiving deliveries: the subscription is paused rather than retried. If you point a webhook at a host that is only reachable inside your own network, deliveries will not arrive — terminate them on a public endpoint and forward inward from there. - **Events** — one or more event types (comma-separated in the API; multi-select in the portal). - **(Optional) Encryption fingerprint** — for the Enterprise tier, you can supply a public key so the platform encrypts payloads before signing them. Skip this for standard use. Each app can have up to **10 active subscriptions**. ## The delivery payload Every delivery is a `POST` with `Content-Type: application/json`. The body is a compact JSON object with three top-level fields: ```json { "event": "loan.created", "timestamp": "2026-08-15T04:32:11.482Z", "data": { "loanId": "65f3a8b1d5c9e4f2a1b3c4d5", "externalLoanId": "loan-001", "sourceSystem": "my-integration" } } ``` - **`event`** is the event type — the same value you'll find in the `X-Gallantree-Event` header. - **`timestamp`** is when the platform first prepared the event (ISO 8601, UTC). Also mirrored in `X-Gallantree-Timestamp`. **Retries carry the original timestamp**, so a retry can arrive hours after it. See [Verify signatures](verify-signature.md). - **`data`** is the event-specific payload described below. It carries identifiers, not the full resource: fetch the resource from the API for its current state. ### `data` by event | Event | `data` fields | |-------|---------------| | `loan.created` | `loanId` — the platform loan id. `externalLoanId` — the `loan.externalId` you sent. `sourceSystem` — the source the loan was ingested under. | | `loan.assessment_completed` | `loanId`, `externalLoanId`, `score` (number), `scoreBand`, `riskGrade`. | | `loan.status_changed` | `loanId`, `previousStatus`, `newStatus`, `mainStatus` (see the [status lifecycle](../resources/loans/README.md#status-lifecycle)). | | `organisation.kyb_completed` | `organisationId`, `kybId`, `result` (`verified`, `rejected` or `info_required`), `completedAt` (ISO 8601). | Test deliveries carry `{ "test": true }` as `data`, whatever event you choose. Headers on every delivery: ``` Content-Type: application/json X-Gallantree-Signature: X-Gallantree-Event: loan.created X-Gallantree-Delivery: X-Gallantree-Timestamp: 2026-08-15T04:32:11.482Z ``` Test deliveries (from the portal's **Send test** button) additionally carry `X-Gallantree-Test: true`. ## Responding to a delivery - **Return `2xx` quickly.** Any `2xx` status marks the delivery as successful. Anything else marks it failed and triggers the retry schedule (see [Delivery and retries](delivery-and-retries.md)). - **Respond within 30 seconds.** The platform gives up on a delivery after 30 seconds and treats it as failed. Do your actual work asynchronously — enqueue the payload and `200` immediately. - **Deduplicate on a hash of the raw body.** The platform may retry a delivery, so your receiver will sometimes receive the same event twice. A retry sends the same body byte-for-byte (and so the same signature) and the same `X-Gallantree-Delivery` value. The body hash is preferred because, unlike the header, the body is signed. See [Delivery and retries](delivery-and-retries.md#duplicate-deliveries). ## Runnable example — subscription creation Use the portal for real subscriptions; the raw HTTP shape is shown here for completeness: ```bash curl -sS -X POST https://developers.gallantreecapital.com/api/v1/webhooks \ -H "x-api-key: $GALLANTREE_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "url": "https://myapp.example.com/webhooks/gallantree", "events": ["loan.created", "loan.status_changed"] }' ``` The response includes a `secret` field — the signing secret. Copy it into your secret store and use it in [Verify signatures](verify-signature.md).