Tutorial: Create an Account

Creating an Account with MBanq API

This tutorial will walk you through the process of creating an account using the MBanq APIs.

Prerequisites:

  • Before proceeding, ensure that you have already created:
    • a client
    • a verified and active user
    • a product (like a savings account or checking account)

Now, let's create an account with the following steps:

📘

API References for Endpoints in this tutorial:

Step 1: Make a POST Request to the Create Account End Point

To create a new account application, send a POST request to the MBanq API with the necessary data.

This table provides an explanation of the parameters used in the given cURL statement for creating an account for a client on your platform. Each parameter has a corresponding value type and a definition that clarifies its purpose in the account creation process.

ParameterValue TypeDefinition
clientIdIntegerThe ID of the client (customer) for whom the account is being created.
productIdIntegerThe ID of the product associated with the account.
localeStringThe locale of the account, specifying the language used.
dateFormatStringThe date format used for displaying dates in the account.
submittedOnDateStringThe date on which the application was submitted.

Step 2: Handle the Response

After making the POST request, you will receive a response from the API indicating the success or failure of the account creation.

Here's an example of the response:

{
  "officeId": 1,
  "clientId": 12,
  "savingsId": 15,
  "resourceId": 15,
  "changes": {
    "status": "ACTIVE",
    "locale": "en",
    "dateFormat": "dd MMMM yyyy",
    "activatedOnDate": "22 June 2023"
  }
}

This table provides an overview of the parameters used in the given code snippet for creating a savings account. Each parameter has a corresponding value type and a definition that clarifies its purpose in the account creation process.

ParameterValue TypeDefinition
officeIdIntegerThe ID of the office associated with the account creation.
clientIdIntegerThe ID of the client (customer) for whom the account is being created.
savingsIdIntegerThe ID of the savings account associated with the client.
resourceIdIntegerThe ID of the resource associated with the account creation.
changes.statusStringThe status of the account.
changes.localeStringThe locale of the account, specifying the language used.
changes.dateFormatStringThe date format used for displaying dates in the account.
changes.activatedOnDateStringThe activation date of the account in the format "dd MMMM yyyy". It specifies when the account was activated.

Here's an example of how to handle the response using JavaScript:

Understanding the Code

In the code snippet, we set the required parameters for creating an account. These parameters include the client ID, date format, locale, product ID, and the date on which the application was submitted. Adjust these values based on your specific scenario.

Make sure to replace the authorization token (Bearer 5d8448ab-e60b-4d84-95a8-23aa45772b9d) and the tenant ID (01CFYSCBVZKJHF0X34E3JY1PTT) with your actual credentials.

var data = JSON.stringify({
  clientId: 13,
  dateFormat: "dd MMMM yyyy",
  locale: "en",
  productId: 1,
  submittedOnDate: "18 June 2018",
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "{{ apiDomain }}/v1/savingsaccounts");
xhr.setRequestHeader(
  "authorization",
  "Bearer 5d8448ab-e60b-4d84-95a8-23aa45772b9d"
);
xhr.setRequestHeader("tenantid", "01CFYSCBVZKJHF0X34E3JY1PTT");
xhr.setRequestHeader("content-type", "application/json");

xhr.send(data);

Upon executing the code, you will receive a response from the API, which you can handle accordingly in your application logic.