Tutorial: View Employment Data

📘

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.io for each example to switch to production.

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"
    }
}

Response Parameter

Key ParameterData TypeDescription
access_tokenstringToken that is required to connect Brick API

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

Use the JWT/public-access-token to authenticate your user via connection to our API with these inputs in order to generate clientId and redirectRefId which will be used in the next step in order to generate user-access-token from your user's account

curl --request POST 'https://sandbox.onebrick.io/v1/auth/token' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer public_access_token' \
--data-raw '{
    "accessToken" : "public_access_token",
    "userId" : "123",
    "redirectUrl": "https://google.com/"
}'
Key ParameterData typeDescription
accessTokenStringPublic-access-token generated using your clientId and clientSecret
userIdStringEnd-user ID that will be saved in developer's database / Can be empty string ('')
redirectUrlStringURL of developer's endpoint after end-user completed login process / Can be empty string ('')

If the authentication is successful, you will receive the success responses.

{
  "status": 200,
  "message": "OK",
  "data": {
    "clientId": 100,
    "clientName": "Brick",
    "clientFullName": "Alfred Gunawan",
    "clientEmail": "[email protected]",
    "clientAlias": "Your App",
    "clientImageUrl": "https://brick-company.s3-ap-southeast-1.amazonaws.com/20210524114645_BrickIcon.png",
    "clientFavicon": "https://i.ibb.co/0ct5brm/47cb1f6a-1890-4695-b356-061dd27d3a0d-200x200-1.png",
    "redirectRefId": 1012
  }
}
Key ParameterData TypeDescription
ClientIdIntegerClient's Id in Brick Database
ClientNameStringClient's application name
ClientFullNameStringClient's registered name
ClientEmailStringClient's registered email
ClientAliasStringClient's application name/Alias
ClientImageUrlStringClient's application logo
ClientFaviconStringClient's favicon
RedirectRefIdStringId stored in Brick Database referring to client's redirect endpoint

After you get this response, you can proceed the authentication process to generate user-access-token with these inputs

curl --location --request POST 'https://sandbox.onebrick.io/v1/auth/100' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer public_access_token' \
--data-raw '{
    "institutionId": 14,
    "username": "username",
    "password": "password",
    "redirectRefId": 1012
}'
Key ParameterData TypeDescription
institutionIdIntegerUnique Institution Id for every institutions, For BPJS its 14 and for DJP it's 43
usernameStringEnd-users username of BPJS Portal or DJP Portal
passwordStringEnd-users password for BPJS portal or DJP Portal
redirectRefIdStringRedirect refId, You can generate this Id from Step 1

If the authentication is successful, you will receive the success responses along with the user-access-token

{
  "status": 200,
  "message": "OK",
  "data": {
    "accessToken": "user_access_token",
    "bankId": "14",
    "target": "https://localhost:8080/",
    "userId": "123"
  }
}
Key ParameterData TypeDescription
accessTokenIntegerAccess_token to identify end-users
bankIdStringInstitution ID of the connected account
targetStringURL of client's endpoint after end-user completed login process
userIdStringEnd-user uniqueID that should be saved for future reference

Step 3: General Information

Retrieve General Information for this user

Using the previously created user-access-token in Step 2, we can now retrieve the general information of the user.

curl https://sandbox.onebrick.io/v1/income/general
  -H 'Content-Type: application/json'
  -H 'Authorization: Bearer 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.

{
  "status": 200,
  "message": "OK",
  "data": [
    {
      "name": "John Doe",
      "ktpNumber": "3277010706920018",
      "npwpNumber": "864025555119000",
      "dob": "09-10-1989",
      "phoneNumber": "+62812345678",
      "address": "Jl sudirman",
      "gender": "LAKI-LAKI",
      "totalBalance": "25000000",
      "bpjsCards": [
        {
          "number": "15036686069",
          "balance": "12500000"
        },
        {
          "number": "15036686070",
          "balance": "12500000"
        }
      ],
      "type": "bpjs-tk",
      "institutionId": 14
    }
  ]
}

Response Parameter

