### Authentication and API Client Setup Source: https://developer.mastercard.com/open-finance-us/documentation/quick-start-guide Code examples demonstrating how to set up the API client, handle authentication tokens, and apply necessary headers for API requests across different languages. ```APIDOC ## Authentication and API Client Setup This section provides code examples for initializing the API client and managing authentication credentials across various programming languages. ### JavaScript (Node.js) ```javascript // Create the API client const createClient = function (openAPIClient) { // Use a promise to ensure the token has been added before sending the request return new Promise((resolve) => { let client = openAPIClient.ApiClient.instance; let authApi = new AuthenticationApi(client) // Add the Finicity-App-Key header for every request client.applyAuthToRequest = function (request) { const _end = request._end; request._end = function () { request.req.setHeader('Finicity-App-Key', APP_KEY); _end.call(request); }; return request; }; // If the token doesn't exist or has expired, refresh it let tokenPromise = function refreshToken() { return new Promise((resolve) => { if (expiry === null || expiry < new Date()) { authApi.createToken(new PartnerCredentials(PARTNER_ID, PARTNER_SECRET), (error, data, response) => { if (!error) { expiry = new Date(); token = data.token; resolve(); } }); } else { resolve() } }) } // Apply the token to the request headers tokenPromise().then(() => { client.applyAuthToRequest = function (request) { const _end = request._end; request._end = function () { request.req.setHeader('Finicity-App-Key', APP_KEY); request.req.setHeader('Finicity-App-Token', token); _end.call(request); }; return request; }; resolve(client); }) }) }; ``` ### Python ```python import datetime from functools import wraps import openapi_client from openapi_client.api.authentication_api import AuthenticationApi from openapi_client.api.connect_api import ConnectApi from openapi_client.models.connect_parameters import ConnectParameters class ApiClient(object): # Credentials partner_id = "{{partnerId}}" partner_secret = "{{partnerSecret}}" app_key = "{{appKey}}" # API Client api_client = None # Token details token = None expiry = None @classmethod def __init__(self): conf = openapi_client.Configuration() conf.verify_ssl = False conf.ssl_ca_cert = None conf.assert_hostname = False conf.cert_file = None api_client = openapi_client.ApiClient(conf) self.add_authentication(self=self, api_client=api_client) self.api_client = api_client def add_authentication(self, api_client): api_client.rest_client.request = self.authenticate(self, api_client.rest_client.request) def authenticate(self, func): @wraps(func) def call_api_function(*args, **kwargs): kwargs['headers']['Finicity-App-Key'] = self.app_key if self.expiry is None or self.expiry < datetime.datetime.now(): self.refresh_token(self) kwargs['headers']['Finicity-App-Token'] = self.token return func(*args, **kwargs) return call_api_function def refresh_token(self): current_date = datetime.datetime.now() expiry_date = current_date + datetime.timedelta(minutes=90) self.expiry = expiry_date request_body = { 'partner_id': self.partner_id, 'partner_secret': self.partner_secret } auth_response = AuthenticationApi(self.api_client).create_token(partner_credentials=request_body) self.token = auth_response.token ``` ### Java ```java var apiClient = Configuration.getDefaultApiClient(); apiClient.setDebugging(true); apiClient.setConnectTimeout(240000); apiClient.setReadTimeout(240000); apiClient.setHttpClient( apiClient.getHttpClient() .newBuilder() .addInterceptor(new FinicityAuthInterceptor("{{partnerId}}", "{{partnerSecret}}", "{{appKey}}")) .build()); ``` ### C# ```csharp var apiClient = new ApiClient("{{partnerId}}", "{{partnerSecret}}", "{{appKey}}"); ``` ``` -------------------------------- ### Generate Connect URL Source: https://developer.mastercard.com/open-finance-us/documentation/quick-start-guide Examples of how to generate a Connect URL using the Finicity API client in different programming languages. ```APIDOC ## Generate Connect URL This section demonstrates how to generate a Finicity Connect URL using the API client in various languages. ### Java ```java // Generate a Connect URL var api = new ConnectApi(apiClient); var params = new ConnectParameters() .customerId(CUSTOMER_ID) .partnerId(PARTNER_ID); var connectUrl = api.generateConnectUrl(params); var link = connectUrl.getLink(); ``` ### C# ```csharp // Generate a Connect URL var connectApi = new ConnectApi { Client = apiClient }; var connectParameters = new ConnectParameters(PartnerId, CustomerId); var connectUrl = connectApi.GenerateConnectUrl(connectParameters); var link = connectUrl.Link; ``` ### JavaScript (Node.js) ```javascript let client = await createClient(OpenAPIClient); // Generate a Connect URL let connectApi = new ConnectApi(client) let connectParameters = new ConnectParameters(CUSTOMER_ID, PARTNER_ID) let connectResponse api.generateConnectUrl(connectParameters, (error, data, response) => { connectResponse = response done(); }); done(); ``` ``` -------------------------------- ### Install Connect Web SDK with npm Source: https://developer.mastercard.com/open-finance-us/documentation/connect/integrating/sdk/web-sdk/websdk-migration Command to install the new `connect-web-sdk` package into your project using npm. ```bash npm install connect-web-sdk ``` -------------------------------- ### Install Connect Web SDK with yarn Source: https://developer.mastercard.com/open-finance-us/documentation/connect/integrating/sdk/web-sdk/websdk-migration Command to install the new `connect-web-sdk` package into your project using yarn. ```bash yarn add connect-web-sdk ``` -------------------------------- ### TypeScript Example: Launch Connect Instance Source: https://developer.mastercard.com/open-finance-us/documentation/connect/integrating/sdk/web-sdk/sdk Demonstrates how to launch a Connect instance using the Web SDK in TypeScript. This example assumes the starter code has been downloaded and 'npm i' has been run. The 'connectURL' variable needs to be populated with a generated Connect URL. ```typescript import Connect from "connect-web-sdk"; // Replace with your generated Connect URL const connectURL = "YOUR_GENERATED_CONNECT_URL"; const connectOptions = { // Optional: Add SDK parameters here, e.g., overlay, selector, node, popup, popupOptions, redirectUrl }; const connectEventHandlers = { onSuccess: (data: any) => { console.log("Success:", data); }, onExit: (data: any) => { console.log("Exit:", data); }, onError: (data: any) => { console.error("Error:", data); } }; const connect = new Connect( connectURL, connectEventHandlers, connectOptions ); connect.open(); ``` -------------------------------- ### Initialize Event Example (JSON) Source: https://developer.mastercard.com/open-finance-us/documentation/connect/integrating/sdk/events/connect-user-events An example of the Initialize event, which is sent when a user starts a Connect session. This event includes details about the customer, partner, session, and product. ```json { "action": "Initialize", "customerId": 12345, "partnerId": 67890, "timestamp": 1717132800000, "ttl": 1717140000000, "type": "full", "experience": "550e8400-e29b-41d4-a716-446655440000", "sessionId": "7035b169d6f13306a240e7291bf7eab1a28010af26b57249ca1ccf5c49a30ce4", "product": "aggregation", "borrowerType": "primary" } ``` -------------------------------- ### Generate Java API Client with OpenAPI Generator Source: https://developer.mastercard.com/open-finance-us/documentation/quick-start-guide Generates a Java client library for the Open Finance APIs using the OpenAPI Generator CLI. It requires the OpenAPI specification file ('*.yaml') and outputs the generated code to the 'api_client' directory. Ensure you have OpenAPI Generator installed. ```bash openapi-generator-cli generate -g java -i *.yaml -o api_client ``` -------------------------------- ### C# Authentication Integration for Open Finance APIs Source: https://developer.mastercard.com/open-finance-us/documentation/quick-start-guide A C# ApiClient extension that adds 'Finicity-App-Key' and 'Finicity-App-Token' headers to requests. It manages token expiration and refreshing, similar to the Java example, excluding the '/authentication' endpoint. This requires a partial ApiClient class and necessary credentials. ```csharp // Create a FinicityApiClient.cs file that extends the partial ApiClient from ApiClient.cs namespace Org.OpenAPITools.Client { public partial class ApiClient { private readonly string _partnerId; private readonly string _partnerSecret; private readonly string _appKey; private string _token; private DateTime _tokenExpiryTime; public ApiClient(string partnerId, string partnerSecret, string appKey) { _baseUrl = GlobalConfiguration.Instance.BasePath; _appKey = appKey; _partnerId = partnerId; _partnerSecret = partnerSecret; } partial void InterceptRequest(IRestRequest request) { // Always add "Finicity-App-Key" request.AddHeader("Finicity-App-Key", _appKey); var url = request.Resource; if (url.Contains("/authentication")) { // No "Finicity-App-Token" header needed for /authentication return; } if (_tokenExpiryTime < DateTime.Now) { RefreshToken(); } // Add access token to the "Finicity-App-Token" header request.AddHeader("Finicity-App-Token", _token); } private void RefreshToken() { _token = CreateToken(); _tokenExpiryTime = DateTime.Now.AddMinutes(90); } private string CreateToken() { var credentials = new PartnerCredentials(_partnerId, _partnerSecret); var authenticationApi = new AuthenticationApi { Client = this }; return authenticationApi.CreateToken(credentials).Token; } } } ``` -------------------------------- ### C#: Configure API Client and Generate Connect URL Source: https://developer.mastercard.com/open-finance-us/documentation/quick-start-guide Initializes an API client with provided partner credentials and then uses it to create a `ConnectApi` instance. This is followed by generating a Connect URL by defining `ConnectParameters` and calling `GenerateConnectUrl`. ```csharp var apiClient = new ApiClient("{{partnerId}}", "{{partnerSecret}}", "{{appKey}}"); // Generate a Connect URL var connectApi = new ConnectApi { Client = apiClient }; var connectParameters = new ConnectParameters(PartnerId, CustomerId); var connectUrl = connectApi.GenerateConnectUrl(connectParameters); var link = connectUrl.Link; ``` -------------------------------- ### Generate C# API Client with OpenAPI Generator Source: https://developer.mastercard.com/open-finance-us/documentation/quick-start-guide Generates a C# (.NET Core) client library for the Open Finance APIs using the OpenAPI Generator CLI. It takes the OpenAPI specification file ('*.yaml') as input and places the generated code in the 'api_client' directory. Requires OpenAPI Generator to be installed. ```bash openapi-generator-cli generate -g csharp-netcore -i *.yaml -o api_client ``` -------------------------------- ### Generate Python API Client with OpenAPI Generator Source: https://developer.mastercard.com/open-finance-us/documentation/quick-start-guide Generates a Python client library for the Open Finance APIs using the OpenAPI Generator CLI. It processes the OpenAPI specification ('*.yaml') and creates the client code in the 'api_client' directory. This command assumes OpenAPI Generator is installed. ```bash openapi-generator-cli generate -g python -i *.yaml -o api_client ``` -------------------------------- ### Generate Connect URL Source: https://developer.mastercard.com/open-finance-us/documentation/quick-start-guide Generates a unique URL that customers can use to start a Mastercard Open Finance Connect session. This session enables them to grant access to their financial accounts and data. ```APIDOC ## POST /connect/v2/generate ### Description Generates a Mastercard Data Connect URL to initiate a customer session for granting financial data access. ### Method POST ### Endpoint /connect/v2/generate ### Parameters #### Request Body - **partnerId** (string) - Required - The unique identifier for the partner. - **customerId** (string) - Required - The unique identifier for the customer. ### Request Example ```json { "partnerId": "{{partnerId}}", "customerId": "{{customerId}}" } ``` ### Response #### Success Response (200) - **link** (string) - The generated Connect URL for the customer session. #### Response Example ```json { "link": "https://connect2.finicity.com?customerId=1005061234&origin=url&partnerId=2423653942467&signature=91f44ab969a9c7bb2568910d92501eb13aa0b7fd4fd56314ab8ebb4f1880fa83×tamp=1651326873996&ttl=1651334073996" } ``` ``` -------------------------------- ### Java Authentication Interceptor for Open Finance APIs Source: https://developer.mastercard.com/open-finance-us/documentation/quick-start-guide An example Java OkHttp3 interceptor that automatically adds 'Finicity-App-Key' and 'Finicity-App-Token' headers to outgoing requests. It handles token refreshing and excludes the '/authentication' endpoint from token addition. Requires specific authentication details and an AuthenticationApi client. ```java // An example of okHttp3 interceptor handling Mastercard Open Finance authentication. public class OpenBankingAuthInterceptor implements Interceptor { private final AuthenticationApi authenticationApi; private final String partnerId; private final String partnerSecret; private final String appKey; private String token; private LocalDateTime tokenExpiryTime; public OpenBankingAuthInterceptor(String partnerId, String partnerSecret, String appKey) { this.partnerId = partnerId; this.partnerSecret = partnerSecret; this.appKey = appKey; this.authenticationApi = new AuthenticationApi(); } @NotNull public Response intercept(@NotNull Chain chain) throws IOException { try { // Always add "Finicity-App-Key" var request = chain.request(); var requestBuilder = request .newBuilder() .addHeader("Finicity-App-Key", this.appKey); var url = request.url().toString(); if (url.contains("/authentication")) { // No "Finicity-App-Token" header needed for /authentication return chain.proceed(requestBuilder.build()); } if (this.tokenExpiryTime == null || this.tokenExpiryTime.isBefore(LocalDateTime.now())) { this.refreshToken(); } // Add access token to the "Finicity-App-Token" header requestBuilder = requestBuilder .addHeader("Finicity-App-Token", this.token); return chain.proceed(requestBuilder.build()); } catch (Exception e) { throw new IOException(e.getMessage()); } } private void refreshToken() throws ApiException { this.token = createToken(); this.tokenExpiryTime = LocalDateTime.now().plusMinutes(90); } private String createToken() throws ApiException { return authenticationApi.createToken(new PartnerCredentials() .partnerId(partnerId) .partnerSecret(partnerSecret)).getToken(); } } ``` -------------------------------- ### GET /aggregation/v3/customers/{customerId}/transactions Source: https://developer.mastercard.com/open-finance-us/documentation/quick-start-guide Retrieves all transactions for a specific customer between the provided start and end dates. Dates must be in Unix epoch timestamp format. ```APIDOC ## GET /aggregation/v3/customers/{customerId}/transactions ### Description Retrieves all transactions for a specific customer between the provided start and end dates. Dates must be in Unix epoch timestamp format. ### Method GET ### Endpoint `/aggregation/v3/customers/{customerId}/transactions` ### Parameters #### Path Parameters - **customerId** (integer) - Required - The ID of the customer whose transactions are to be fetched. #### Query Parameters - **fromDate** (integer) - Required - The start date for the transaction search, as a Unix epoch timestamp. - **toDate** (integer) - Required - The end date for the transaction search, as a Unix epoch timestamp. - **includePending** (boolean) - Optional - Specifies whether to include pending transactions. - **sort** (string) - Optional - Specifies the sort order for transactions (e.g., 'asc', 'desc'). - **limit** (integer) - Optional - The maximum number of transactions to return. ### Request Example ```json { "request": "curl --location --request GET 'https://api.finicity.com/aggregation/v3/customers/{{customerId}}/transactions?fromDate={{fromDate}}&toDate={{toDate}}&includePending=true&sort=desc&limit=25' \ --header 'Finicity-App-Key: {{appKey}}' \ --header 'Accept: application/json' \ --header 'Finicity-App-Token: {{appToken}}'" } ``` ### Response #### Success Response (200) - **found** (integer) - The total number of transactions found. - **displaying** (integer) - The number of transactions currently displayed. - **moreAvailable** (string) - Indicates if more transactions are available ('true' or 'false'). - **fromDate** (string) - The start date of the transaction results in Unix epoch timestamp format. - **toDate** (string) - The end date of the transaction results in Unix epoch timestamp format. - **sort** (string) - The sort order applied to the transactions. - **transactions** (array) - An array of transaction objects. - **id** (integer) - The unique identifier for the transaction. - **amount** (number) - The transaction amount. - **accountId** (integer) - The ID of the account associated with the transaction. - **customerId** (integer) - The ID of the customer the transaction belongs to. - **status** (string) - The status of the transaction (e.g., 'active'). - **description** (string) - A description of the transaction. - **memo** (string) - A memo associated with the transaction. - **postedDate** (integer) - The date the transaction was posted, in Unix epoch timestamp format. - **transactionDate** (integer) - The date of the transaction, in Unix epoch timestamp format. - **createdDate** (integer) - The date the transaction was created, in Unix epoch timestamp format. - **categorization** (object) - Information about the transaction's categorization. - **normalizedPayeeName** (string) - The normalized name of the payee. - **category** (string) - The category assigned to the transaction. - **bestRepresentation** (string) - The best representation of the payee. - **country** (string) - The country associated with the payee. #### Response Example ```json { "found": 64, "displaying": 25, "moreAvailable": "true", "fromDate": "1349701444", "toDate": "1665234244", "sort": "desc", "transactions": [ { "id": 13212489147, "amount": 1208.15, "accountId": 6020605022, "customerId": 6012188750, "status": "active", "description": "REMOTE ONLINE DEPOSIT #", "memo": "1", "postedDate": 1665144000, "transactionDate": 1665144000, "createdDate": 1665248277, "categorization": { "normalizedPayeeName": "Remote Online", "category": "Income", "bestRepresentation": "REMOTE ONLINE DEPOSIT", "country": "USA" } } ] } ``` ``` -------------------------------- ### JavaScript: Generate Connect URL using Existing Client Source: https://developer.mastercard.com/open-finance-us/documentation/quick-start-guide Generates a Connect URL using an already created `client` instance. It instantiates `ConnectApi` and `ConnectParameters`, then calls `generateConnectUrl` asynchronously, handling the response and using `done()` to signal completion. ```javascript let client = await createClient(OpenAPIClient); // Generate a Connect URL let connectApi = new ConnectApi(client) let connectParameters = new ConnectParameters(CUSTOMER_ID, PARTNER_ID) let connectResponse api.generateConnectUrl(connectParameters, (error, data, response) => { connectResponse = response done(); }); done(); ``` -------------------------------- ### Generate Connect URL using Python Source: https://developer.mastercard.com/open-finance-us/documentation/quick-start-guide This snippet demonstrates how to generate a Connect URL using the Mastercard Open Finance API. It requires an ApiClient instance and specifies partner and customer IDs. The output is a URL that initiates the connection process. ```python customer_id = "{{customerId}}" api_client = ApiClient() connect_parameters = ConnectParameters( partner_id=api_client.partner_id, customer_id=customer_id) # Generate a Connect URL response = ConnectApi(api_client.api_client).generate_connect_url(connect_parameters=connect_parameters) print("Connect URL: ", response.link) ``` -------------------------------- ### Install Open Finance Web SDK using npm Source: https://developer.mastercard.com/open-finance-us/documentation/connect/integrating/sdk/web-sdk/sdk Installs the Open Finance Web SDK and its dependencies using Node Package Manager (npm). Requires Node.js and npm to be installed. This command is for versions 1.x of the SDK. ```bash npm install connect-web-sdk core-js --save ``` -------------------------------- ### Fetch All Customer Transactions (cURL) Source: https://developer.mastercard.com/open-finance-us/documentation/quick-start-guide This snippet demonstrates how to fetch all customer transactions within a specified date range using the Finicity API via cURL. It requires customer ID, start and end dates (as Unix epoch timestamps), and app credentials. The response includes transaction details, metadata, and categorization. ```curl curl --location --request GET 'https://api.finicity.com/aggregation/v3/customers/{{customerId}}/transactions?fromDate={{fromDate}}&toDate={{toDate}}&includePending=true&sort=desc&limit=25' \ --header 'Finicity-App-Key: {{appKey}}' \ --header 'Accept: application/json' \ --header 'Finicity-App-Token: {{appToken}}' ``` -------------------------------- ### JavaScript: Create and Authenticate API Client Source: https://developer.mastercard.com/open-finance-us/documentation/quick-start-guide Creates an API client instance and configures it to automatically refresh authentication tokens and add necessary headers (Finicity-App-Key and Finicity-App-Token) to outgoing requests. It uses promises to ensure token refresh completes before requests are sent. ```javascript const createClient = function (openAPIClient) { return new Promise((resolve) => { let client = openAPIClient.ApiClient.instance; let authApi = new AuthenticationApi(client) client.applyAuthToRequest = function (request) { const _end = request._end; request._end = function () { request.req.setHeader('Finicity-App-Key', APP_KEY); _end.call(request); }; return request; }; let tokenPromise = function refreshToken() { return new Promise((resolve) => { if (expiry === null || expiry < new Date()) { authApi.createToken(new PartnerCredentials(PARTNER_ID, PARTNER_SECRET), (error, data, response) => { if (!error) { expiry = new Date(); token = data.token; resolve(); } }); } else { resolve() } }) } tokenPromise().then(() => { client.applyAuthToRequest = function (request) { const _end = request._end; request._end = function () { request.req.setHeader('Finicity-App-Key', APP_KEY); request.req.setHeader('Finicity-App-Token', token); _end.call(request); }; return request; }; resolve(client); }) }) }; ``` -------------------------------- ### Generate JavaScript API Client with OpenAPI Generator Source: https://developer.mastercard.com/open-finance-us/documentation/quick-start-guide Generates a JavaScript client library for the Open Finance APIs using the OpenAPI Generator CLI. It uses the OpenAPI specification ('*.yaml') and outputs the client code to the 'api_client' directory. Make sure OpenAPI Generator is set up. ```bash openapi-generator-cli generate -g javascript -i *.yaml -o api_client ``` -------------------------------- ### Add Testing Customer API Source: https://developer.mastercard.com/open-finance-us/documentation/quick-start-guide This endpoint creates a "testing" customer record that can be used with FinBank test profiles. The Customer ID returned is essential for retrieving account and financial data. ```APIDOC ## POST /aggregation/v2/customers/testing ### Description Creates a "testing" customer record for use with FinBank test profiles. The returned Customer ID is required for subsequent data retrieval operations. ### Method POST ### Endpoint /aggregation/v2/customers/testing ### Parameters #### Headers - **Content-Type** (string) - Required - `application/json` - **Accept** (string) - Required - `application/json` - **Finicity-App-Key** (string) - Required - Your application key. - **Finicity-App-Token** (string) - Required - The access token obtained from the Create Access Token API. #### Request Body - **username** (string) - Required - A username for the test customer. - **applicationId** (string) - Optional - The application ID, can be omitted when generating test customers. ### Request Example ```json { "username": "customerusername1" } ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the created customer. - **username** (string) - The username of the created customer. - **createdDate** (integer) - The timestamp when the customer was created. #### Response Example ```json { "id": "1005061234", "username": "customerusername1", "createdDate": 1607450357 } ``` ``` -------------------------------- ### POST /aggregation/v1/customers/{customerId}/accounts Source: https://developer.mastercard.com/open-finance-us/documentation/quick-start-guide Initiates the refresh process for a customer's accounts. This is a necessary step before you can retrieve account transactions for the specified customer. The request requires the customerId in the path and authentication headers. ```APIDOC ## POST /aggregation/v1/customers/{customerId}/accounts ### Description Initiates the refresh process for a customer's accounts. This is a necessary step before you can retrieve account transactions for the specified customer. ### Method POST ### Endpoint /aggregation/v1/customers/{customerId}/accounts ### Parameters #### Path Parameters - **customerId** (string) - Required - The ID of the customer for whom to refresh accounts. #### Query Parameters None #### Request Body - **(empty)** - Required - An empty JSON object is expected. ### Request Example ```json {} ``` ### Response #### Success Response (200) - **accounts** (array) - A list of refreshed account objects. - **id** (string) - The unique identifier for the account. - **number** (string) - The account number. - **realAccountNumberLast4** (string) - The last four digits of the account number. - **accountNumberDisplay** (string) - The account number to display. - **name** (string) - The name of the account. - **balance** (number) - The current balance of the account. - **type** (string) - The type of the account (e.g., "checking", "savings", "investment"). - **aggregationStatusCode** (integer) - The status code of the aggregation. - **status** (string) - The status of the account (e.g., "active"). - **customerId** (string) - The ID of the customer associated with the account. - **institutionId** (string) - The ID of the institution where the account is held. - **balanceDate** (integer) - The date and time the balance was recorded (Unix timestamp). - **aggregationSuccessDate** (integer) - The date and time the aggregation was successful (Unix timestamp). - **aggregationAttemptDate** (integer) - The date and time the aggregation was attempted (Unix timestamp). - **createdDate** (integer) - The date and time the account was created (Unix timestamp). - **lastUpdatedDate** (integer) - The date and time the account was last updated (Unix timestamp). - **currency** (string) - The currency of the account balance (e.g., "USD"). - **institutionLoginId** (integer) - The ID of the institution login associated with the account. - **detail** (object) - Additional details specific to the account type (e.g., marginBalance, availableCashBalance). - **displayPosition** (integer) - The display order of the account. - **accountNickname** (string) - A nickname for the account. - **marketSegment** (string) - The market segment the account belongs to. #### Response Example ```json { "accounts": [ { "id": "6020488409", "number": "232323", "realAccountNumberLast4": "2323", "accountNumberDisplay": "2323", "name": "ROTH", "balance": 11001.0, "type": "roth", "aggregationStatusCode": 0, "status": "active", "customerId": "6012118342", "institutionId": "102105", "balanceDate": 1665157710, "aggregationSuccessDate": 1665157711, "aggregationAttemptDate": 1665157711, "createdDate": 1665157660, "lastUpdatedDate": 1665157664, "currency": "USD", "institutionLoginId": 6009863353, "detail": {}, "displayPosition": 5, "accountNickname": "ROTH", "marketSegment": "personal" } ] } ``` ``` -------------------------------- ### Add Test Customer with cURL Source: https://developer.mastercard.com/open-finance-us/documentation/quick-start-guide This snippet demonstrates how to add a testing customer record for Finicity test profiles using cURL. It requires `appKey` and `appToken` and accepts a JSON payload with a username. The output is a JSON object with the new customer's ID and details. ```bash curl --location --request POST 'https://api.finicity.com/aggregation/v2/customers/testing' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'Finicity-App-Key: {{appKey}}' \ --header 'Finicity-App-Token: {{appToken}}' \ --data-raw '{ "username": "customerusername1" }' ``` -------------------------------- ### Create Access Token API Source: https://developer.mastercard.com/open-finance-us/documentation/quick-start-guide This endpoint is used to generate a new access token required for all requests to the Open Finance US APIs. Requests must originate from an IP address in the United States, United Kingdom, Canada, or Australia. ```APIDOC ## POST /aggregation/v2/partners/authentication ### Description Generates a new access token required for authenticating requests to the Mastercard Open Finance US APIs. ### Method POST ### Endpoint /aggregation/v2/partners/authentication ### Parameters #### Headers - **Content-Type** (string) - Required - `application/json` - **Finicity-App-Key** (string) - Required - Your application key obtained from Mastercard Developers. - **Accept** (string) - Required - `application/json` #### Request Body - **partnerId** (string) - Required - Your partner ID obtained from Mastercard Developers. - **partnerSecret** (string) - Required - Your partner secret obtained from Mastercard Developers. ### Request Example ```json { "partnerId": "{{partnerId}}", "partnerSecret": "{{partnerSecret}}" } ``` ### Response #### Success Response (200) - **token** (string) - The generated access token. #### Response Example ```json { "token": "YBh22Sb9Es6e66Q7lWdt" } ``` ``` -------------------------------- ### Load Mastercard Connect SDK using IIFE in HTML Source: https://developer.mastercard.com/open-finance-us/documentation/connect/integrating/sdk/web-sdk/web-sdk-cdn This example demonstrates how to load the Mastercard Connect Web SDK using its IIFE build directly within an HTML file. It includes a basic script to launch the SDK with event handlers for success, cancellation, and errors. The SDK is made available as a global object after loading. ```html Connect SDK - IIFE Example ``` -------------------------------- ### Download the Starter Code Source: https://developer.mastercard.com/open-finance-us/documentation/connect/integrating/sdk/web-sdk/sdk Instructions for downloading and setting up the starter code which includes the Web SDK and necessary modules, demonstrating its use with TypeScript and webpack. ```APIDOC ## Download the Starter Code ### Description Download the provided starter code zip file, which demonstrates using the Web SDK with TypeScript and webpack. This package includes pre-installed node modules. ### Method Download and Terminal Command ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```bash # Download the starter code: openfinance-webpack.zip # Navigate to the downloaded folder cd path/to/extracted/folder # Install node modules (includes connect-web-sdk and core-js) npm i ``` ### Response #### Success Response (200) * Node modules installed successfully. * Refer to `index.ts` to configure and launch the Connect instance. #### Response Example N/A ``` -------------------------------- ### Install Node Modules from Starter Code Source: https://developer.mastercard.com/open-finance-us/documentation/connect/integrating/sdk/web-sdk/sdk Installs all necessary Node.js modules, including 'connect-web-sdk' and 'core-js', after downloading the starter code. This command is run in the terminal within the downloaded starter code's directory. ```bash npm i ``` -------------------------------- ### Connect Class - Start Method Source: https://developer.mastercard.com/open-finance-us/documentation/connect/integrating/sdk/android/android-sdk The `start` method initiates the Connect activity. It requires a context, a Connect URL, a redirect URL, and an event handler. The SDK ensures only one instance of the Connect activity can run at a time. ```APIDOC ## POST /connect/start ### Description Initiates the Connect activity which handles user authentication and data consent flows. ### Method POST ### Endpoint Connect.start ### Parameters #### Path Parameters * None #### Query Parameters * None #### Request Body * **context** (Context) - Required - The Android Context for starting the activity. * **connectUrl** (String) - Required - The URL that loads the Connect flow. * **redirectUrl** (String) - Optional - The App Link URL to redirect back to the app after the OAuth flow. Required for App to App authentication. * **eventHandler** (EventHandler) - Required - An implementation of the EventHandler interface to receive callbacks. ### Request Example ```json { "context": "android_context_instance", "connectUrl": "https://connect.mastercard.com/init?flow_id=...", "redirectUrl": "https://yourdomain.com/connect/callback", "eventHandler": "event_handler_instance" } ``` ### Response #### Success Response (200) This method does not return a value directly, but starts an activity. Events are handled via the `EventHandler` interface. #### Response Example N/A ### Error Handling * Throws `RuntimeException` if Connect is started while another Connect activity is already running. ``` -------------------------------- ### Install the SDK from npm Source: https://developer.mastercard.com/open-finance-us/documentation/connect/integrating/sdk/web-sdk/sdk Instructions on how to install the Connect Web SDK using Node Package Manager (npm). Includes commands for different SDK versions and notes on peer dependencies. ```APIDOC ## Install the SDK from npm ### Description Install the Connect Web SDK directly from npm. This method is suitable for projects that already use a module compiler like Webpack or Babel, or for starting a new project. ### Method Terminal Command ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```bash # Initialize package.json if it doesn't exist npm init -y # Install for Open Finance Web SDK version 1.x (includes core-js) npm install connect-web-sdk core-js --save # Install for Open Finance Web SDK version 2.0 or higher npm install connect-web-sdk --save ``` ### Response #### Success Response (200) * SDK installed successfully in `node_modules`. #### Response Example N/A ``` -------------------------------- ### Get Statement Report Example Source: https://developer.mastercard.com/open-finance-us/documentation/products/lend/reports/statements Provides an example of a successful JSON response when retrieving a statement report. ```APIDOC ## Get Statement Report Example ### Description This example shows a successful JSON response for the Statement Report. Note that examples are for reference only and may not reflect the latest production changes. ### Response Example ```json { "id": "38dknche83oh-statement", "customerType": "active", "customerId": 1000262464, "requestId": "nd4b55a4bg", "title": "Mastercard Open Banking Statement Report", "consumerId": "d15ff15ed0c8627eae61c452928d7fc3", "consumerSsn": "1111", "disputeStatement": "Invalid data present.", "requesterName": "Demo", "endUser": { "name": "ABC Apartments", "address": "123 Main St", "city": "Murray", "state": "UT", "zip": "84123", "phone": "555-2106", "email": "customerservice@abcapartments.com", "url": "abcapartments.com" }, "constraints": { "statementReportData": { "accountId": 1000076901, "statementIndex": 1 }, "reportCustomFields": [ { "label": "loanID", "value": "123456", "shown": true } ] }, "type": "statement", "status": "success", "createdDate": 1586189339, "assetId": "aaaa3be2-6f1a-4aac-a360-4ad240aa652d" } ``` ``` -------------------------------- ### Initialize package.json using npm Source: https://developer.mastercard.com/open-finance-us/documentation/connect/integrating/sdk/web-sdk/sdk Creates a package.json file in your project if you don't already use node modules. This command is run in the terminal and requires Node.js and npm. ```bash npm init -y ``` -------------------------------- ### Get Account Owner API Request (JSON Response Example) Source: https://developer.mastercard.com/open-finance-us/documentation/participant-model/partner-linked/processor/processor-steps Example JSON response from the Get Account Owner API. This response includes the real owner name and address associated with the provided pseudo customer and account IDs. It is used to verify account ownership. ```json { "ownerName": "John Smith", "ownerAddress": "APT C 5600 S SPRINGFIELD GARDENS CIR SPRINGFIELD, VA 22162-1058" } ``` -------------------------------- ### Get Available Balance API Response (JSON Example) Source: https://developer.mastercard.com/open-finance-us/documentation/participant-model/partner-linked/processor/processor-steps Example JSON response from the Get Available Balance API. This response provides detailed information about the account, including the last four digits of the account number, available balance, and balance dates. It helps in understanding the financial status of the account. ```json { "id": 5047759451, "realAccountNumberLast4": "2222", "availableBalance": 228.33, "availableBalanceDate": 1646076805, "cleared Balance": 228.33, "clearedBalanceDate": 1646076805, "aggregationStatusCode": 0, "currency": "USD" } ``` -------------------------------- ### Install Reference Application Dependencies using npm Source: https://developer.mastercard.com/open-finance-us/documentation/reference-app These commands clone the reference application repository from GitHub and install the necessary Node.js dependencies using npm. This is a prerequisite for running the application locally. Ensure you have Git and Node.js (v14+) installed. ```bash git clone https://github.com/Mastercard/open-banking-reference-application.git cd open-banking-reference-application npm i ``` -------------------------------- ### SDK Parameters Source: https://developer.mastercard.com/open-finance-us/documentation/connect/integrating/sdk/web-sdk/sdk Details the required and optional parameters for initializing the Connect Web SDK. ```APIDOC ## SDK Parameters ### Description Parameters required or available for the Connect Web SDK initialization. ### Method SDK Initialization ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body * **connectURL** (string) - Required - The URL provided to load the Connect experience. * **connectEventHandlers** (object) - Required - An instance of a class implementing the EventHandler interface. * **connectOptions** (object) - Optional - Additional configuration options for the SDK. ```