Fetching corporate data

1600

This guide describes how to get data for corporate bank accounts.

Fetch Account data

Once you have an entity_id you can now make calls to /data/v1/accounts/ endpoints.

Accounts Call & Response:

curl -X POST 'https://sandbox.leantech.me/data/v1/accounts' \
    --header 'Content-Type: application/json' \
    --header 'lean-app-token: YOUR_APP_TOKEN' \
    --data-raw '{ 
      "entity_id": "f08fb010-878f-407a-9ac2-a7840fb56185",
      "end_user_id": "3d586d40-04d9-4657-80b7-65bb8cce1e9a"
    }'
{
  "status": "OK",
  "payload": {
    "accounts": [
      {
          "account_id": "3d586d40-04d9-4657-80b7-65bb8cce1e9a",
          "name": "Mockbank1 Checkings Account",
          "currency_code": "SAR",
          "type": "Checkings",
          "iban": "SA03 8000 0000 6080 1016 7519",
          "bank_identifier": "LEANMB1"
      }, {
          "account_id": "3e9e4289-9e4f-480f-af68-3181cb35218e",
          "name": "Mockbank1 Savings Account",
          "currency_code": "SAR",
          "type": "Savings",
          "iban": "SA03 8000 0000 6080 1635 2788",
          "bank_identifier": "LEANMB1"
      }
    ]
  }
}

After making an /accounts/ call you should save the id field from the response, as this will be used to make Balance and Transaction calls on the associated accounts.

Fetch Balance and Transaction data

Once you have an account_id for a specific account, you can now make calls for balance and transaction data.

Balance returns an overview of the cash position and type of the account.

Transactions returns an array of transaction objects, you can also request for this to be returned with categorization with the insights: true flag.

Balance Call & Response:

curl -X POST 'https://sandbox.leantech.me/v1/balance' \
    --header 'Content-Type: application/json' \
    --header 'lean-app-token: YOUR_APP_TOKEN' \
    --data-raw '{
        "entity_id": "f08fb010-878f-407a-9ac2-a7840fb56185",
        "account_id": "01bb8b3f-8462-470b-b2ed-14eb15b95fa2",
        "end_user_id": "3d586d40-04d9-4657-80b7-65bb8cce1e9a"
    }'
{
  "status": "OK",
  "payload": {
    "balance": 15035.85,
    "currency_code": "SAR",
    "account_id": "01bb8b3f-8462-470b-b2ed-14eb15b95fa2",
    "account_name": "Mockbank1 Checkings Account",
    "account_type": "Checkings"
  }
}

Transactions Call & Response:

curl -X POST 'https://sandbox.leantech.me/v1/transactions' \
  --header 'Content-Type: application/json' \
  --header 'lean-app-token: YOUR_APP_TOKEN' \
  --data-raw '{
    "entity_id": "f08fb010-878f-407a-9ac2-a7840fb56185",
    "account_id": "01bb8b3f-8462-470b-b2ed-14eb15b95fa2",
    "end_user_id": "3d586d40-04d9-4657-80b7-65bb8cce1e9a",
    "start_date": "2020-03-01",
    "end_date": "2020-03-15",
    "insights": true
  }'
{
  "status": "OK",
  "payload": {
    "transactions": [
      {
        "id": "01e39a9c-a4ff-3429-a079-968ad1bbb0a3",
        "description": "ALETIHAD CREDIT BUREAU ABU DHABI AE",
        "amount": 84685.18,
        "currency_code": "AED",
        "pending": false,
        "timestamp": "2021-01-31T00:00:00Z",
        "insights": {
          "description_cleansed": "ALETIHAD CREDIT BUREAU ABU DHABI AE",
          "category": "LOANS_AND_INVESTMENTS",
          "category_confidence": 0.99,
          "type": "TRANSFER",
          "type_confidence": 1
        }
      }
    ]
  }
}