Overview / Guides / Get started
Integration guide
Start here. This guide says what the integration is, who does what, how to get into the sandbox, the flow end to end, what to build on your side and what has to be true before going live. The details are in the other guides, each linked where it matters.
What you are integrating
Borrou lends USDT against BTC collateral to your users, inside your own app. You are the channel: you originate and inform. TFG approves and moves: every payout and every return of collateral is approved by two different people at TFG and then executed by the custodian. The API never moves funds, never approves anything and never takes a payout or return address.
| Who | Does |
|---|---|
| You (your backend, through the API) | Apply for your user, start their KYC, create the loan once TFG has approved the borrower, issue the contract, show the borrower what Borrou gives you (an acceptance text or a signing link, a deposit address, the loan's figures), and follow everything by webhook and by the events feed. |
| The borrower (in your app) | Completes the identity check, accepts or signs the contract, sends the BTC, tops up on a margin call, repays. |
| TFG | Decides the borrower's KYC, approves every payout and every return of collateral (two people), records repayments, decides a liquidation (one person proposes, another approves), and sets your configuration (two people for every change). |
| The custodian | Holds the collateral in one wallet per loan, screens deposits, and executes what TFG approved. |
| Borrou | Quotes and prices, monitors every loan's coverage, issues margin calls where your product says so, keeps the records and sends the events. |
Where the money goes is set by TFG for your partner, never by a request:
- Your settlement account at the custodian, if TFG has registered one for you. Every payout and every return of collateral of your loans goes there, and you credit the borrower in your app.
- Otherwise, the borrower's own wallet at the custodian, which Borrou asks the custodian to open when TFG approves the borrower.
A loan shows which by kind only (destination.kind), never by reference.
Environments
| Sandbox | Live | |
|---|---|---|
| Base URL | https://api.borrou.capital | Announced by TFG |
| Credential | client_id starting bpc_test_ | client_id starting bpc_live_ |
| Data | Synthetic only: borrower emails under .test | Real |
| The borrower's KYC, signature and deposit | Simulated on request (/v1/sandbox/…) | The borrower, at the providers and with their own BTC |
| The payout's two TFG approvals | Simulated on Borrou's sandbox, through the same two-person checks | Two TFG people |
| A repayment, and the collateral's return | Recorded by TFG: ask your TFG contact, naming the loan's LN- reference | TFG |
| BTC price | Your own simulated feed (POST /v1/sandbox/prices) | The checked market price |
| Addresses shown | Synthetic: never send real assets to them | Real, and always signed by Borrou |
A sandbox credential is refused on live and a live one on the sandbox. Make the base URL and the credential configuration, never constants, and never call a /v1/sandbox path from code that can run against live. The sandbox says what each simulator does and never does.
Getting into the sandbox
TFG sets up, for your partner:
- A sandbox partner and its API product: its rate, term, collateral levels, limits, accepted USDT networks and countries, and how the contract is accepted (a signing link, or a one-time code the borrower receives by email). Read it all with
GET /v1/products. - Where the money goes: your settlement account at the custodian, or the borrower's wallet there.
- A sandbox credential, a
client_idand aclient_secret, handed to you through a secure channel of TFG's choosing. The secret is shown once: keep it in your secret manager.
Then, in your first hour:
- Run the quick-start (Sandbox quick-start): a token, your product and a quote, then one loan through the sandbox, from the Bruno collection or the code snippets.
- Walk one borrower end to end, call by call (Channel flow, call by call).
What to build on your side
| Component | What it does |
|---|---|
| API client, on your backend only | OAuth 2.0 client credentials (POST /v1/oauth/token); the token kept until expires_in and renewed on 401 invalid_token. Tokens are opaque: never parse them. Never call Borrou from a mobile app or a browser. |
| Idempotent writes | A fresh Idempotency-Key (a UUID) on every POST and DELETE, kept with your own record of the request; the same key only to retry the same request. |
| Retries | Only no answer (a timeout or a dropped connection), 429 and a 5xx, with the same key, after Retry-After where there is one, backing off otherwise; not the two configuration refusals Error codes marks as not transient (lender_of_record_not_configured, repayment_address_not_configured). A 409 or 422 is never retried unchanged: it is the state of a record, or the request itself (Rules and checklist, section 7). |
| Webhook receiver | HTTPS on 443 at a public DNS name. Borrou-Signature verified on the raw body before anything acts on it. A 2xx answered at once and the work done after. Events de-duplicated on their id: delivery is at least once, and not always in order. |
| Events feed reader | GET /v1/events?after=<last position>: the same events in a guaranteed order, to recover what your endpoint missed and to reconcile against. Keep the last position. |
| Address verification | Before a deposit or top-up address is shown, its address_attestation verified against GET /v1/address-keys, and its verification_code shown beside it (Verifying an address). |
| Contract screen | The acceptance text shown exactly as given and the borrower's acceptance relayed with their one-time code, or the signing link opened, as your product says. |
| Loan screens | Driven by next_action and the events, never by timers: the loan's state, what is owed, coverage, a margin call and its top-up, the maturity, the repayment instructions. |
| Your own borrower record | Borrower personal fields are write-only in Borrou: never returned, never in an event. Keep your own. |
The rules that break an integration when ignored are in Rules and checklist; the first of them:
- Never send an address or a
destinationfield:422 destination_not_accepted. - Never set a loan's collateral or principal: the principal is the application's, and Borrou quotes the collateral to the satoshi.
- Money is a decimal string (USDT up to 6 decimals, BTC up to 8), never a float.
- A step is done when Borrou says so (
loan.activated; a payoutEXECUTEDwith itstx_hash), not when you asked for it. - Branch on
error.code, never onmessage, and quoterequest_idto TFG. - No personal data in references (
external_reference,borrower.reference,partner_session_ref).
The flow end to end
The steps of Channel flow, call by call, with every request and answer there.
| Step | Who | Calls | Events |
|---|---|---|---|
| A token | You | POST /v1/oauth/token | — |
| Webhooks, and the feed's current end | You | POST /v1/webhooks/subscriptions, GET /v1/events | — |
| Your product | You | GET /v1/products | — |
| The application | You | POST /v1/applications | application.submitted |
| KYC, then TFG's decision | You start it; the borrower completes it; TFG decides | POST /v1/applications/{id}/kyc-handoff | kyc.completed, kyc.status_changed, application.approved or application.rejected |
| A quote, then the loan | You | GET /v1/quote, POST /v1/loans | loan.created |
| The contract | You issue it; the borrower accepts or signs | POST /v1/loans/{reference}/contract, then …/contract/acceptance-code and …/contract/accept for a code | contract.sent, contract.signed, collateral.wallet_assigned |
| The collateral | The borrower | GET /v1/loans/{reference}/collateral/deposit-address | collateral.deposit_received, collateral.deposit_released |
| The payout | TFG (two people), then the custodian | GET /v1/loans/{reference}/disbursement | loan.disbursed, loan.activated |
| While the loan runs | Borrou, the borrower, TFG | GET /v1/loans/{reference}/coverage, …/margin-calls, …/collateral/top-up-address, …/balance | loan.coverage_warning, loan.margin_call_issued, loan.margin_call_cured, loan.margin_call_expired, loan.liquidation_level, loan.maturity_approaching, loan.maturity_defaulted |
| The repayment, and the collateral back | The borrower pays; TFG records it and returns the collateral | GET /v1/loans/{reference}/repayment-instructions, …/release | loan.repayment_received, loan.collateral_released, loan.closed |
Before activation you may cancel (POST /v1/loans/{reference}/cancel, with a coded reason) until TFG has entered the payout; collateral already deposited then goes back once two TFG people approve it.
GET /v1/loans/{reference} carries next_action: { code, by }: what has to happen for the loan to move, and who does it. Only ISSUE_CONTRACT is yours. The table of every code and what your app shows for it is in Rules and checklist.
KYC
| Mode | What it is |
|---|---|
Borrou's KYC provider (hand-off mode PROVIDER) | Borrou's identity-verification page, opened for the borrower from a short-lived link handed to you once. No document goes through you or through the API. |
Your own KYC evidence (kyc_evidence on POST /v1/applications; proposed, may change) | References to what your KYC established: the checks passed and when, your document references and the country, never a document. It covers proof of address and the source of funds; the identity checks still go through Borrou's provider unless TFG lets your evidence stand for them. The answer's checks_left_for_provider says what remains. Only for a partner TFG has set to send it. |
Reliance (hand-off mode RELIANCE) | You attest the borrower's KYC under a reliance arrangement TFG has approved. Off until TFG decides it. |
Importing a borrower someone else has already verified, so that the identity checks are not repeated, is not supported. The borrower's country is required, and is checked against TFG's list of countries it does not serve and the countries your product accepts (422 country_not_accepted).
Risk while the loan runs
- Coverage is collateralisation: the collateral's value divided by the principal plus the interest accrued, in basis points, compared exactly with your product's levels (the initial margin, the margin call and the liquidation level). The LTV beside each level is for display only.
- The strike and the trigger prices. At the payout Borrou records the loan's strike, the checked BTC price then, and publishes the BTC prices at which the loan reaches its margin-call and liquidation levels, at the strike and now. Every loan resource carries them, and
loan.disbursed. - Margin calls are issued by TFG, or by Borrou itself on a product whose margin calls are automatic, and only on checked prices. The borrower is emailed the notice; you receive
loan.margin_call_issued, andnext_actionbecomesBORROWER_TOPS_UP_COLLATERAL. Show the top-up asked for and the top-up address, verified like the deposit address, before the deadline. Thenloan.margin_call_curedorloan.margin_call_expired. A margin call moves nothing. - A liquidation is never automatic: one TFG person proposes it and another approves it. You receive
loan.liquidation_startedandloan.liquidation_completed. - In the sandbox move your own BTC price with
POST /v1/sandbox/pricesto see warnings and margin calls: steps of up to about 9.5%, each after the next price check.
Events to subscribe to
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
Every event carries identifiers, statuses and amounts only: no personal data. The full catalogue, with each event's data, is in the API reference. Webhooks go out about a minute after the change; you can list deliveries and replay one (GET /v1/webhooks/deliveries, POST /v1/webhooks/deliveries/{id}/replay), and read your subscriptions' health (GET /v1/webhooks/health).
Security
- The
client_secret, access tokens, webhook signing secrets and one-time codes stay in memory or in your secret manager: never in logs, error reports, fixtures or source control. - Every webhook verified on its raw body before anything acts on it.
- Every deposit and top-up address verified against Borrou's published keys before it is shown.
- Borrou called from your backend only, with sandbox and live kept apart by configuration.
- No personal data in references or in webhook URLs.
Before going live
On your side:
- The flow end to end passes in the sandbox, and so do a rejected KYC; a cancellation before and after the deposit; a short deposit, which waits for TFG; a margin call by moving the price, cured by a top-up and left to expire; a repayment TFG records and the collateral's return; a request replayed with the same
Idempotency-Key; and your endpoint down, then recovered from the events feed and by replaying deliveries. - Every error code your calls can meet is handled (Error codes).
- Unknown event types,
next_actioncodes and fields are logged and ignored, never fatal (Versioning). - The checklist at the end of Rules and checklist.
On TFG's side, confirmed to you before your first live loan: the live environment and your live credential; your product's live terms, some of which wait for legal clearance before any live loan uses them (409 legal_clearance_pending until then; the sandbox is never held back by it); and the lender named on your borrowers' contracts and statements, shown as "to be confirmed" until it is set.
Support
Quote the response's X-Request-Id (or the error's request_id) and the loan's LN- reference. Never send TFG a secret, a token or a one-time code.