BorrouPartner APISandboxDraft

Draft documentation for partners integrating against the sandbox. It can change before /v1 is published; the contract, openapi.yaml, is the reference.

Overview / Guides / Build

Error codes

v0.2 draftEvery error code with its HTTP status, cause, remedy, and whether a refusal is stored under the Idempotency-Key.

Every error has the same body:

{ "error": { "code": "application_not_approved", "message": "…", "request_id": "…" } }
  • Branch on code, never on message. Codes are stable; messages are for people and may be reworded. New codes may be added at any time (see Versioning): treat an unknown code by its HTTP status.
  • request_id is also in the X-Request-Id header of every response. Quote it when you ask TFG about a request.
  • Retry-After (seconds) comes with every 429, with 503 price_unavailable and with 503 provider_unavailable. Wait at least that long.

Retries and the Idempotency-Key

Every POST and DELETE (except the token request) takes an Idempotency-Key. A retry of the same request sends the same key; a new request sends a new key.

The last column below says whether a refusal is stored under the key:

  • Stored: the refusal is about the request itself. Sending the same key again replays it, with Idempotent-Replayed: true. To try something different, change the request and send a new key.
  • Not stored: the refusal can change without the request changing (TFG acts, a price comes back, a provider answers). The same key works once the situation has changed.
  • Before the write: refused before anything ran (authentication, validation, a malformed id, not found), so nothing is stored and the same key can be used once the request is fixed.
  • Read: a GET; there is no key.

Retry automatically only on no answer (a timeout or a dropped connection), 429 and 5xx, with the same key, honouring Retry-After, with backoff and a limit on attempts. Every 409 is a conflict with the state of a loan, an application or a request: retrying it unchanged gets the same answer. Borrou never answers 409 to a concurrent retry with the same key; that request waits for the first one and replays its answer.

Authentication and access

CodeHTTPWhenWhat to doStored
invalid_client401The token request's client credentials are missing, malformed, unknown, wrong, revoked, for the other environment (a sandbox credential on live, or the reverse), or for a partner the API does not serve now. Which part was wrong is never said.Check the client_id and client_secret and the base URL. If they were rotated or revoked, use the current ones; otherwise contact TFG.n/a
unsupported_grant_type400grant_type is not client_credentials.Send grant_type=client_credentials.n/a
invalid_scope400The token request asked for a scope that does not exist or was not granted to the credential.Ask only for scopes the credential holds, or leave scope out to get all of them.n/a
invalid_token401No Bearer token, or one that is expired, forged, for the other environment, from a revoked credential, from a secret a rotation has retired, or for a partner the API does not serve now (disabled, or an access mode without the API).Get a new token and retry once. If a fresh token is refused too, the credential or the partner's access has changed: contact TFG.Before the write
insufficient_scope403The token does not carry the scope the endpoint needs (named in the message and in WWW-Authenticate).Ask TFG to grant the scope to the credential, then get a new token.Before the write
rate_limited429Too many requests: per partner per minute (RateLimit-* headers), per source address, on the token endpoint, or on a capped action (replays, contract reminders, one-time codes).Wait Retry-After seconds, then retry with the same key. Cache tokens instead of asking for one per request.Not stored

Requests and idempotency

CodeHTTPWhenWhat to doStored
invalid_request400, 422400: the body or query failed validation (the message names the field), an unknown field was sent (bodies are strict), a cursor is not one of yours (or, for the events feed, not a position), the token request is malformed, or the Idempotency-Key is not 1 to 255 visible ASCII characters. 422: a new webhook subscription would exceed ten active ones.Fix the request as the message says. For the subscription cap, disable one you no longer use.Before the write; the subscription cap is stored
unsupported_media_type415A body that is not application/json (or, for the token request, not form-encoded or JSON).Send Content-Type: application/json.Before the write
payload_too_large413The body is over 64 KiB.Send less; no request needs that much.Before the write
idempotency_key_required400A POST or DELETE without an Idempotency-Key.Generate a key (a UUID) for the request and keep it for its retries.Before the write
idempotency_key_mismatch422The key was already used with a different request (another path or body). Nothing is written.Use a new key for every new request. Send a key again only to retry the same request.Nothing written
not_found404No such endpoint, a malformed id, or a resource that does not exist or belongs to another partner (the two look the same).Check the id or reference, and that it is one of yours.Before the write

Catalogue, quotes and prices

