Point-of-sale financing (either in store or remote) is initiated by the merchant: the seller initiates the financing application by selecting a product (consumer loan, credit line, etc.) and setting the conditions (loan principal, term, instalment amount, etc.). After introducing the customer’s contact information, the financing application is generated and the link to the digital onboarding is sent off to the customer. The customer completes the onboarding process, either in-store or remotely, and the financing application is distributed amongst Nemuru’s pool of lenders, thus maximising the approval rate.
To create a financing invitation (Create loan) it is necessary to provide three types of information: loan conditions, contact details about the customer (borrower), and asset details. Prior to this, it might be necessary to check the available loan conditions for an specific amount and term. Your agent id is also required, which you can obtain from the Get agent profile use case, after having obtained an access token using the Login use case. Once a loan is created, it is possible to check its details and status in a couple of ways: (1) get the loan details on demand by calling the Get loan by id use case, or (2) Create a webhook to get notifications about all loan status changes automatically If needed, you can use the Upload documentation use case to upload files and documents for an specific loan.
To sum up, this is the list of requests that are typically needed for integrating Nemuru for in-store / remote financing:
- Login
- Get agent profile (optional, if you already know your agent id)
- Get loan conditions (optional, if you already know your pricings)
- Create loan
- Upload documentation (optional, if documentation upload by the merchant is not needed)
- Get loan by id (optional, if you have a webhook already created)
- Create a webhook (optional, if you don't use webhooks)
Nemuru's APIs use HTTP status codes together with error objects to handle errors. When an API call fails, the response will include a 4xx or 5xx status code together with a response body.
The error object MUST contain an exception
and an error
property. ONLY in case of 400 Bad Request error, the schema_errors
property will also be present:
- The exception is a path referring to the unique and enumerable error that occurred in Nemuru. The intent of this property is that it is machine readable and so that you can act properly on its value.
- The error is the message that accompanies Nemuru's exception. It's value is a human readable message to aid in debugging.
- The schema_errors returns an object indicating invalid fields in the request. This property is ONLY available when an API call returns a status 400 Bad Request —the request data do not comply with the scheme validation.
Examples
A few examples of error response bodies:
404 Not Found
{
"status": "ko",
"exception": "Nemuru\\Module\\Financial\\Domain\\Loan\\Exception\\LoanNotFoundByIdException",
"error": "\\Loan\\ with id \\c7d07661-8644-425e-91e0-afdcaef6f8d9\\ not found"
}
Status codes
Code | Label | Description |
---|---|---|
200 | OK | The target resource was successfully found. |
201 | Created | The target resource was successfully created. |
204 | No content | The target resource was successfully modified. |
400 | Bad Request | Some input property does not meet the expected validation. |
401 | Unauthorized | The access token used has expired or is invalid. |
403 | Forbidden | The user’s credentials are not authorized to consume the target service. |
404 | Not Found | The target resource was not found. |
409 | Conflict | There was a conflict with the current state of the target resource. |
410 | Gone | The target resource is no longer available. |
500 | Internal Error | The server encountered an unexpected condition that prevented it from fulfilling the request. |
502 | Bad Gateway Error | The service received an invalid response from the upstream server. |
504 | Gateway Timeout | The service did not get a response in time from the upstream server that it needed in order to complete the request. |
Login
Retrieve an access token with your username and password, which will be needed in following requests.
Request Body schema: application/json
Login
username required | string Example: "username@email.com" Username |
password required | string Example: "12345" Password |
Responses
Request samples
- Payload
{- "username": "username@email.com",
- "password": "12345"
}
Response samples
- 200
{- "token_type": "Bearer",
- "access_token": "1857fdb2-c746-44f9-88a8-507a855fe920",
- "refresh_token": "f9131f93-5e64-461e-8493-0fb8cb76f31d",
- "expires_in": 2678400
}
Get agent profile
Gets the corresponding agent associated to the credentials through the access token from the header.
The
id
that appears in the payload of the response corresponds to the agent id linked to the access token from which the request was sent. Thisid
can be used to create loans in the name of this agent.
header Parameters
Authorization required | string The Authorization header must include |
Content-Type | string Default: application/json Content-Type |
Responses
Response samples
- 200
{- "status": "ok",
- "payload": {
- "created_at": "2020-02-04T12:52:15+00:00",
- "updated_at": "2020-02-04T12:52:15+00:00",
- "id": "23f4dd4f-79aa-4ed2-ad7d-5c657eb4c7f7",
- "name": "Agent 1",
- "username": "acme@acme.com",
- "allowed_asset_types": [
- "home_improvement",
- "auto"
]
}, - "identifier": "urn:nemuru:api_gateway:external:v2:agent:23f4dd4f-79aa-4ed2-ad7d-5c657eb4c7f7"
}
Create loan
Creates a Loan.
The request must provide a loan id (id
), the corresponding agent id (agent_id
), and three blocks of information:
- Loan conditions: currency, term, principal, program, insurance
- Borrower: email, full name, phone number
- Asset: type, description, value
Depending on the type of asset, the details
within the asset
substructure will have more or less data points.
Note that the loan principal amount must be equal or lower than the asset value. For example, financing a car valued at 15,000€, then the loan principal cannot exceed the price of the car.
header Parameters
Authorization required | string The Authorization header must include |
Content-Type | string Default: application/json Content-Type |
Request Body schema: application/json
id required | string <uuid> Example: "e7c52ad3-0473-4fbc-bc36-7eb755b1c18d" The Loan id |
agent_id required | string <uuid> Example: "23f4dd4f-79aa-4ed2-ad7d-5c657eb4c7f7" The Agent id |
currency required | string Example: "EUR" The Loan currency |
term required | number Example: 30 The Loan term in months (integer) |
principal required | number Example: 5000 The Loan principal (float) |
annual_interest | number Example: 0.091 The Loan annual interest rate (float, not percentage). No need to provide the annual interest rate unless previously agreed with Nemuru. |
program required | string Enum: "free_program" "zero_program" Example: "free_program" The Loan program reference. |
object The Borrower setup fee | |
object The Insurance details, associated with the Loan | |
required | object The Borrower details |
asset_type required | string The Asset type |
required | object The Education asset |
Responses
Request samples
- Payload
{- "id": "e7c52ad3-0473-4fbc-bc36-7eb755b1c18d",
- "agent_id": "23f4dd4f-79aa-4ed2-ad7d-5c657eb4c7f7",
- "currency": "EUR",
- "term": 30,
- "principal": 5000,
- "annual_interest": 0.091,
- "program": "free_program",
- "setup_fee": {
- "amount": 125,
- "type": "type_upfront"
}, - "insurance": {
- "description": "seguro_vida",
- "is_financed": false
}, - "borrower": {
- "email": "john.doe@gmail.com",
- "first_name": "John",
- "last_name": "Doe",
- "phone_number": "+34601000001"
}, - "asset_type": "education",
- "asset": {
- "description": "Máster en Data Science",
- "value": 9000
}
}
Response samples
- 201
- 400
- 401
- 409
- 500
{ }
Loan actions
Perform a variety of actions on the Loan by indicating the action (op) in the request body.
header Parameters
Authorization required | string The Authorization header must include |
Content-Type | string Default: application/json Content-Type |
Request Body schema: application/json
id required | string <uuid> Example: "e7c52ad3-0473-4fbc-bc36-7eb755b1c18d" The Loan id |
op required | string <string> Enum: "cancelLoan" "approveLoan" "sendContract" "signContract" "confirmLoan" "payLoan" Example: "confirmLoan" The desired Loan management operation. Some of these operations may requiere additional information to be included in the body of the request (tap the blue buttons above to switch between different operations and use the right-hand side Request samples examples to switch between different examples).
|
Responses
Request samples
- Payload
{- "id": "e7c52ad3-0473-4fbc-bc36-7eb755b1c18d",
- "op": "cancelLoan"
}
Response samples
- 204
- 400
- 401
- 404
- 409
- 500
{ }
Get loan by id
Get loan by id (loanId
).
The loan
status
represents the current status of the loan.
path Parameters
loanId required | string <uuid> Example: e7c52ad3-0473-4fbc-bc36-7eb755b1c18d Loan Id |
header Parameters
Authorization required | string The Authorization header must include |
Content-Type | string Default: application/json Content-Type |
Responses
Response samples
- 200
- 400
- 401
- 404
- 500
{- "status": "ok",
- "payload": {
- "created_at": "2020-03-23T12:33:55+00:00",
- "updated_at": "2020-03-23T12:33:55+00:00",
- "id": "e7c52ad3-0473-4fbc-bc36-7eb755b1c18d",
- "status": "status_initial",
- "loan_conditions": {
- "currency": "EUR",
- "due_date": 1,
- "program": "free_program",
- "merchant_discount_percentage": 0,
- "annual_interest": 0.091,
- "principal": 5000,
- "setup_fee": 0,
- "term": 30,
- "number_of_payments": 30,
- "tae": 0.095,
- "total_interest_paid": 609.15,
- "total_amount_paid": 5609.15,
- "user_defined_quota": 186.97
}, - "borrower": {
- "email": "john.doe@gmail.com",
- "first_name": "John",
- "last_name": "Doe",
- "phone_number": "+34601000001",
- "expires_on": "2020-06-18T00:00:00+00:00"
}, - "asset": {
- "description": "Reformas de mi casa",
- "value": 10000
}
}, - "identifier": "urn:nemuru:api_gateway:external:v2:loan:e7c52ad3-0473-4fbc-bc36-7eb755b1c18d"
}
Get loan conditions
Gets the loan conditions given an agent id and loan parameters (currency, term, and principal).
This operation does not create a loan, it only simulates and returns the loan conditions available. If the agent (= merchant) has more than one loan program to offer (e.g. 0% APR program, Standard program), the loan conditions will be simulated for each program as long as the input parameters find an available pricing.
query Parameters
agent_id required | string Example: agent_id=9286898b-7bb7-4885-9a9b-94c4e880378b The Agent id |
currency required | string Example: currency=EUR The Loan currrency |
term required | number Example: term=30 The Loan term defined by the user |
principal required | number Example: principal=5000 The Loan principal amount |
header Parameters
Authorization required | string The Authorization header must include |
Content-Type | string Default: application/json Content-Type |
Responses
Response samples
- 200
- 400
- 401
- 404
- 500
{- "status": "ok",
- "data": [
- {
- "created_at": "2020-06-18T00:00:00+00:00",
- "updated_at": "2020-06-18T00:00:00+00:00",
- "loan_conditions": {
- "currency": "EUR",
- "due_date": 1,
- "program": "zero_program",
- "merchant_discount_percentage": 0.099,
- "annual_interest": 0,
- "principal": 5000,
- "setup_fee": 0,
- "term": 30,
- "number_of_payments": 30,
- "tae": 0,
- "total_interest_paid": 0,
- "total_amount_paid": 5000,
- "user_defined_quota": 166.67
}
}, - {
- "created_at": "2020-06-18T00:00:00+00:00",
- "updated_at": "2020-06-18T00:00:00+00:00",
- "loan_conditions": {
- "currency": "EUR",
- "due_date": 1,
- "program": "free_program",
- "merchant_discount_percentage": 0,
- "annual_interest": 0.091,
- "principal": 5000,
- "setup_fee": 0,
- "term": 30,
- "number_of_payments": 30,
- "tae": 0.095,
- "total_interest_paid": 609.15,
- "total_amount_paid": 5609.15,
- "user_defined_quota": 186.97
}
}
]
}
A Webhook (also called a web callback or HTTP push API) is a way for an app to provide other applications with real-time information. A webhook delivers data to other applications as it happens, meaning you get data immediately.
Webhooks are an effective way to get information as it happens, rather than continually polling for that data.
State
Webhooks can be enabled or disabled. By default, webhooks are always enabled.
- Enabled:
1
- Disabled:
2
Client
The notification can be sent to an email address (email
) or posted to an endpoint (callback
).
- Email:
email
- Callback:
callback
Callbacks
In case the response was a callback, the payload for each type of event would vary:
// loan_steps
{
"id": "e7c52ad3-0473-4fbc-bc36-7eb755b1c18d",
"event": "loan_steps",
"step": "status_opened",
"triggered_at": "2020-06-18T00:00:00+00:00"
}
where:
id
: the loan idevent
: the event name (loan_steps
by default)triggered_at
: timestamp of the event
Loan steps
Step | Description |
---|---|
status_initial |
Agent sends loan proposal to borrower |
status_opened |
Borrower opens the loan invitation |
status_kyc_set |
Borrower accepts T&C and finishes KYC |
status_income_set |
Borrower income is obtained either through Bank Reader or declared manually |
status_professional_details_set |
Borrower submits professional details |
status_risk_set |
Origination risk values are set |
status_analysing |
Borrower finishes onboardin. Loan applications sent to lenders |
status_lender_has_been_selected |
Lender accepts the loan application (pre-approved) |
status_contract_sent |
Contract is sent to borrower |
status_contract_signed |
Borrower signs the contract |
status_docs_approved |
Documentation evaluation by lender finishes successfully and sends transfer order |
status_active_trial |
Funds are sent to merchant (money out) |
status_active |
14-day grace period finishes and loan is active |
status_desisted |
Borrower desists the loan |
status_denied |
Loan application is denied by lenders |
status_expired |
Loan invitation is expired (not finished before 30 days since status_initial) |
status_cancelled |
Merchant cancels the loan proposal |
status_cancelled_test |
Loan proposal is cancelled as it is a test |
status_ended |
Loan is fully paid by the borrower |
Authentication
Webhook callbacks can use multiple authentication methods. The authentication information has to be provided by you at the moment of creating the webhook.
No authentication
Authorization header: callbacks will include a static authorization token in the header, tipically used for basic authentication applications. Independent of the authentication scheme, the full header has to be provided by you. For example, if you wish to apply a Basic Authorization header, you should provide
'authorization_header': 'Basic bG9sOnNlY3VyZQ=='
and'content_type': 'application/json'
.OAuth 2.0: callbacks will use an OAuth 2.0 authentication scheme. For this, a specific user should be created in your resource server and it will be necessary for you to provide the
url
(= token url),client_id
,client_secret
,username
, andpassword
of the client, at the moment of creating the webhook.
Create webhook
Create a webhook to subscribe to a specific event.
Every time there is an event triggered, you will receive a notification that follows this request.
For example, if you subscribe to loan_steps
event, you will get a notification for any loan status change.
Request Body schema: application/json
client required | string Enum: "callback" "email" Example: "callback" The type of client (i.e. the type of notification to the Event under subscription) |
event required | string Value: "loan_steps" Example: "loan_steps" The name of the Event under subscription |
target required | string Example: "https://www.your_web_url.com/endpoint" The url endpoint or email address to send the notification to |
Responses
Request samples
- Payload
{- "client": "callback",
- "event": "loan_steps",
}
Response samples
- 201
Get webhooks
Get the list of webhooks you are currently subscribed to (associated to the credentials through the access token from the header).
Responses
Response samples
- 200
{- "status": "ok",
- "data": [
- {
- "created_at": "2020-06-18T00:00:00+00:00",
- "updated_at": "2020-06-18T00:00:00+00:00",
- "id": "408f340c-0f40-4e79-92e9-6af717d4d936",
- "client": "callback",
- "event": "loan_steps",
- "state": 1
}
]
}
Response samples
- 200
{- "status": "ok",
- "payload": [
- {
- "created_at": "2020-06-18T00:00:00+00:00",
- "updated_at": "2020-06-18T00:00:00+00:00",
- "id": "408f340c-0f40-4e79-92e9-6af717d4d936",
- "client": "callback",
- "event": "loan_steps",
- "state": 1
}
], - "identifier": "urn:nemuru:sync_and_integration:webhook:408f340c-0f40-4e79-92e9-6af717d4d936"
}
Update webhook by id
Update a webhook by id (specified within the query parameters id
).
Request Body schema: application/json
client required | string Enum: "callback" "email" Example: "callback" The type of client (i.e. the type of notification to the Event under subscription) |
event required | string Value: "loan_steps" Example: "loan_steps" The name of the Event under subscription |
target required | string Example: "https://www.your_web_url.com/endpoint" The url endpoint or email address to send the notification to |
Responses
Request samples
- Payload
{- "client": "callback",
- "event": "loan_steps",
}
Response samples
- 204
{ }
Upload files
Upload files for a specific loan (through the loanId
in the query parameters).
Files must be encoded in base64 and included in the request via the
data
field. It is possible to upload more than one file per request, but the maximum size of the request must not exceed 20 megabytes. If not possible, consider sending multiple requests, or contact us.
Request Body schema: application/json
required | Array of objects The list of Files | ||||||
Array
|
Responses
Request samples
- Payload
{- "files": [
- {
- "name": "dni-front-borrower.jpeg",
- "type": "document_id_front",
- "data": "aGVsbG8gd29ybGQh"
}
]
}
Response samples
- 201
{ }
Get files
Get the list of all files associated to a specific loan (through the loanId
in the query parameters).
Responses
Response samples
- 200
{- "status": "ok",
- "data": [
- {
- "name": "1c5d6380-13c3-44c0-930e-9ea9f6090559",
- "type": "document_id_front",
- "data": "/document_id_front/1c5d6380-13c3-44c0-930e-9ea9f6090559.jpeg"
}, - {
- "name": "1c5d6380-13c3-44c0-930e-9ea9f6090559",
- "type": "document_id_back",
- "data": "/document_id_back/1c5d6380-13c3-44c0-930e-9ea9f6090559.jpeg"
}
]
}