Tutorial: Financial statement OCR

The following steps are only applicable to the Financial statement.

This API helps you to upload Financial institutions' PDFs & passbooks and parse the data.

Brick is currently offering two environments:

  • Sandbox, a sandbox environment with test data perfect for test and development phases.
  • Production, a live environment used in production with real connections to institutions.

To generate your keys for each environment, have a look to our guide to get your Brick API keys or Sign Up now!

You follow this tutorial along side a Video tutorial we made for better understanding.

Our new version of APIs(v2) is callback-based APIs, So if you have not set up a callback URL till now, Please set it from brick dashboard.

📘

In the following examples, we will use the sandbox environment. Change the base URL to https://api.onebrick.com/v2 for using the APIs in production.

Step 1: Generate a JWT bearer token (Public access token)

Data product

Use public token API with sandbox API keys with client_id & client_secret to get a JWT(JSON Web Token). This JWT or what we call a public access token can be used to launch the Brick widget and access the institution list.

curl --request GET \
     --url https://sandbox.onebrick.io/v2/data/auth/token \
     --header 'Accept: application/json' \
     --header 'password: client_secret' \
     --header 'username: client_id'

This API gives give you a JWT/public access token that is only valid for the next 30 minutes and which can be used to launch the Brick Widget and access Brick APIs. It can be used multiple times in 30 minutes.

{
  "status": 200,
  "data": {
    "message": "We are successfully able to fetch data",
    "access_token": "token",
    "primary_color": "#97FF00",
    "expiry": 1654681846751
  },
  "metadata": {
    "source": {{API/Widget/Dashboard/SDK/Portal}},
    "entity": "AUTH"
  },
  "error": null
}

Step 2: Launch Brick Widget (Option 1)

Use the JWT/public-access-token to launch the brick widget in your application and let your users upload the financial statements with your application.
To launch the brick UI widget you need to construct the URL in the following format-
https://cdn.onebrick.io/sandbox-widget/v1/?accessToken=public-sandbox-access-token&user_id=userid

Notes: A unique user_id will be useful for you to map the final responses to your end-user at the time of receiving a notification back from Brick.

Choose the Institution (Financial statement digitization only available for selected institutions)

774

From the above picture, you can choose one institution that you want to connect with

Choose the method of verification

768

Choose manual verification so that you can upload the financial statements images/documents. Please note that manual verification is only available on the selected institutions.

Upload your document

We accept the financial statements in both passbook and monthly statement format. PDF, PNG , XLS, or JPEG is acceptable with a maximum size of 5 MB / file.

780 778

Step 3: Notification to webhook URL / Email

Once the digitization process is done, Brick will notify your platform with callbacks that will notify you of the responses of the document digitization. You need to register your Webhook URL to Brick from the Brick Developer Dashboard.

If there is no Webhook URL present, then the responses will be sent to Email (attached as CSV) automatically. The email will be the same as the one registered with your brick account.

{
    “status”: 200,
    “message”: “OK”,
    “data”: {
        “id”: “id”,
        “userId”: “userid”,
        “account”: {
            “accountHolderVerified” : "true",
            “accountNumberVerified” : "true",
            “accountId”: “UarXg4ad/81344wJF8xthY==“,
            “accountHolder”: “JOHN DOE”,
            “accountHolderVerification” : “JOHN DOE”,  
            “accountNumber”: “1551110757891",
            “bankName”: “BCA”
        },
        “transaction”: [
            {
                “reference_id”: 123,
                “amount”: 600000.0,
                “date”: “2020-06-29”,
                “description”: “ATM-MP SA CWD XMD S1AW1MJK /7774759936/ATM-RCOASIAAFRK 4616993200225278 RCOASIAAFRK”,
                “status”: “CONFIRMED”,
                “direction”: “out”
            },
            {
                “reference_id”: 1234,
                “amount”: 10000.0,
                “date”: “2020-06-29”,
                “description”: “CREDIT Bunga”,
                “status”: “CONFIRMED”,
                “direction”: “in”
            }
        ],
        “historyBalance”: {
            “beginningBalance”: 500000.0,
            “endingBalance”: 1000000.0,
            “dateFrom”: “2020-06-01",
            “dateTo”: “2020-06-30",
        }
    }
}

Notes: The beginning & ending balance is only applicable for Financial institution statements format