CodeHTTPWhenWhat to doStored
product_unavailable409You have no active product on the API channel, your product sizes collateral from agreed terms (which the API cannot take), or you named a product that is not your active one.Ask TFG to activate an API product with quoted collateral, or quote the code the message names.Not stored
amount_above_limit422A principal above the product's maximum (quote, application, loan); an increase above what may be requested now; a surplus return above what may go back.Ask for less. For an increase or a surplus return, read GET /v1/loans/{reference}/upper-limit first.Stored for an application or a loan; not stored for an increase or a surplus return
amount_below_minimum422A principal below the product's minimum.Ask for more.Stored
price_unavailable503No checked BTC price right now (its circuit breaker is open, or the sources disagree). Nothing was created.Wait Retry-After and retry with the same key. GET /v1/prices/btc-usd shows the breaker.Not stored
quant_platform_unavailable503Not offered: only for a product priced per loan by a pricing platform (operating.pricing_source: QUANT), which no partner is set to. That pricing is not available, or did not quote this loan. Nothing was created.Retry later with the same key.Not stored
invalid_quote_token422The quote_token was not issued by this service to your partner.Quote again (GET /v1/quote) and send its token, or leave the token out.Stored
quote_expired422The quote_token is past quote_expires_at; where the deployment pins the quoted price (price_pinned), the message says how old that price is.Quote again and send the new token.Stored
quote_mismatch422The quote_token was issued for another principal than the application's.Quote the application's principal.Stored
quote_terms_changed409Your product's terms changed after the quote.Quote again and send the new token.Not stored

Applications and KYC

CodeHTTPWhenWhat to doStored
duplicate_external_reference409Another application of yours already has this external_reference.Read that application, or send a different reference.Stored
borrower_mismatch409A borrower with this email is already your client under a different name. One email is one borrower.Check the borrower's details; correct the name or the email.Stored
application_not_cancellable409The application is already cancelled or already a loan.Nothing to cancel. To stop a loan before activation, cancel the loan.Stored
kyc_handoff_not_open409The application is cancelled or already a loan (stored); or the borrower's KYC file is with TFG or TFG has decided it (not stored).Wait for TFG's decision (application.approved or application.rejected).Stored for a cancelled application or a loan; not stored while TFG holds or has decided the file
reliance_not_approved403A RELIANCE hand-off from a partner TFG has not approved for reliance, or while TFG does not let a reliance attestation stand for its identity checks (a setting still open).Use mode: PROVIDER, or ask TFG about reliance.Not stored
country_not_accepted422The borrower's country of residence is on TFG's block-list, outside the countries your agreement with TFG covers, or not one your product lends to (an application); or there is none on file (a RELIANCE hand-off).Send the borrower's real country of residence; a country excluded for you or your product cannot borrow under it. Ask TFG if your agreement should cover it.Stored
kyc_link_not_replayable409A retry, with the same key, of a PROVIDER hand-off: its short-lived link is handed over once and kept nowhere. The body carries the hand-off without the link.For a fresh link, send a new hand-off with a new key.Stored (this is the stored answer)
provider_unavailable503The KYC or e-signature provider did not answer (a hand-off, or a contract), or the custodian did not open the loan's collateral wallet when a click-wrap acceptance was sent. Nothing was sent to the borrower, and no acceptance was recorded (the one-time code stays unspent); a contract's retry makes the agreement on the same document.Wait Retry-After and retry with the same key (for an acceptance, the same code).Not stored

Loans and origination

