Test Brick APIs with cURL - Old

In this section, You will learn to use Brick APIs via Curl method.

Brick is currently offering two environments:

  • Sandbox - The sandbox environment should use for development and testing purposes.
  • Production - The production environment should be used for connection with real accounts.

Please feel free to register yourself if haven't from here.

📘

API Environment

In the below examples, we will use the sandbox environment. Change the base URL to https://api.onebrick.io in each example to switch to 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)

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.

Data Product

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

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
}

Payment Product

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

This API gives give you a JWT/public access token that is only valid for use One time, After using it once, public_access_token for payments will expire and you have to regenerate this.

{
    "status": 200,
    "error": null,
    "metaData": {
        "source": "API",
        "entity": "Payment"
    },
    "data": {
        "message": "Access token is valid for 5 minutes and can use one time only",
        "accessToken": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxODQ3IiwiY29sb3VyIjoiIzMzMzMzMyIsInJvbGUiOlsiVVNFUiJdLCJuYW1lIjoiQnJpY2siLCJpc3MiOiJCcmljayIsImV4cCI6MTY1NzA4ODgzOSwiaWF0IjoxNjU3MDg4NTM5LCJqdGkiOiIyZTZmZTIwOS0yN2ZiLTQ0MjctOTI5Mi1lNThiYzMyMDUyMzkiLCJ0cyI6MTY1NzA4ODUzOTg1N30.gexikMhPVvS8z2j9muHhSAZb_TrkUAn4BDWIvOJLZDE",
        "issuedAt": "2022-07-06T13:22:19.857147",
        "expiresAt": "2022-07-06T13:27:19.857147"
    }
}

Step 2: List all supported institutions

You can use this JWT/public access token to view the list of institutions currently supported by Brick.

curl --request GET \
     --url https://sandbox.onebrick.io/v2/data/institution/list \
     --header 'Accept: application/json' \
     --header 'public_access_token: public_access_token'

Where [JWT-public-access-token] is the public access token/JWT generated in the previous step which needs to be passed as the Bearer token in the Authorization header.

The API responds with the institution's list currently supported by Brick.

Step 3: 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.

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

Step 4: Retrieve Financial Institution account

Retrieve List of all accounts for this user

Using the previously created user-access-token in Step 3 and public_access_token in Step 1, We can now retrieve the information about different financial institution accounts connected by this user.

curl --request GET \
     --url https://sandbox.onebrick.io/v2/data/account/list \
     --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 financial Institution connection through the widget which needs to be passed in headers as user_access_token.

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.

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

