Overview / Guides / Get started
Sandbox quick-start, the channel flow end to end
One borrower, from your own KYC to the repayment, against the sandbox at https://api.borrou.capital, call by call. It is the flow of a partner embedding Borrou in its own app: you send what your KYC already established, the payout and the collateral's return go to your settlement account at the custodian, the borrower accepts the contract in your app with a one-time code, and you follow the loan by webhook and by the events feed.
A few steps rest on settings that are proposed, may change: TFG has not decided them, and the field names or the behaviour can still change. They are marked where they appear and listed at the end. Everything else is the API as built.
The shorter walk on the default terms (an e-signature link, payouts to the borrower's wallet at the custodian) is Sandbox quick-start; what each simulator does, and what it never does, is The sandbox.
What you need
- A sandbox credential for a sandbox partner set up for this flow: a
client_id(bpc_test_…) and aclient_secret. TFG hands it to you; keep the secret in your secret manager, never in a file you commit. - That partner's settings, made by TFG (two TFG people, as for every change to your configuration): your KYC evidence accepted (proposed, may change), your settlement account at the custodian registered for your payouts and returns, and an API product whose contract is accepted with a one-time code (
signature_mode: CLICKWRAP_OTP). Ask your TFG contact. - Optionally, an endpoint for webhooks (step 1). The events feed (step 9) needs none.
Conventions for every call below:
Authorization: Bearer <access_token>(step 0) on every/v1call but the token request.- A fresh
Idempotency-Key(a UUID) on everyPOST. Send the same key again only to retry the same request: you get the stored answer, withIdempotent-Replayed: true. - Amounts are decimal strings. Never send real personal data: borrower emails must be under
.test(422 sandbox_test_email_requiredotherwise). Never send real assets to any address the sandbox shows you.
0. A token
POST /v1/oauth/token
Authorization: Basic base64(<client_id>:<client_secret>)
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials
Keep access_token until expires_in runs out, and ask for a new one whenever a call answers 401 invalid_token. Do not parse the token: it is opaque. scope lists what it may do; this walk uses quotes:read, applications:write, applications:read, kyc:write, loans:write, loans:read, collateral:read, repayments:read, webhooks:manage, events:read and sandbox:simulate.
1. Subscribe, and remember where the feed is
POST /v1/webhooks/subscriptions
{
"url": "https://webhooks.example.com/borrou",
"event_types": [
"application.submitted", "kyc.completed", "kyc.status_changed", "application.approved", "application.rejected",
"loan.created", "contract.signed", "collateral.wallet_assigned", "collateral.deposit_received", "collateral.deposit_released",
"loan.disbursed", "loan.activated",
"loan.coverage_warning", "loan.margin_call_issued", "loan.margin_call_cured", "loan.margin_call_expired", "loan.liquidation_level",
"loan.maturity_approaching", "loan.maturity_defaulted",
"loan.liquidation_started", "loan.liquidation_completed",
"loan.repayment_received", "loan.collateral_released", "loan.closed", "loan.cancelled"
]
}
That list is the set the integration guide recommends: every event this walk says you receive, and loan.cancelled. The URL must be your own endpoint, and Borrou checks it before it saves the subscription, and again before every delivery:
httpsonly, on the default port (443, or no port at all), with no user name or password in it;- a public DNS name (not a bare host name, not
localhostor a private suffix such as.localor.internal), or a public IP address; - every address the name resolves to must be public. A name that does not resolve, or resolves to a private, loopback or reserved address, is refused.
Otherwise the answer is 422 invalid_destination, saying which rule failed. As written, webhooks.example.com is a placeholder that does not resolve, so Borrou refuses it: put your own endpoint there. A tunnel to your machine works if its public name resolves to a public address.
The answer carries the subscription; read its signing secret once with GET /v1/webhooks/subscriptions/{id}/signing-secret, straight into your secret store. Verify the Borrou-Signature header on the raw body of every delivery before you act on it (snippets/ has a verifier in TypeScript, Python and Java, tested on Borrou's own fixture).
Then note the feed's current end: GET /v1/events?after=0, page to the last next_cursor, and keep the last position. Step 9 reads from there.
2. Your product
GET /v1/products
Check, on your API product:
| Field | For this flow | Meaning |
|---|---|---|
signature_mode | CLICKWRAP_OTP | The borrower accepts in your app with a code Borrou emails them; no signing link. |
repayment_profile, term_days, accrual_basis | for example BULLET, 30, SECOND_ACT_360 | A bullet loan: interest runs per second on a 360-day year from the payout, and principal and interest are paid together, at any time and at the latest at the maturity. |
risk_policies | AUTOMATIC, RETAIN, NON_RECOURSE | Borrou issues a margin call itself; after a sale the lender keeps any surplus and the borrower owes nothing more. Proposed for live use subject to legal clearance (see the end). |
operating.pricing_source, operating.liquidation_execution, operating.maturity_action | PRODUCT, TFG_PROPOSES, DEFAULT | The rate and ladder are the product's; a liquidation is proposed and approved by TFG; nothing is offered at the maturity. Other values of these fields are not offered. |
Where the money goes is not a product field you act on: your partner's settlement account, which TFG registers, receives every payout and every collateral return of your loans. Each loan shows it by kind only (destination.kind: PARTNER_SETTLEMENT_ACCOUNT on the payout and on the release), never by its reference. Borrou never takes a payout or return address from you: an address or destination field anywhere in a body is refused with 422 destination_not_accepted.
3. The application, with your KYC evidence (proposed, may change)
POST /v1/applications
{
"principal_usdt": "1000",
"external_reference": "app-0001",
"borrower": { "reference": "user-0001", "full_name": "Synthetic Borrower", "email": "borrower.0001@example.test", "country": "AR" },
"kyc_evidence": {
"provider_name": "Your KYC provider",
"applicant_reference": "kyc-applicant-0001",
"checks": [
{ "check": "PROOF_OF_ADDRESS", "passed_on": "2026-10-20" },
{ "check": "SOURCE_OF_FUNDS", "passed_on": "2026-10-20" }
],
"documents": [{ "kind": "PROOF_OF_ADDRESS", "reference": "doc-0001" }],
"residence_country": "AR",
"attestation_version": "partner-kyc-attestation-v0.1-draft"
}
}
- The borrower's fields are write-only: never returned, never in events. Keep your own record.
kyc_evidencecarries references only, never a document or its bytes;residence_countrymust beborrower.country; each check once, on a day not in the future. Sending it you attest TFG's attestation text of that version; Borrou stores the version and the text's SHA-256.- The answer's
kyc_evidence.checks_left_for_providernames what the borrower still completes at Borrou's KYC provider. Today that is the identity checks (identity document, liveness, screening): your evidence covers proof of address and the source of funds, unless TFG lets it stand for more. - Refused, and nothing created:
403 partner_kyc_not_accepted(your partner is not set to send evidence),409 kyc_evidence_not_accepted(a borrower whose file is with TFG or decided, or filed under another country). Withoutkyc_evidencethe application is the default one.
4. The rest of KYC, then TFG's decision
POST /v1/applications/{id}/kyc-handoff
{ "mode": "PROVIDER" }
The answer's link is Borrou's identity verification page, short-lived and handed over once: open it for the borrower in live. If the KYC provider does not answer, the hand-off is 503 provider_unavailable with Retry-After: retry with the same key. In the sandbox, play the borrower and TFG's reviewer:
POST /v1/sandbox/applications/{id}/kyc
{ "decision": "APPROVE" }
You receive kyc.completed, kyc.status_changed and application.approved, and GET /v1/applications/{id} reads APPROVED. (REJECT gives application.rejected.)
5. A quote, then the loan
GET /v1/quote?principal_usdt=1000
Keep quote_token: it pins the product's terms for this principal until quote_expires_at.
The quote's BTC amount is indicative. Unless the deployment pins the price (the answer then says price_pinned: true and indicative: false), the quote reads price_pinned: false: its required_collateral_btc is worked out at the display price of the moment, and the token pins the terms, not the price. The loan's own BTC amount is fixed when you create it, at the checked price then, so it can differ from the quote's. Show the borrower the loan's required_collateral_btc (from the answer below, or GET /v1/loans/{reference}), never the quote's. Where the price is pinned, the loan is created at the quoted price for as long as the quote lasts, and 422 quote_expired after.
POST /v1/loans
{
"application_id": "<the application's id>",
"collateral_sender": "CLIENT",
"usdt_network": "TRON (TRC-20)",
"quote_token": "<from the quote>"
}
- The principal is the application's, and the collateral is Borrou's quote from the product at the checked price, rounded up to the satoshi: you set neither.
usdt_networkmust be one Borrou offers and your product accepts (the product'susdt_networks); otherwise422 network_not_accepted.- No address: the payout goes to your settlement account, and you credit the borrower in your app.
- The loan is
LOAN_CREATED;next_actionisISSUE_CONTRACT, yours.
6. The contract, accepted with a one-time code
POST /v1/loans/{reference}/contract
There is no signing_link. Show the borrower the text in acceptance.text.text exactly as given (its version is acceptance.text.version, its hash acceptance.text.text_sha256), with the contract's document.sha256, then ask Borrou to email them a code:
POST /v1/loans/{reference}/contract/acceptance-code
The code is never returned to you. It lasts ten minutes and takes five attempts; a borrower can be sent at most five codes an hour (429 rate_limited with Retry-After beyond that). In the sandbox, read it back as the borrower would read the email:
GET /v1/sandbox/loans/{reference}/contract/acceptance-code
Then send the borrower's click:
POST /v1/loans/{reference}/contract/accept
{ "otp": "<six digits>", "contract_sha256": "<document.sha256>", "text_version": "<acceptance.text.version>", "partner_session_ref": "sess-0001" }
partner_session_ref is an opaque reference of your own to the borrower's session: never an email or an IP address. Every code that does not accept gets one answer, 422 acceptance_code_rejected. If the custodian does not open the loan's collateral wallet in time, the acceptance is not recorded and the answer is 503 provider_unavailable with Retry-After: retry with the same key and the same code. On success you receive contract.signed and collateral.wallet_assigned; the loan is SIGNED_WALLET_READY.
7. The collateral
GET /v1/loans/{reference}/collateral/deposit-address
Before you show the address, verify address_attestation with the key GET /v1/address-keys publishes under its key_id, and check the statement names this address and this loan (Verifying an address). Show verification_code beside it. In the sandbox, play the borrower and the custodian:
POST /v1/sandbox/loans/{reference}/deposit
{ "amount_btc": "<the loan's required_collateral_btc>" }
You receive collateral.deposit_received and collateral.deposit_released; the loan is COLLATERAL_DEPOSITED. A short or late deposit waits for TFG's go/no-go instead.
8. The payout: two approvals, then the custodian
GET /v1/loans/{reference} reads next_action: TFG_APPROVES_PAYOUT, by TFG. In live, two different people at TFG approve every payout in Borrou, and only then is the custodian instructed.
On Borrou's sandbox those two approvals are simulated. The sandbox's two simulated TFG users take them, one entering the payout and the other approving it, through the same two-person checks a live payout goes through. You need no one at TFG to reach ACTIVE:
POST /v1/sandbox/loans/{reference}/advance
advance enters and approves the payout as those two simulated users, then plays the custodian executing it; the answer's steps name what it did. The loan becomes ACTIVE once Borrou's custody sync has applied the execution, usually at once and otherwise within a minute or two: read GET /v1/loans/{reference} until it does. If a TFG person has already entered the payout, a second TFG person approves it in TFG's console; advance then answers 409 sandbox_step_unavailable saying so, and plays only the custodian once the instruction is out.
Once executed, GET /v1/loans/{reference}/disbursement reads EXECUTED with its tx_hash, and its destination.kind is PARTNER_SETTLEMENT_ACCOUNT, by kind only: its reference is never returned. You receive loan.disbursed and loan.activated. A bullet loan now carries matures_at, and every loan its strike_price and trigger_prices. Credit the borrower only once you see EXECUTED.
9. Webhooks and the events feed
Webhooks arrive about a minute after each change, signed, at least once, and not always in order: de-duplicate on the event's id. The feed carries the same events with the same ids:
GET /v1/events?after=<the last position you processed>
Process each page in order, store the last position, and pass next_cursor for the next page. Positions only grow, so reading from your last position misses nothing. Use the feed to recover what your endpoint missed, and as your reconciliation source.
10. While the loan runs
- Coverage.
GET /v1/loans/{reference}/coveragereads the loan's collateralisation at the checked price.loan.coverage_warningandloan.liquidation_leveltell you when the price moves it between levels. In the sandbox,POST /v1/sandbox/pricesmoves your own simulated BTC price, in steps of up to about 9.5%, each after the next price check. - Margin calls. On a product whose margin calls are automatic, Borrou issues the call itself once two checked prices from both sources put the loan at or below its margin-call level, and emails the borrower the notice: you receive
loan.margin_call_issued, thenloan.margin_call_curedorloan.margin_call_expired. A call moves nothing. While it is open,next_actionisBORROWER_TOPS_UP_COLLATERAL, and the top-up address isGET /v1/loans/{reference}/collateral/top-up-address, verified like the deposit address. - Maturity.
loan.maturity_approachingcomes twice, a week beforematures_atand a day before;loan.maturity_defaultedcomes if the loan is unpaid at it. Nothing is sold or moved on either. - Liquidation. A sale is proposed by one TFG person and approved by another, never by the API or by a timer:
loan.liquidation_started, thenloan.liquidation_completed, whose data carries what the lender kept (surplus_retained_usdt) and, on a non-recourse loan, the loss the borrower does not owe (shortfall_not_owed_usdt). There is no sandbox simulator for a liquidation.
11. The repayment
GET /v1/loans/{reference}/balance
GET /v1/loans/{reference}/repayment-instructions
The instructions give the full amount to repay, valid until valid_until, the end of the UTC day, and Borrou's USDT receiving address on the loan's network. On a bullet loan, whose interest runs per second, full.amount_usdt is what the loan will owe at the end of that UTC day, so a payment that reaches Borrou and is recorded any time before then covers it. A payment made earlier in the day is up to one day's interest more than the loan owes at that moment; how that difference is treated is still to be confirmed by TFG. Read the instructions again after valid_until for the next day's amount. A partial repayment follows the product (refused unless it allows one).
In the sandbox the address is synthetic (destination.synthetic: true): send nothing to it.
In live the borrower, or you for them, sends the USDT; TFG records the payment, one person entering it and a different one confirming it after checking the transaction against the custodian. In the sandbox both are simulated (proposed, may change), through the same two-person checks:
POST /v1/sandbox/loans/{reference}/repayment
makes the full amount arrive at the simulated custodian, and the sandbox's two simulated TFG users enter and confirm the repayment, one each (steps: TRANSFER_SEEN, REPAYMENT_ENTERED, REPAYMENT_CONFIRMED). Then you receive loan.repayment_received, and an open margin call ends with the debt.
The collateral then goes back after two more TFG approvals and the custodian's execution, to your settlement account. In the sandbox, POST /v1/sandbox/loans/{reference}/advance on the repaid loan plays them (steps: COLLATERAL_RETURN_ENTERED, COLLATERAL_RETURN_APPROVED, CUSTODIAN_EXECUTED): GET /v1/loans/{reference}/release reads release.status up to EXECUTED with its tx_hash, and release.destination by kind only (PARTNER_SETTLEMENT_ACCOUNT). You receive loan.collateral_released and loan.closed.
What is proposed, may change
None of these is decided by TFG for live use; each is off unless TFG sets it for your partner or product:
- Your KYC evidence (
kyc_evidenceonPOST /v1/applications, step 3), what it covers, and the attestation text and its version. - The contract accepted with a one-time code, the lender keeping a liquidation surplus, and non-recourse: decided for this channel, and subject to legal clearance before any live loan uses them. Live, a product with any of them lends nothing until then (
409 legal_clearance_pending). The sandbox is never held back by that. - Simulated TFG approvals of the payout are on for Borrou's sandbox only (step 8). Live, every payout waits for two TFG people.
Errors you may meet
Every error is { "error": { "code", "message", "request_id" } }; branch on code, quote request_id to TFG. Error codes has each code's cause, remedy and whether a refusal is stored under the Idempotency-Key.
| Step | Codes |
|---|---|
| 0 | invalid_client, unsupported_grant_type, invalid_scope, rate_limited |
| 1 | invalid_destination, invalid_request (more than ten active subscriptions) |
| 3 | sandbox_test_email_required, country_not_accepted, partner_kyc_not_accepted, kyc_evidence_not_accepted, borrower_mismatch, duplicate_external_reference, amount_above_limit, amount_below_minimum |
| 4 | kyc_handoff_not_open, kyc_link_not_replayable, provider_unavailable, sandbox_step_unavailable |
| 5 | product_unavailable, application_not_approved, borrower_not_eligible, invalid_quote_token, quote_expired, quote_mismatch, quote_terms_changed, network_not_accepted, destination_not_accepted, price_unavailable, exposure_limit_reached |
| 6 | contract_not_issuable, borrower_not_eligible, contract_not_awaiting_acceptance, rate_limited, acceptance_code_rejected, contract_document_mismatch, acceptance_text_outdated, provider_unavailable |
| 7 | deposit_address_unavailable, sandbox_step_unavailable |
| 8 | sandbox_step_unavailable |
| 10 | price_move_out_of_band, loan_not_active, loan_repaid_in_full, deposit_address_unavailable |
| 11 | nothing_to_repay |
Any call can also answer rate_limited (with Retry-After) or internal_error.