Tutorial: Financial statement OCR

📘

Get all of the data points available from multiple Financial institution Statements supported, including data points that are available on Account APIs, Transaction APIs, Transaction & Summary Balance APIs.

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.

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

Use your Sandbox API keys viz. a ClientID & ClientSecret with the generate public token api 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 institution list.

curl -u Client ID:Client Secret https://sandbox.onebrick.io/v1/auth/token
{
    "status": 200,
    "message": "OK",
    "data": {
        "access_token": "public-sandbox-b70bcf83-87a1-4f2c-8f2a-16d48021413a"
    }
}

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 2: API Connection (Option 2)

You can also upload the file through the API (POST -> form-data) directly

Key ParameterData TypeDescription
user_idstringunique ID for each user
filesfileThe financial statement* file, PDF, PNG , XLS, or JPEG with a maximum size of 5 MB / file.


notes: The documents should include the page where the account name and number is clearly stated

If the upload process is successful, you will receive the success responses.

{
    "status": 200,
    "message": "OK",
    "data": {
        "id": "f97be126-5522-4716-b796-2cbc83fb9ee4",
        "fileNames": [
            "BNI - 4.pdf"
        ],
        "user_id": "Test"
    }
}

After you get this response, the digitization process will be done in parallel in the background. Once the process is done, you will be notified to your email or your webhook URL (Please refer to step 3)

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