Key ParameterData TypeDescription
namestringName of the user account holder
ktpNumberstringKTP number of the user
npwpNumberstringTax Identification number of the end user
(only applicable for DJP account)
dobstringDate of Birth of the account holder
phoneNumberstringUser phone number
addressstringDetail address of the user
genderstringGender of the user
totalBalancefloatTotal balance of the account holder
(only applicable for BPJS account)
BpjsCardsListList of registered BPJS card number of the end user
(only applicable for BPJS account)
NumberstringBPJS number of the end user
(only applicable for BPJS account)
BalancestringBalance of each registered BPJS card
(only applicable for BPJS account)
TypestringThe type of data source, "bpjs-tk" for BPJS account and "tax" for DJP account
InstitutionIdintegerUnique Institution Id for every institutions

Step 4: Employment Information

Retrieve Employment Information for this user

Using the previously created user-access-token in Step 2, we can now retrieve the employment information of the user.

curl https://sandbox.onebrick.io/v1/income/employment
  -H 'Content-Type: application/json'
  -H 'Authorization: Bearer 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.

{
  "status": 200,
  "message": "OK",
  "data": [
    {
      "latestSalary": "9500000",
      "companyName": "BRICK TEKNOLOGI INDONESIA",
      "latestPaymentDate": "22-12-2021",
      "workingMonth": "7",
      "bpjsCardNumber": "15036686069",
      "status": "Aktif",
      "type": "bpjs-tk",
      "institutionId": 14
    },
    {
      "latestSalary": "7660000",
      "companyName": "BERKAH BERSAMA",
      "latestPaymentDate": "09-10-2018",
      "workingMonth": "7",
      "bpjsCardNumber": "15036686070",
      "status": "Tidak Aktif",
      "type": "bpjs-tk",
      "institutionId": 14
    },
    {
      "latestSalary": "4000000",
      "companyName": "YESBOSS GROUP INDONESIA PT",
      "latestPaymentDate": "15-02-2021",
      "workingMonth": "27",
      "bpjsCardNumber": "15036686071",
      "status": "Tidak Aktif",
      "type": "bpjs-tk",
      "institutionId": 14
    }
  ]
}

Response Parameter

Key ParameterData TypeDescription
latestSalarystringLatest salary receive from the company
companyNamestringName of company where user work at
latestPaymentDatestringLatest Payment date made by company
workingMonthstring- Duration on how long user works in a company (for BPJS account)
- Tax filing year of user who works in a company (for DJP account)
bpjsCardNumberstringBPJS number of the end user
(only applicable for BPJS account)
statusstringEmployee Status (Aktif/Tidak Aktif)
(only applicable for BPJS account)
typestringThe type of data source, "bpjs-tk" for BPJS account and "tax" for DJP account
institutionIdintegerUnique Institution Id for every institutions

Step 5: Salary Information

Retrieve Salary Information for this user

Using the previously created user-access-token in Step 2, we can now retrieve the salary information of the user. It will retrieve the last 3 months salary information from each company.

curl https://sandbox.onebrick.io/v1/income/salary
  -H 'Content-Type: application/json'
  -H 'Authorization: Bearer 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.

{
  "status": 200,
  "message": "OK",
  "data": [
    {
      "companyName": "PT Brick Teknologi Indonesia",
      "monthName": "01-07-2020",
      "salary": "9500000",
      "bpjsCardNumber": "15036686069",
      "type": "bpjs-tk",
      "institutionId": 14
    },
    {
      "companyName": "PT Brick Teknologi Indonesia",
      "monthName": "01-06-2020",
      "salary": "9500000",
      "bpjsCardNumber": "15036686070",
      "type": "bpjs-tk",
      "institutionId": 14
    },
    {
      "companyName": "PT Brick Teknologi Indonesia",
      "monthName": "01-05-2020",
      "salary": "9500000",
      "bpjsCardNumber": "15036686071",
      "type": "bpjs-tk",
      "institutionId": 14
    }
  ]
}

Response Parameter

Key ParameterData TypeDescription
companyNamestringName of company where user work at
monthNamestring- Date of the payment (for BPJS account)
- Year of tax report (for DJP account)
salarystring- Amount of gross salary received Monthly (for BPJS account)
- Amount of gross salary received Annually (for DJP account)
bpjsCardNumberstringBPJS number of the end user
(only applicable for BPJS account)
typestringThe type of data source, "bpjs-tk" for BPJS account and "tax" for DJP account
institutionIdintegerUnique Institution Id for every institutions

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