# Create a loan Loan creation uses the **handover payload** — a bundle that carries the loan **plus** the organisations it references (the borrower, servicer and lender of record, and any others such as a valuer) and its collateral, in a single atomic request. You don't need to create organisations first. Guarantors aren't carried yet. A broker (`broker` or `brokerOrganisationExternalId`), corporate trustees (`corporateTrustee` or `corporateTrusteeExternalIds`), `sponsors` and loan-level `fees` can't be stored on a loan yet, so sending any of them is rejected with a `400` naming the field. Fees belong on the [product](../products/README.md) or [capital program](../capital-programs/README.md). ``` POST /api/v1/loans x-api-key: Idempotency-Key: Content-Type: application/json { "source": "my-integration", # optional label "organisations": [ … ], # required, min 1 "collaterals": [ … ], # optional "loan": { … } # required } ``` **Required scope:** `loans:write`. **Idempotency-Key header:** required. See [Idempotency](../../idempotency.md). **Import order:** the platform inserts `organisations` first, then `collaterals`, then the capital program and product, then the `loan`. If anything fails midway, nothing is committed. The full payload schema (every field on every entity) is at [`HandoverPayload` in the API reference](../../../reference/openapi.md). What follows is the minimal shape that the platform accepts. ## What the platform requires Beyond the schema's required fields, the import itself checks for: | Requirement | Detail | |---|---| | `loan.borrowingEntityExternalId` | Must match an `externalId` in `organisations`. | | `loan.servicerExternalId` and `loan.lenderOfRecordExternalId` | Both must match an `externalId` in `organisations`. One organisation can fill both. (The nested forms `loan.servicer.externalId` and `loan.lenderOfRecord.externalId` also work.) | | A capital program and a product | For each, **either** an inline block (`loan.capitalProgram` / `loan.product`, each with at least `externalId` and `name`; `capitalProgram.domicile` is required) **or** the id of an existing one (`loan.capitalProgramId` / `loan.productId`). Not both. See [Capital program and product](create-program-and-product.md). | | A deal lead | `loan.dealLead.email` of a user on your lender's platform. If omitted, the environment's default integration user is used. If neither resolves, the request is rejected. Ask your Gallantree account manager which applies to your environment. | | `domicile` on every organisation | One of `australia`, `newZealand`, `singapore`, `unitedStates`, `caymanIslands`. | | Recognised enum values | See [Enum values must be recognised](#enum-values-must-be-recognised). | ## Minimal handover payload ```json { "source": "my-integration", "organisations": [ { "externalId": "borrower-001", "organisationName": "Test Borrower Holdings Pty Ltd", "organisationStructure": "privateCompany", "domicile": "australia", "roles": ["borrower"], "registrations": { "abn": "12345678901" } }, { "externalId": "lender-001", "organisationName": "Sandbox Lender Alpha", "domicile": "australia" } ], "collaterals": [ { "externalId": "collateral-001", "collateralType": "property", "address": "1 Sample St, Sydney NSW 2000", "values": { "current": 2500000 } } ], "loan": { "externalId": "loan-001", "category": "cre", "borrowingEntityExternalId": "borrower-001", "servicerExternalId": "lender-001", "lenderOfRecordExternalId": "lender-001", "collateralExternalIds": ["collateral-001"], "capitalProgram": { "externalId": "program-001", "name": "Sandbox CRE Program", "domicile": "australia" }, "product": { "externalId": "product-001", "name": "CRE Senior 5yr" }, "principalAmount": 1500000, "loanTerm": 60 } } ``` Every entity carries an **`externalId`** — your stable identifier from the source system. `externalId`s are scoped to your lender: another lender using the same value never touches your records, and you never touch theirs. Everything the request creates (organisations, collaterals, the capital program, the product and the loan) belongs to your lender, so you can read it straight back with the v1 read endpoints. ## Enum values must be recognised Enum-like fields (organisation `roles`, `organisationStructure`, `organisationIndustry`, `collateralType`, `property.type`, loan `category`, base rates, and the capital program and product classification fields) are matched against the platform's values, ignoring case, spaces, hyphens and underscores, so `privateCompany`, `PRIVATE_COMPANY` and `private company` are all accepted. **An unrecognised value is rejected** with a `400` that names the field and lists the accepted values (see [Errors](#errors)). Leaving an optional field out still applies its default. The `servicer` role is not applied from `roles`: link the servicer through `loan.servicerExternalId` instead. ## Loan fields you can set Besides the amounts, term and dates in the example, these loan fields are stored when you send them: | Field | Values | |---|---| | `currency` | `aud`, `nzd`, `usd`, `eur`, `sgd` and so on (any case). Defaults to `aud`. | | `loanRank` | `firstLien`, `secondLien`, `thirdLien`, `fourthLien`… | | `purposeOfLoan` | `acquisition`, `refinance`, `construction`, `renovation`… | | `loanExitStrategy` | `preAgreedSale`, `likelySale`, `refinanceToAnotherProduct`, `cashflowFromOperations`… | | `totalCollateralValue` | A number. | | `expectedStartDate` | When the loan is expected to start. `startDate` is accepted as an older name for the same field; send one or the other. Either way it's returned as `expectedStartDate`. | An unrecognised value is rejected with a field error that lists every accepted value. `status` and `mainStatus` are accepted but **not** applied: a new loan always starts in `draft` (main status `pending`). ## Sending the same payload again Re-sending a loan whose `externalId` already exists for your lender **changes nothing**. Nothing is created or updated, the credit assessment doesn't run again, and no webhooks fire. The response is `201` with `loan.created: false` and the existing ids, so a retry after a timeout is safe. Changed field values on the loan or its records are ignored, not applied. Organisations are matched as on the first send: by `externalId`, then by legal name among your organisations, so one named like an organisation you already have resolves to it. The re-send's response has no `assessment`: the assessment is only on the first response, and the [`loan.assessment_completed`](../../webhooks/subscribe.md) webhook is how to receive it if that response was lost. Re-sending is not a way to change a loan. If the payload names an organisation that doesn't exist yet, a collateral that isn't one of the loan's collaterals (even one already on another of your loans), or a different borrower, the request is rejected with `409` and a field error for each one (for example `collaterals[1]` or `loan.borrowingEntityExternalId`), and nothing is written. An update path for existing loans is planned. Organisations, collaterals, capital programs and products are also reused as they are when another loan names their `externalId`: nothing in the new payload overwrites them. Use a fresh `Idempotency-Key` per logical operation; reusing a key returns the stored response without running the import at all. ## Response Successful creation returns `201 Created` with an acknowledgement of what was created (`created: true`) or reused (`created: false`): ```json { "lmsLoanId": "65f3...c4d5", "loan": { "externalId": "loan-001", "created": true }, "organisations": [ { "externalId": "borrower-001", "lmsId": "65f3...c4f2", "created": true } ], "collaterals": [ { "externalId": "collateral-001", "lmsId": "65f3...c503", "created": true } ], "assessment": { "status": "assessed", "score": 72, "scoreBand": "B1", "riskGrade": "moderate", "...": "…" } } ``` `assessment` is the automatic credit assessment, present when it produced a result. Follow up with `GET /api/v1/loans/` to see the full loan. ## Errors | Status | When | |--------|------| | `400` | The payload failed validation, or a required reference is missing (see [What the platform requires](#what-the-platform-requires)). When the problem is with specific fields, the body lists them (see below). | | `409` | An idempotency-key mismatch (same key, different body); an `externalId` already registered by a different integration source; or a re-sent loan that names records it wasn't created with (`errors` lists them). The `message` disambiguates. | | `500` | Server-side ingest failure — the platform logs the specific cause; retry with a **new** idempotency key | Retrying a `500` with the *same* idempotency key returns the same 500 (that's the point of idempotency). To actually re-attempt the write, use a fresh key. See [Idempotency](../../idempotency.md). ### Field errors When the import can tell which fields are wrong, the `400` body lists **every** problem it found, not just the first. Nothing is written. ```json { "message": "Invalid request.", "errors": [ { "field": "organisations[1].roles[0]", "message": "Not a recognised value. Accepted values: arranger, trustee, servicer, corporateTrustee, broker, legalFirm, securityTrustee, collateralManager, valuer, auditor, borrower, noteholder, media, propertyFirm, creditRatingsAgency, researchFirm, vendor." }, { "field": "loan.servicerExternalId", "message": "Does not match the externalId of any organisation in this request." } ] } ``` `field` is a path into the body you sent. A schema failure (a missing required field, a wrong type) is still reported with the `message` alone.