CodeHTTPWhenWhat to doStored
application_not_approved409TFG has not approved the borrower yet, so no loan can be created.Wait for application.approved, then retry with the same key.Not stored
borrower_not_eligible409On POST /v1/loans: TFG approved the borrower, but no new loan can start now: an override of missing documents has expired, the country of residence is to be confirmed or not one your product lends to, the approval predates the identity checks TFG now requires, or the borrower's identity verification does not pass at the KYC provider at the moment. On POST /v1/loans/{reference}/contract: the borrower is no longer approved by TFG, or does not pass at the KYC provider. The message says which.Provide what the message names (your operators can upload a missing proof of address or source-of-funds declaration), or ask TFG compliance; then retry with the same key.Not stored
application_not_open409The application is cancelled, or already a loan (the message names it).Read the application; submit a new one if needed.Stored
exposure_limit_reached422The loan, or the increase, would take you over your remaining capacity with TFG.Ask for less, or ask TFG about your capacity.Not stored
network_not_accepted422usdt_network is not one Borrou offers, or not one your product accepts.Send a network from your product's usdt_networks.Stored when the product does not accept it; before the write when Borrou does not offer it
destination_not_accepted422The body has an address or destination field, at any depth. Payouts and collateral returns go to your settlement account at the custodian, if TFG has registered one for you, or otherwise to the borrower's wallet at the custodian, opened when TFG approves the borrower; the API takes no address.Remove the field.Before the write
payout_destination_required422Not offered: only for a product that pays out to an address you provide, which no partner is set to. POST /v1/loans carried no payout.Ask TFG about your product's settings.Stored
collateral_return_destination_required422Not offered: only for a product that returns collateral to an address you provide, which no partner is set to. POST /v1/loans carried no collateral_return.Ask TFG about your product's settings.Stored
destination_address_invalid422Not offered: only for a product that takes an address from you, which no partner is set to. The address does not fit its network.Ask TFG about your product's settings.Stored
contract_not_issuable409The contract can be issued only while the loan is LOAN_CREATED.Read GET /v1/loans/{reference}/contract: it may already be sent or signed.Stored
contract_not_awaiting_signature409A reminder for a contract that is not waiting for the borrower's signature.Nothing to remind.Not stored
contract_not_awaiting_acceptance409A one-time code or an acceptance for a contract that is not a click-wrap one (signature_mode CLICKWRAP_OTP) awaiting the borrower's acceptance; in the sandbox read-back, no usable code.Read GET /v1/loans/{reference}/contract: it may be signed already, or signed through the e-signature link. In the sandbox, send a new code first.Stored; read for the sandbox read-back
contract_document_mismatch422contract_sha256 is not the SHA-256 of the loan's stored contract. No attempt is spent.Show the borrower the contract GET .../contract describes, and send its document.sha256.Stored
acceptance_code_rejected422The code does not accept the contract: wrong, expired, already used, out of attempts, or none sent. One answer for all of them; a wrong code spends one of its five attempts. Nothing was recorded.Ask the borrower to check the latest email from Borrou, or send a new code with POST .../contract/acceptance-code; send the next attempt with a new key.Stored
legal_clearance_pending409Live only: the product's terms wait for legal clearance (today: click-wrap acceptance, a liquidation surplus kept by the lender, or a non-recourse loan), so no loan is created and no contract issued on them. Nothing was created.Contact TFG. Retrying changes nothing until TFG has recorded the clearance.Not stored
partner_kyc_not_accepted403kyc_evidence sent, but TFG has not set your partner to send its own KYC evidence (proposed, pending TFG). The application was not created.Send the application without kyc_evidence and use a KYC hand-off, or ask TFG; then retry with the same key.Not stored
kyc_evidence_not_accepted409kyc_evidence for a borrower whose KYC file is with TFG for review or already decided, or whose country on file is not kyc_evidence.residence_country. The application was not created.Send the application without kyc_evidence, or ask TFG to confirm the borrower's country.Not stored
repayment_detection_off409Not offered: repayment announcements (POST /v1/loans/{reference}/repayments) are not taken. Nothing was recorded.Send nothing here; TFG records repayments.Not stored
repayment_announced_differently409Not offered (repayment announcements): this hash was already announced on the loan with another network, asset or amount. Nothing was recorded.Check the transfer, and announce it with its own figures.Stored
collateral_announcement_not_taken409Proposed (collateral announcements, POST /v1/loans/{reference}/collateral/announcements): the loan has a deposit address of its own, or takes no collateral in its state. Nothing was recorded.Send the collateral to the loan's deposit address; no announcement is needed.Stored
collateral_transfer_already_announced409Proposed (collateral announcements): the transaction was already announced for another loan. Nothing was recorded.Announce each loan's own transaction: one transaction is one loan's collateral.Stored
asset_not_accepted422Not offered (repayment announcements): the loan is not repaid in the asset announced (USDT today).Announce the transfer in the loan's asset.Stored
deposit_address_unavailable409No deposit address yet (before the signature), none any more (the loan is active: use the top-up address; or it has ended), or the address cannot be confirmed right now: Borrou's records disagree, or its signature on the address does not verify.Follow next_action. If the address cannot be confirmed, contact TFG before anything is sent, and never use an address you held from before.Read
lender_of_record_not_configured503Live only: the lender of record for the loan's product is not set yet, so no loan is created and no contract issued. Nothing was created.Contact TFG. Retrying changes nothing until TFG has set it.Not stored
loan_not_cancellable409The loan is active or has ended (stored); or TFG has entered its payout, or the payout is with the custodian (not stored).Contact TFG to stop a payout already entered.Stored for an active or ended loan; not stored while a payout is entered or with the custodian

Servicing

