Request a new loan.
If you haven't visited the guide: how to make your first loan? we recommend you to visit it first.
Timeout after: 30 seconds (status code will be 504 in such a case)
You can request a loan for only one invoice. At the moment, we don't support multiple-invoices financing.
- You can either request a loan for an existing invoice, in which case you should set
invoice_ids
. - Or you can create the invoice and request a loan with a single call to this API.
- If you pass an invoice in
invoices
, the base64-encoded value of the PDF of the invoice is required under thedocument
property. You can for example use base64guru.
Behavior
When you send this API request, our system will:
- Create a loan in our database (you will get its id in the response)
- Start evaluating your loan request. Here you should choose between 2 behaviors:
a. (default) Getting the decision asynchronously. The status of the returned loan will always be PENDING_VALIDATION. Webhooks will tell you if it goes approved or declined. In can happen from a few seconds after the request up to a few days after it.
b. Getting the decision synchronously. This is recommended if this endpoint is called directly from a frontend. To activate this option, set"wait_for_validation": true
. In such a case, the returned loan status will be:
i. if the loan is automatically accepted by Defacto -> the status of the loan will be TO_VALIDATE if you set"auto_validate": false
, or one of: VALIDATED, SCHEDULED, INITIATED, TO_REPAY. Fore more information on this, see section "Why the status of the loan in the response vary?" below.
ii. if the loan is automatically declined by Defacto -> the status of the loan will be DECLINED and thedenial_reason
will be set.
iii. if the loan validation takes longer than 20s (max response time is 2 business days) -> the status of the loan will be PENDING_VALIDATION. It is therefore very important to think about how to communicate with the end-user. While its not an issue for validated loans, it can get frustrating for declined loans. Users must be alerted of loans that gets declined few hours after their request. - If the loan is accepted by Defacto, it will then move forward and its status will be updated regularly. Subscribe to webhooks to get live notifications of this.
Why the status of the loan in the response vary?
The status vary because our system is asynchronous and the steps moving the loan forward may be executed immediately or not depending on the current load on our system.
What should I do if the status of the loan is TO_VALIDATE?
TO_VALIDATE means that Defacto accepted the loan as is.
The next step is to get the user consent for this loan offer.
When obtained, call POST /loan/{loan_id}/validate
.
Most of the time the user does not want to do this manual consent. To avoid requiring this, you can set "auto_validate": true
in your request. When setting this option, please ensure that its very explicit for the user that the loan may be automatically accepted and paid so that they won't be able to cancel it. Users can cancel the loan only before Defacto sends the money to the beneficiary, which happens 24 to 48 hours before the "to_pay_at"
date.