DigiFI SDK for Node JS
npm install @digifi/digifi-node-js


The DigiFi Node library provides convenient access to the DigiFi API from
applications written in server-side JavaScript.
See the API docs.
Node 12 or higher.
Install the package with:
``sh`
npm install @digifi/digifi-node-js --saveor
yarn add @digifi/digifi-node-js
This package provides API Clients and API Services to help you communicate with DigiFi platform.
In order to start communication with DigiFi platform API you need to create DigiFi API Service by providing the
url to the DigiFi platform (this url can be different if you're using dedicated platform solution) and api-key.
`js
const Digifi = require('@digifi/digifi-node-js');
const digifiApi = new Digifi.DigifiApi('https://cloud.digifi.io/api', 'digifi-...', {
apiVersion: '2024-02-26',
});
const { items, total } = await digifiApi.applications.find({ productId: '63d...' });
console.log(items);
`
DigiFi maintains types for the latest API Version.
`ts
import { CreateApplicationParams, Application, DigifiApi } from '@digifi/digifi-node-js';
const digifiApi = new DigifiApi('https://cloud.digifi.io/api', 'digifi-...', {
apiVersion: '2024-02-26',
});
const createApplication = async () => {
const params: CreateApplicationParams = {
productId: '63d288ae64f7677836046de7',
...,
};
const application: Application = await digifiApi.applications.create(params);
console.log(application.id);
};
createApplication();
`
To initialize DigiFi API Service you need provide the following data:
* `baseUrl` of DigiFi Platform API endpoint as first argument, options
* api-key as second argument and
* apiVersion in object as third argument.
`js
import { DigifiApi } from '@digifi/digifi-node-js';
const baseUrl = 'https://cloud.digifi.io/api';
const apiKey = 'digifi-cloud-...';
const digifiApi = new DigifiApi(baseUrl, apiKey, {
apiVersion: '2024-02-26',
});
`
parameter that has this structure:| Option | Default | Required | Description |
| -------------------------------- |---------|----------|------------------------------------------------------------------------------------------------------------------------------------|
|
apiVersion | | true | Api version to use for client. |
| enableIdempotencyHeader | false | false | If true is provided it allows POST requests to be idempotent |
| maxNetworkRetries | 0 | false | The amount of times a request should be retried if error occured |
| logger | null | false | Logger for tracing errors and requests |$3
Idempotency Header can be enabled with the
enableIdempotencyHeader to prevent duplication in cause of retry. Librabry will automatically assign idempotency header key (generated by UUID v4) to each POST request.`js
const digifiApi = new DigifiApi('https://cloud.digifi.io/api', 'digifi-cloud-...', {
apiVersion: '2024-02-26',
enableIdempotencyHeader: true, // Will assign idempotency key to each POST request using UUID
});
`$3
Automatic network retries can be enabled with the
maxNetworkRetries config option.
This will retry requests n times with exponential backoff if they fail due to an intermittent network problem.`js
const digifiApi = new DigifiApi('https://cloud.digifi.io/api', 'digifi-cloud-...', {
apiVersion: '2024-02-26',
maxNetworkRetries: 2, // Retry a request twice before giving up
});
`API Services
An instance of Digifi Api Service class has several properties, each of them represents entity/domain in DigiFi system For example, if you need to create a borrower in DigiFi Platform you can use the following structure:
`js
const digifiApi = new DigifiApi(...);const borrowers = await digifiApi.borrowers.create({ ... });
console.log(borrower.id);
`> Note
> You can communicate with DigiFi Platform API directly by
AuthorizedApiClient, since it provides method makeCall, but it's recommended to use Digifi API Services to make sure that you're using correct request structure.Here the list of
API Services that DigiFi Node JS Library provides:-
new DigifiApi.borrowerAccounts(...) - api for borrower accounts.
- findAccountByEmail(email: string) - returns borrower account.
- createAccount(accountParams: object, refreshTokenExpirationTimeMinutes?: number) - creates and returns borrower account.
- getCurrentUser(accountAccessToken: string) - returns current borrower account by accountAccessToken.
- sendUpdatePhoneNumberCode(phone: string, accountAccessToken: string, accountPasswordValidationToken: string) - send code that confirms phone update for borrower account.
- updatePhoneNumber(code: string, accountAccessToken: string) - confirms phone update for borrower by code and accountAccessToken.
- sendAddPhoneNumberCode(phone: string, accountAccessToken: string, accountPasswordValidationToken: string) - send code that confirms phone adding for borrower account.
- addPhoneNumber(code: string, accountAccessToken: string) - confirms add phone to borrower/intermediary (depends on reference passed to the service) by code and accountAccessToken.
- deletePhoneNumber(phone: string, accountAccessToken: string, accountPasswordValidationToken: string) - deletes phone for borrower by accountAccessToken and accountPasswordValidationToken.
- sendUpdateEmailCode(email: string, accountAccessToken: string, accountPasswordValidationToken: string) - sends update email code for borrower to account by accountAccessToken and accountPasswordValidationToken.
- updateEmailAddress(code: string, accountAccessToken: string) - confirms email update for borrower for account by accountAccessToken.
- createPasswordValidationToken(password: string, accountAccessToken: string) - creates password validation token for borrower account by password and accountAccessToken.
- updatePassword(oldPassword: string, newPassword: string, accountAccessToken: string) - updates password for borrower account.
- find(params: object) - finds borrower accounts by params object.
- new DigifiApi.borrowerEmailVerification(...) - api for borrower accounts email verification.
- sendVerificationEmail(accountAccessToken: string) - sends verification email for borrower account by accountAccessToken.
- verifyEmail(code: string, accountAccessToken: string) - verifies email for borrower account using code by accountAccessToken.
- new DigifiApi.borrowerInvites(apiClient: ApiClient) - api for borrower invitation management.
- acceptInvite(inviteParams: object, refreshTokenExpirationTimeMinutes?: number) - accepts invite for borrower account.
- getInviteInfo(token: string) - retrieves invitation information for borrower account by token.
- new DigifiApi.borrowerPhoneVerification(...) - api for borrower phone verification management.
- sendMfaCode(phone: string, accountAccessToken: string) - sends mfa code for borrower account phone by accountAccessToken.
- verifyMfaCode(code: string, accountAccessToken: string) - verifies mfa code for borrower account by accountAccessToken.
- new DigifiApi.borrowerResetPassword(...) - api for borrower account reset password management.
- sendResetPasswordLink(email: string) - sends reset password link to borrower account email.
- resetPassword(password: string, resetPasswordToken: string) - resets password for borrower account by resetPasswordToken.
- getResetPasswordTokenInfo(resetPasswordToken: string) - retrieves reset password token info for borrower account by resetPasswordToken.
- new DigifiApi.borrowerSessions(...) - api for borrower account session management.
- createSession(email: string, password: string, refreshTokenExpirationTimeMinutes?: number) - creates session for borrower account.
- createSessionWithPhoneVerificationCode(phoneVerificationCode: string, refreshTokenExpirationTimeMinutes?: number) - creates session for borrower account by phoneVerificationCode.
- sendPhoneVerificationCode(phone: string) - sends phone verification code for borrower account by phone.
- validateToken(accountAccessToken: string) - validates access token for borrower account.
- logout(accountAccessToken: string) - kills session associated with borrower account by accountAccessToken.
- resignAccessToken(accountRefreshToken: string) - resign access token for borrower account by accountRefreshToken.
- new DigifiApi.intermediaryAccounts(...) - api for intermediary accounts.
- findAccountByEmail(email: string) - returns intermediary account.
- createAccount(accountParams: object, refreshTokenExpirationTimeMinutes?: number) - creates and returns intermediary account.
- getCurrentUser(accountAccessToken: string) - returns current intermediary account by accountAccessToken.
- sendUpdatePhoneNumberCode(phone: string, accountAccessToken: string, accountPasswordValidationToken: string) - send code that confirms phone update for intermediary account.
- updatePhoneNumber(code: string, accountAccessToken: string) - confirms phone update for intermediary by code and accountAccessToken.
- sendAddPhoneNumberCode(phone: string, accountAccessToken: string, accountPasswordValidationToken: string) - send code that confirms phone adding for intermediary account.
- addPhoneNumber(code: string, accountAccessToken: string) - confirms add phone to intermediary by code and accountAccessToken.
- deletePhoneNumber(phone: string, accountAccessToken: string, accountPasswordValidationToken: string) - deletes phone for intermediary by accountAccessToken and accountPasswordValidationToken.
- sendUpdateEmailCode(email: string, accountAccessToken: string, accountPasswordValidationToken: string) - sends update email code for intermediary to account by accountAccessToken and accountPasswordValidationToken.
- updateEmailAddress(code: string, accountAccessToken: string) - confirms email update for intermediaryfor account by accountAccessToken.
- createPasswordValidationToken(password: string, accountAccessToken: string) - creates password validation token for intermediary account by password and accountAccessToken.
- updatePassword(oldPassword: string, newPassword: string, accountAccessToken: string) - updates password forintermediary account.
- find(params: object) - finds intermediary accounts by params object.
- new DigifiApi.intermediaryEmailVerification(...) - api for intermediary accounts email verification.
- sendVerificationEmail(accountAccessToken: string) - sends verification email for intermediary account by accountAccessToken.
- verifyEmail(code: string, accountAccessToken: string) - verifies email for intermediary account using code by accountAccessToken.
- new DigifiApi.intermediaryInvites(...) - api for intermediary invitation management.
- acceptInvite(inviteParams: object, refreshTokenExpirationTimeMinutes?: number) - accepts invite for intermediary account.
- getInviteInfo(token: string) - retrieves invitation information for intermediary account by token.
- new DigifiApi.intermediaryPhoneVerification(...) - api for borrower/intermediary phone verification management.
- sendMfaCode(phone: string, accountAccessToken: string) - sends mfa code for intermediary account phone by accountAccessToken.
- verifyMfaCode(code: string, accountAccessToken: string) - verifies mfa code for intermediary account by accountAccessToken.
- new DigifiApi.intermediaryResetPassword(...) - api for borrower/intermediary account reset password management.
- sendResetPasswordLink(email: string) - sends reset password link to intermediary (depends on reference passed to the service) account email.
- resetPassword(password: string, resetPasswordToken: string) - resets password for intermediary account by resetPasswordToken.
- getResetPasswordTokenInfo(resetPasswordToken: string) - retrieves reset password token info for intermediary account by resetPasswordToken.
- new DigifiApi.intermediarySessions(...) - api for intermediary account session management.
- createSession(email: string, password: string, refreshTokenExpirationTimeMinutes?: number) - creates session for intermediary account.
- createSessionWithPhoneVerificationCode(phoneVerificationCode: string, refreshTokenExpirationTimeMinutes?: number) - creates session for intermediary account by phoneVerificationCode.
- sendPhoneVerificationCode(phone: string) - sends phone verification code for intermediary account by phone.
- validateToken(accountAccessToken: string) - validates access token for intermediary account.
- logout(accountAccessToken: string) - kills session associated with intermediary account by accountAccessToken.
- resignAccessToken(accountRefreshToken: string) - resign access token for intermediary account by accountRefreshToken.
- new DigifiApi.users(...) - api for users management.
- find(params: object) - finds organization users by params object.
- new DigifiApi.variables(...) - api for variables management.
- find(params: object) - finds organization variables by params object.
- new DigifiApi.decisions(...) - api for decisions management.
- find(params; object) - finds organization decisions by params object.
- findById(id: string) - finds organization decision by id.
- delete(id: string) - deletes organization decision by id.
- new DigifiApi.borrowerStandardPortalGeneralSettings(...) - api for borrower standard portal settings management.
- getGeneralSettings() - retrieves general settings of standard borrower portal for current organization.
- new DigifiApi.borrowerStandardPortalLegalConsents(apiClient) - api for borrower standard portal legal consents management.
- getLegalConsents() - retrieves borrower standard portal legal consents for current organization.
- new DigifiApi.branding(...) - api for organization branding management.
- getBranding() - retrieves current organization branding.
- getLogo() - retrieves current organization logo.
- getFavicon() - retrieves current organization favicon.
- new DigifiApi.decisionProcessing(...) - api for processing decisions.
- runDecisions(params: object) - runs one/many decisions for current organization by params object.
- new DigifiApi.integrationFileDownload(...) - api for integration files downloads management.
- downloadById(id: string) - downloads integration result file by id.
- new DigifiApi.integrationProcessing(...) - api for processing integrations.
- processIntegration(params: object) - processes integration for current organization by params object.
- new DigifiApi.integrationResultFiles(...) - api for integration result files management.
- uploadMany(integrationResultId: string, files: object[]) - uploads few files for integration result.
- new DigifiApi.integrationResults(...) - api for integration results management.
- find(params: object) - finds integration results for current organization by params object.
- findById(id: string) - finds integration result by id.
- delete(id: string) - deletes integration result by id.
- new DigifiApi.applicationDecisionProcessing(...) - api for processing application decisions.
- makeDecision(params: object) - processes application decision for current organization by params object.
- new DigifiApi.applicationDocuments(...) - api for application documents management.
- find(params: object) - finds application documents by params object.
- findById(id) - finds application document by id.
- create(params: object) - uploads application document by params object.
- createMany(params: object) - uploads few application documents by params object.
- update(id: string, params: object) - updates application document by id and params object.
- createFolder(params: object) - creates application document folder by params.
- delete(id: string) - deletes application document by id.
- new DigifiApi.applicationDocumentsDownloads(...) - api for application documents download.
- downloadById(id: string) - downloads application document by id.
- downloadAll(applicationId: string, accessPermission?: ApplicationDocumentAccessPermission) - downloads all application documents.
- new DigifiApi.applicationDocumentsPreview(...) - api for document preview management.
- createToken(documentId: string) - creates preview token for document by documentId.
- new DigifiApi.applicationIntegrationProcessing(...) - api for processing application integrations.
- processIntegration(params: object) - processes integration for application by params object.
- new DigifiApi.applicationNotes(...) - api for application notes management.
- find(params: object) - finds application notes by params object.
- findById(id: string) - finds application note by id.
- create(params: object) - creates application note by params object.
- update(id: string, params: object) - updates application note by id and params object.
- delete(id: string) - deletes application note by id.
- new DigifiApi.applications(...) - api for applications management.
- search(params: object) - search applications by params object.
- list(params: object) - lists applications by params object.
- findById(id: string) - finds application by id.
- findByDisplayId(displayId: string) - finds application by displayId.
- create(params: object) - creates application by params object.
- update(id: string, params: object) - updates application by id and params object.
- delete(id: string) - deletes application by id.
- updateCoBorrowers(id: string, params: object) - updates application co-borrowers by id and params object.
- updateIntermediary(id: string, params: object) - updates application intermediary by id and params object.
- getVariables(id: string, variablesToInclude?: string[]) - retrieves application variables by id (optional argument variablesToInclude includes only specified variables).
- runCalculations(id: string, params: object) - re-runs applications calculations by id and optional params object (provide variablesToRun in params object to re-run only specified variables).
- addLabels(id: string, labelsIds: string[]) - adds labels to application by id.
- addTeamMembers(id: string, teamMembersIds: string[]) - adds team members to application by id.
- runAutomation(id: string, params: object) - triggers automation workflow on application by id and params object.
- new DigifiApi.applicationStatuses(...) - api for application statuses management.
- find(productId: string) - finds application statuses for current organization and mode (depends on api-key provided to api client) by productId.
- new DigifiApi.borrowers(...) - api for borrowers management.
- search(params: object) - search borrowers by params object.
- list(params: object) - lists borrowers by params object.
- findById(id: string) - finds borrower by id.
- create(params: object) - creates borrower by params object.
- update(id: string, params: object) - updates borrower by id and params object.
- delete(id: string) - deletes borrower by id.
- new DigifiApi.comments(...) - api for comments management.
- find(params: object) - finds comments by params object.
- create(params: object) - creates comment by params object.
- update(id: string, params: object) - updates comment by id and params object.
- delete(id: string) - deletes comment by id.
- new DigifiApi.intermediaries(...) - api for intermediaries management.
- search(params: object) - search intermediaries by params object.
- list(params: object) - lists intermediaries by params object.
- findById(id: string) - finds intermediary by id.
- create(params: object) - creates intermediary by params object.
- update(id: string, params: object) - updates intermediary by id and params object.
- delete(id: string) - deletes intermediary by id.
- getSuggestions(params: object) - retrieves intermediary suggestions by params object.
- createMany(intermediaries: object[]) - creates many intermediaries.
- new DigifiApi.productCalculations(...) - api for product calculations management.
- find(productId: string) - finds product calculations for current organization and mode (depends on api-key provided to api client) by productId.
- new DigifiApi.products(...) - api for products management.
- find(params: object) - finds products for current organization and mode (depends on api-key provided to api client) by params.
- findById(id: string) - finds product for current organization and mode (depends on api-key provided to api client) by id.
- new DigifiApi.tasks(...) - api for application tasks management.
- search(params: object) - search tasks by params object.
- list(params: object) - lists tasks by params object.
- findById(id: string) - finds task by id.
- create(params: object) - creates task by params object.
- update(id: string, params: object) - updates task by id and params object.
- delete(id: string) - deletes task by id.
- bulkCreate(params: object) - creates many tasks by params object.
- new DigifiApi.webhookEndpoints(...) - api for webhooks management.
- find(params: object) - finds webhook endpoints by params object.
- findById(id: string) - finds webhook endpoints by id.
- create(params: object) - creates webhook endpoint by params object.
- update(id: string, params: object) - updates webhook endpoints by id and params object.
- delete(id: string) - deletes webhook endpoint by id.
- new DigifiApi.communications(...) - api for communications management.
- search(params: object) - search communications by params object.
- findById(id: string) - finds communication by id.
- create(params: object) - creates communication by params object.
- update(id: string, params: object) - updates communication by id and params object.
- delete(id: string) - deletes communication by id.Webhook signing
DigiFi can verify webhook events signature it sends to your endpoint, allowing you to validate that they were not sent by a third-party. You can read more about it here.
Please note that you must pass the _raw_ request body, exactly as received from DigiFi, to the
verifyWebhookSignature() function; this will not work with a parsed (i.e., JSON) request body.Here is an example how to use it with express:
`js
const express = require('express');
const digifi = require('digifi-node-js');
const bodyParser = require('body-parser');const app = express();
const endpointSecret = '...';
app.post('/webhooks', bodyParser.raw({ type: 'application/json' }), (req, res) => {
const timestamp = req.headers['x-digifi-event-timestamp'];
const signature = req.headers['x-digifi-signature'];
if (!digifi.verifyWebhookSignature(req.body, endpointSecret, timestamp, signature)) {
res.status(400).send({ message: 'Invalid signature' });
return;
}
if (!digifi.verifyWebhookTimestamp(timestamp)) {
res.status(400).send({ message: 'Invalid timestamp' });
return;
}
switch (req.body.eventType) {
case 'application.created': {
handleApplicationCreate();
}
case 'application.updated': {
handleApplicationUpdate();
}
}
res.status(200).send({});
});
app.listen(3000, () => {
console.log(
Example app listening at http://localhost:3000)
});
`Support
New features and bug fixes are released on the latest major version of the
@digifi/digifi-node-js` package. If you are on an older major version, we recommend that you upgrade to the latest in order to use the new features and bug fixes including those for security vulnerabilities. Older major versions of the package will continue to be available for use, but will not be receiving any updates.