Creating a customer

Overview

In order to start fetching data, you first need to create a Customer resource. For corporate bank accounts, you will also need to create an end user. This creates a relationship between your application, user and all the services they consume within Lean into a single object.

Creating a customer

To create a Customer, call the /customers/v1/ endpoint with a reference to your app_user_id. You should save the returned customer_id against your user table for future reference.

📘

Note

The app_user_id has a unique constraint, but does not need to map directly to the id of the user in your database, for example you could pass prod_usr_1246 as the app_user_id, so that you can identify that the Customer is a user of your production database. In this case, you should save both the customer_id and app_user_id against your user table for later retrieval and mapping.

Call:

curl -X POST 'https://sandbox.leantech.me/customers/v1/' \
  --header 'Content-Type: application/json' \
  --header 'lean-app-token: YOUR_APP_TOKEN' \
  --data-raw '{
    "app_user_id": "IDENTIFIER_FOR_CUSTOMER"
  }'

Response:

{
  "app_user_id": "IDENTIFIER_FOR_CUSTOMER",
  "customer_id": "f08fb010-878f-407a-9ac2-a7840fb56185"
}

Creating an end user

📘

This part is only applicable if you would like your customers to connect business bank accounts. If your customers are expected to connect personal bank accounts, then skip this step.

For corporate bank account customers, you will need to create at least one end user. Each end user corresponds to one user of the bank account that has their own access.

To create an end user you will need to call the following:

curl -X POST 'https://sandbox.leantech.me/customers/v1/end-users' \
  --header 'Content-Type: application/json' \
  --header 'lean-app-token: YOUR_APP_TOKEN' \
  --data-raw '{
    "customer_id": "f08fb010-878f-407a-9ac2-a7840fb56185",
    "reference": "IDENTIFIER_FOR_END_USER"
}'

The response will look like this:

{
  "end_user_id": "3d586d40-04d9-4657-80b7-65bb8cce1e9a",
  "customer_id": "f08fb010-878f-407a-9ac2-a7840fb56185",
  "reference": "IDENTIFIER_FOR_END_USER"
}