CodeHTTPWhenWhat to doStored
loan_not_active409The step needs an active loan (a top-up address, an increase, a surplus return, a repayment announcement).Follow next_action.Read for the top-up address; not stored for an increase or a surplus return; stored for a repayment announcement
nothing_to_repay409Repayment instructions for a loan that is not active, or is repaid in full and waits for its collateral to go back.Send nothing.Read
repayment_address_not_configured503Live only: Borrou has no receiving address configured for the loan's network yet.Send no funds; contact TFG.Read
loan_repaid_in_full409A top-up address for a loan repaid in full whose collateral is going back.Send nothing more to the loan.Read
address_verification_pending409Live only: the deposit or top-up address carries no Borrou signature yet, or the service holds no key to check one, so it is not served (see Verifying an address).Ask TFG for it; never use an address from anywhere else.Read

Above the upper limit

CodeHTTPWhenWhat to doStored
upper_limit_unavailable409The loan is not above its upper limit with no breach continuing (the message names why: below the limit, a margin call open, interest overdue, a liquidation under way, and so on), or the borrower has no verified email for the one-time code.Read GET /v1/loans/{reference}/upper-limit; reason says why.Not stored
increase_in_progress409An increase is already offered or accepted on the loan. An increase and a surplus return never run together.Wait for it to be paid or to end, or withdraw it.Not stored
surplus_return_in_progress409A surplus return is requested or under way on the loan.Wait for it to end.Not stored
increase_not_open409The increase is no longer awaiting the borrower (accepted, paid, expired or cancelled).Read the request's status.Stored; read for the sandbox code read-back
increase_expired409The increase has ended (its acceptance window passed, or ten wrong codes in all). Nothing was recorded.Request a new increase if the borrower still wants one.Stored
increase_not_cancellable409TFG has entered the increase's payout.Ask TFG to stop it.Not stored
surplus_return_not_cancellable409TFG has entered the return, or the request has already ended or lapsed.Ask TFG to stop an entered return.Stored
acceptance_text_mismatch422text_sha256 is not the SHA-256 of the text Borrou issued for this request.Show the borrower acceptance_text.text exactly as given, and send its hash.Stored
acceptance_text_outdated422text_version is unknown or not the current version.Show the text in the request as it is now, and send its version.Stored
invalid_accepted_at422accepted_at is before the request or its one-time code, or in the future.Send the time of the borrower's click from a synchronised clock.Stored
otp_not_issued409No one-time code has been sent for the request (or, in the sandbox read-back, the current one was not issued by this sandbox).Send one with POST .../resend-code.Stored on an acceptance; read for the sandbox read-back
otp_invalid422Not the code Borrou emailed the borrower. It spends one of the code's five attempts.Ask the borrower to check the code; send the next attempt with a new key (the body changed).Stored
otp_expired422, 409The code is past its ten minutes (422 on an acceptance; 409 on the sandbox read-back).Send a new one with resend-code.Stored on an acceptance; read for the sandbox read-back
otp_used409The code was already used.Read the request: it is probably accepted.Stored on an acceptance; read for the sandbox read-back
otp_attempts_exhausted422, 409Five wrong attempts on this code (422 on an acceptance; 409 on the sandbox read-back).Send a new one with resend-code. Ten wrong codes in all end the request.Stored on an acceptance; read for the sandbox read-back

Webhooks

CodeHTTPWhenWhat to doStored
invalid_destination422The webhook URL is not https, not on port 443, carries a user name or password, or its host is not a public DNS name resolving to public addresses.Use a public https endpoint on the default port.Before the write
subscription_inactive409A replay of a delivery whose subscription is disabled.Subscribe again, or read the event from GET /v1/events.Stored

Sandbox

CodeHTTPWhenWhat to doStored
sandbox_only403A sandbox simulator called anywhere but the sandbox, with a live credential, or for a partner that is not a sandbox partner.Call the simulators only on the sandbox with your sandbox credential. In live, the borrower, the providers, the custodian and TFG take these steps.Before the write
sandbox_step_unavailable409The simulator has nothing to do for the loan or application as it stands; the message says what it waits for. This includes advance on a payout a TFG person entered (a second TFG person approves it), or, on a sandbox where simulated approvals are off, any payout until two TFG people have approved it.Follow the message: the step it names, or ask your TFG contact to approve the payout.Not stored
price_move_out_of_band422A sandbox price step moves more than the price checks accept at once from the price they last accepted.Move the price in smaller steps, each after the next price check (about a minute).Not stored
sandbox_test_email_required422An application in the sandbox names a borrower email outside the .test domain. The sandbox takes synthetic borrowers only, so nothing it sends can reach a real person.Use a synthetic address under .test, such as borrower-1@partner.test.Stored

Service

CodeHTTPWhenWhat to doStored
internal_error500Something went wrong on Borrou's side. Nothing was saved.Retry with the same key, with backoff. If it persists, contact TFG with the request_id.Not stored