Idempotency
Every write endpoint (POST, PUT, DELETE) supports the Idempotency-Key header. This lets you retry safely — a network hiccup, a client timeout, a container restart — without accidentally creating the same resource twice.
The rule
- On the first request with a given key, the API processes the request normally and stores the response — status code, headers, and body — against the key.
- On any subsequent request with the same key, the API returns the stored response verbatim. It does not re-execute the write.
- The response is stored for 24 hours from the first request. After that, the key is forgotten and a new request with the same key is treated as a first request.
What counts as "the same key"
- Same header value (
Idempotency-Key: <value>). - Same route (
POST /api/v1/loans). - Same authenticated app (idempotency records are scoped to an app — two apps can safely use the same key value in isolation).
A key that matches on all three replays the stored response. A key that matches only some of them is treated as a new request.
What about a different body?
If you re-send the same Idempotency-Key with a different request body, the API returns 409 Conflict:
JSON
{ "message": "Idempotency key conflict: the same key was used with a different request body." }
This is a safety measure — it prevents a client bug from silently overwriting a stored response. Fix the client or use a fresh key.
Choosing a key
- Format: a UUID v4 (random). Other UUID versions and non-UUID values are rejected with
400 Idempotency-Key must be a valid UUID. - Scope: one key per logical operation, not one per attempt. If your client generates a fresh key on every retry, you defeat the purpose — the API cannot recognise the retries and each attempt runs afresh.
- Persistence: store the key alongside the operation it identifies. When your client retries, look up the key you already generated and re-use it.
What idempotency does not do
- It does not re-attempt failed writes. If the first request returned
500, replays return500. Use a new key if you want the operation to actually run again. - It does not cover
GETreads. Reads are naturally idempotent; the header is ignored onGETroutes. - It does not cross environments. A key on sandbox and a key on production are entirely separate spaces.
Runnable example
Shell
KEY=$(uuidgen) # uuidgen produces a v4 UUID on macOS and most Linux distributions
# The minimal handover payload from the Loans guide.
cat > loan.json <<'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
}
}
JSON
# First attempt — actually creates the loan
curl -sS -X POST https://developers.gallantreecapital.com/api/v1/loans \
-H "x-api-key: $GALLANTREE_API_KEY" \
-H "Idempotency-Key: $KEY" \
-H "Content-Type: application/json" \
--data-binary @loan.json
# Retry after a client-side timeout — same key, same body: returns the original response, no duplicate
curl -sS -X POST https://developers.gallantreecapital.com/api/v1/loans \
-H "x-api-key: $GALLANTREE_API_KEY" \
-H "Idempotency-Key: $KEY" \
-H "Content-Type: application/json" \
--data-binary @loan.json
See Loans → Create for the full payload.
Was this page helpful?