{
  "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
}
{
  "data": {
    "method": "GET",
    "api": "/v2/data/account/list",
    "message": "We are able to fetch a list of accounts of end-users",
    "job_id": "MaBkJUww03291282",
    "count": "1",
    "last_updated_at": "1662103296909",
    "session": "valid",
    "account_list": [
        {
        "account_id": "XH3c7dtoskIqAmEbwHAM7Q==",
        "account_holder": "ABC",
        "account_number": "88XXXXXX6",
        "type": "Savings",
        "currency": "IDR"
        "balances": {
          "available": 2195258.5,
          "current": 2195258.5,
          "limit": null
        },
        {
        "account_id": "XH3c7dtoskIqAmEbwHAM7Q==",
        "account_holder": "XYZ ",
        "account_number": "88XXXXXX7",
        "type": "Savings",
        "currency": "IDR"
          "balances": {
          "available": 2111258.5,
          "current": 195258.5,
          "limit": null
        },
      }
    ]
  },
  "metadata": {
    "entity": "Data",
    "source": "API"
  },
  "error": null,
  "status": 200
}

Retrieve details of a particular Financial Institution account

Using the account_id retrieved from the previous API- accounts list, You can get in-depth details about the account including any identifying information that's available on the account.

curl --request GET \
     --url 'https://sandbox.onebrick.io/v2/data/account/detail?account_id=account_id' \
     --header 'Accept: application/json' \
     --header 'public_access_token: public_access_toke' \
     --header 'user-access-token: user_access_token'

Where [user-access-token] is the access token generated after successful Financial institution connection through the widget which needs to be passed as the Bearer token in the Authorization header. And accountId is the identification of the account for which you want the details.

Where [user-access-token] is the access token generated after a successful financial Institution connection through the widget which needs to be passed as the user_access_token and account_id is the identification of the account for which you want the details.

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.

The API responds with details of the account associated with the account_id.

{
  "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
}
{
  "data": {
    "method": "GET",
    "api": "/v2/data/account/detail",
    "job_id": "GYGJ4Tbb03371498",
    "last_updated_at": "1662103375848",
    "message": "We are able to fetch account details for you",
    "session": "valid",
    "account_details": {
      "account_holder": "Taufic Hidayat",
      "account_id": "XH3c7dtoskIqAmEbwHAM7Q==",
      "account_number": "8831355336",
      "address": null,
      "email": null,
      "ktp_number": null,
      "phone_number": null,
      "type": "Savings",
      "balances": {
        "available": 2195258.5,
        "current": 2195258.5,
        "limit": null
      },
      "currency": "IDR"
    }
  },
  "metadata": {
    "entity": "Data",
    "source": "API"
  },
  "error": null,
  "status": 200
}

Step 5: Retrieve transactions

Using the previously generated user-access-token in step 3 and public_access_token in step 1, We can now retrieve all transactions for a user from all his financial institution account under the login used with the brick widget.

curl --request GET \
     --url 'https://sandbox.onebrick.io/v2/data/transaction/list?from=10-03-2020&to=10-04-2020' \
     --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 Financial institution connection through the widget which needs to be passed as the headers.

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.

The API responds with rich transaction data of all the accounts associated with the user under his login.

{
  "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
}
{
  "data": {
    "method": "GET",
    "api": "/v2/data/transaction/list",
    "job_id": "PRwR0rlr03400817",
    "message": "We are able to fetch transactions for you",
    "count": "5",
    "last_updated_at": 1662103406871,
    "session": "valid",
    "transaction_list": [
      {
        "id": 0,
        "account_id": "XH3c7dtoskIqAmEbwHAM7Q==",
        "account_number": "8831355336",
        "account_currency": "IDR",
        "institution_id": 2,
        "merchant_id": 0,
        "outlet_outlet_id": 0,
        "location_city_id": 0,
        "location_country_id": 0,
        "date": "2022-08-12",
        "amount": 10001,
        "description": "TRSF E-BANKING CR 1208/FTSCY/WS95051 10001.00 BRICK TEKNOLOGI IN",
        "status": "CONFIRMED",
        "direction": "in",
        "reference_id": "XH3c7dtoskIqAmEbwHAM7Q==-20220812-1",
        "transaction_type": "Savings",
        "category": {
          "category_id": 5,
          "category_name": "transfer-in ",
          "classification_group_id": 26,
          "classification_group": "account transfer-in",
          "classification_subgroup_id": 92,
          "classification_subgroup": "others account transfer-in"
        }
      },
      {
        "id": 0,
        "account_id": "XH3c7dtoskIqAmEbwHAM7Q==",
        "account_number": "8831355336",
        "account_currency": "IDR",
        "institution_id": 2,
        "merchant_id": 0,
        "outlet_outlet_id": 0,
        "location_city_id": 0,
        "location_country_id": 0,
        "date": "2022-08-12",
        "amount": 10002,
        "description": "TRSF E-BANKING CR 1208/FTSCY/WS95051 10002.00 BRICK TEKNOLOGI IN",
        "status": "CONFIRMED",
        "direction": "in",
        "reference_id": "XH3c7dtoskIqAmEbwHAM7Q==-20220812-2",
        "transaction_type": "Savings",
        "category": {
          "category_id": 5,
          "category_name": "transfer-in ",
          "classification_group_id": 26,
          "classification_group": "account transfer-in",
          "classification_subgroup_id": 92,
          "classification_subgroup": "others account transfer-in"
        }
      },
      {
        "id": 0,
        "account_id": "XH3c7dtoskIqAmEbwHAM7Q==",
        "account_number": "8831355336",
        "account_currency": "IDR",
        "institution_id": 2,
        "merchant_id": 0,
        "outlet_outlet_id": 0,
        "location_city_id": 0,
        "location_country_id": 0,
        "date": "2022-08-12",
        "amount": 10000,
        "description": "TRSF E-BANKING CR 1208/FTSCY/WS95051 10000.00 BRICK TEKNOLOGI IN",
        "status": "CONFIRMED",
        "direction": "in",
        "reference_id": "XH3c7dtoskIqAmEbwHAM7Q==-20220812-3",
        "transaction_type": "Savings",
        "category": {
          "category_id": 5,
          "category_name": "transfer-in ",
          "classification_group_id": 26,
          "classification_group": "account transfer-in",
          "classification_subgroup_id": 92,
          "classification_subgroup": "others account transfer-in"
        }
      },
      {
        "id": 0,
        "account_id": "XH3c7dtoskIqAmEbwHAM7Q==",
        "account_number": "8831355336",
        "account_currency": "IDR",
        "institution_id": 2,
        "merchant_id": 0,
        "outlet_outlet_id": 0,
        "location_city_id": 0,
        "location_country_id": 0,
        "date": "2022-08-12",
        "amount": 10001,
        "description": "TRSF E-BANKING CR 1208/FTSCY/WS95051 10001.00 BRICK TEKNOLOGI IN",
        "status": "CONFIRMED",
        "direction": "in",
        "reference_id": "XH3c7dtoskIqAmEbwHAM7Q==-20220812-4",
        "transaction_type": "Savings",
        "category": {
          "category_id": 5,
          "category_name": "transfer-in ",
          "classification_group_id": 26,
          "classification_group": "account transfer-in",
          "classification_subgroup_id": 92,
          "classification_subgroup": "others account transfer-in"
        }
      },
      {
        "id": 0,
        "account_id": "XH3c7dtoskIqAmEbwHAM7Q==",
        "account_number": "8831355336",
        "account_currency": "IDR",
        "institution_id": 2,
        "merchant_id": 0,
        "outlet_outlet_id": 0,
        "location_city_id": 0,
        "location_country_id": 0,
        "date": "2022-08-19",
        "amount": 15000,
        "description": "BIAYA ADM",
        "status": "CONFIRMED",
        "direction": "out",
        "reference_id": "XH3c7dtoskIqAmEbwHAM7Q==-20220819-1",
        "transaction_type": "Savings",
        "category": {
          "category_id": 4,
          "category_name": "payment",
          "classification_group_id": 21,
          "classification_group": "fee & tax",
          "classification_subgroup_id": 63,
          "classification_subgroup": "admin fee"
        }
      }
    ]
  },
  "metadata": {
    "entity": "Data",
    "source": "API"
  },
  "error": null,
  "status": 200
}

Conclusion

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