Tutorial: View Employment Data

The following steps are only applicable to Employment Financial institutions.

In this section, you will learn how to connect with a financial institution and access your employment data like Employee Information, General Information, and Salary Information.

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!

📘

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.

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.

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

Use the JWT/public-access-token to launch the brick widget in your application and let your users connect their financial Institution accounts 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

📘

Notice that the URL above is a newer version ( V1 ) of our Brick Widget that contained a new feature inside comparing to the old version. Currently, we still offer you our old Brick Widget where your end-user can only connect a single account at a time ( https://cdn.onebrick.io/sandbox-widget/?accessToken=public-sandbox-access-token ) until further notice.

Therefore, we encourage you to integrate and experienced our newest feature on Brick Widget as soon as possible where your end-user have the ability to connect multiple accounts/institutions in single flow.

P.S : This feature would be very helpful for you to have as much information from the connected accounts/institutions from your end-users.

There are some optional parameters that can be added to above url for customizations which can be seen here.

Read the Brick Widget Section to see in-depth integration steps.

Step 3: General Information

Retrieve General Information for this user

Using the previously created user_access_token in Step 2 and public_access_token in step 1, we can now retrieve the general information of the user.

curl --request GET \
     --url https://sandbox.onebrick.io/v2/data/income/general \
     --header 'Accept: application/json' \
     --header 'public_access_token: public_access_token' \
     --header 'user-access-token: user_access_token'

Where, [user-access-token] is the access token generated after successful institution connection through the widget which needs to be passed as the Bearer token in the Authorization header.

The API responds with accounts associated with the user who logged in using the Brick widget.

This API is Async API, So once you send the request you will receive the acceptance response synchronously and then will receive the data in your callback URL asynchronously. If you haven't set the callback URL till now, Feel free to set it from here.

{
  "status": 200,
  "data": {
    "job_id": "KVWJUrwQ78333309",
    "message": "We are processing your request and will send the data in the callback URL."
  },
  "metadata": {
    "source": {{API/Widget/Dashboard/SDK/Portal}},
    "entity": "Data"
  },
  "error": null
}
{
   "status":200,
   "data":{
      "message":"We are successfully able to fetch the data",
      "method":"GET",
      "api":"/v2/data/income/general”,   
      "job_id": "KVWJUrwQ78333309",  
      "card_details":{
         "name":"John Doe",
         "ktp_number":"3277010706920018",
         "bpjs_card_number":"15036686069",
         "dob":"09-10-1989",
         "phone_number":"+62812345678",
         "address":"Jl sudirman",
         "gender":"LAKI-LAKI",
         "total_balance":"25000000",
         "count":{{"Objects in bpjs_cards"}},
         "bpjs_cards":[
            {
               "number":"11111111",
               "balance":"12500000"
            },
            {
               "number":"11111111",
               "balance":"12500000"
            }
         ],
         "type":"bbjs-tk",
         "institution_id":12
      },
      "metadata":{
         "source":{{API/Widget/Dashboard/SDK/Portal}},
         "entity":"Data"
      },
      "error":null
   }

Step 4: Employment Information

Retrieve Employment Information for this user

Using the previously created user_access_token in Step 2 and public_access_token in step 1, we can now retrieve the general information of the user.

curl --request GET \
     --url https://sandbox.onebrick.io/v2/data/income/employment \
     --header 'Accept: application/json' \
     --header 'public_access_token: public_access_token' \
     --header 'user-access-token: user_access_token'

Where, [user-access-token] is the access token generated after a successful institution connection through the widget which needs to be passed as the Bearer token in the Authorization header.

The API responds with accounts associated with the user who logged in using the Brick widget.

This API is Async API, So once you send the request you will receive the acceptance response synchronously and then will receive the data in your callback URL asynchronously. If you haven't set the callback URL till now, Feel free to set it from here.

{
  "status": 202,
  "data": {
    "job_id": "KVWJUrwQ78333309",
    "message": "We are processing your request and will send the data in the callback URL."
  },
  "metadata": {
    "source": {{API/Widget/Dashboard/SDK/Portal}},
    "entity": "Data"
  },
  "error": null
}
{
   "status":200,
   "data":{
      "message":"We are successfully able to fetch the data",
      "method":"GET",
      "api":"/v2/data/income/employment”,   
      "job_id": "KVWJUrwQ78333309",  
      "count":{{"number_of_object_in_company data"}},
      "company_data":[
         {
            "latest_salary":"3300000",
            "company_name":"CODIGO CYBERLIN METADATA",
            "latest_payment_date":"09-10-2018",
            "working_month":"7",
            "status":"Tidak Aktif",
            "bpjs_card_number":"111111111"
         },
         {
            "latest_salary":"5000000",
            "company_name":"PT Brick Teknologi Indonesia",
            "latest_payment_date":"15-02-2021",
            "working_month":"27",
            "status":"Aktif",
            "bpjs_card_number":"111111111"
         }
      ],
      "type":"bpjs-tk"
     "institution_id":12
   },
   "metadata":{
      "source":{{API/Widget/Dashboard/SDK/Portal}},
      "entity":"Data"
   },
   "error":null
}

Step 5: Salary Information

Retrieve Salary Information for this user

Using the previously created user_access_token in Step 2 and public_access_token in step 1, we can now retrieve the general information of the user.

curl --request GET \
     --url https://sandbox.onebrick.io/v2/data/income/salary \
     --header 'Accept: application/json' \
     --header 'public_access_token: public_access_token' \
     --header 'user-access-token: user_access_token'

Where, [user-access-token] is the access token generated after successful institution connection through the widget which needs to be passed as the Bearer token in the Authorization header.

The API responds with accounts associated with the user who logged in using the Brick widget.

`This API is Async API, So once you send the request you will receive the acceptance response synchronously and then will receive the data in your callback URL asynchronously. If you haven't set the callback URL till now, Feel free to set it from here.

{
  "status": 202,
  "data": {
    "job_id": "KVWJUrwQ78333309",
    "message": "We are processing your request and will send the data in the callback URL."
  },
  "metadata": {
    "source": {{API/Widget/Dashboard/SDK/Portal}},
    "entity": "Data"
  },
  "error": null
}
{
   "status":200,
   "data":{
      "message":"We are successfully able to fetch the income",
      "method":"GET",
      "api":"/v2/data/income/salary”,   
      "job_id": "KVWJUrwQ78333309",  
      "count":{{"Count_of_objects_in_salary_data"}},
      "salary_data":[
         {
            "company_name":"PT Brick Teknologi Indonesia",
            "month_name":"01-07-2020",
            "salary":"1111",
            "bpjs_card_number":"11111111"
         },
         {
            "company_name":"PT Brick Teknologi Indonesia",
            "month_name":"01-06-2020",
            "salary":"2222",
            "bpjs_card_number":"11111111"
         },
         {
            "company_name":"PT Brick Teknologi Indonesia",
            "month_name":"01-05-2020",
            "salary":"12122",
            "bpjs_card_number":"11111111"
         }
      ],
      "type":"bbjs-tk",
      "institution_id":12  
   },
   "metadata":{
      "source":{{API/Widget/Dashboard/SDK/Portal}},
      "entity":"Data"
   },
   "error":null
}

Conclusion

Using this step by step guide you have been able to get a first preview on Brick's API for employment data and how to integrate Brick in your website or application