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:
npm install @digifi/digifi-node-js --save
# or
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.
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.
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, - api-key as second argument and
-
apiVersion in
options
object as third argument.
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',
});
API client can be created with required options
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 |
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.
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
});
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.
const digifiApi = new DigifiApi('https://cloud.digifi.io/api', 'digifi-cloud-...', {
apiVersion: '2024-02-26',
maxNetworkRetries: 2, // Retry a request twice before giving up
});
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:
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 methodmakeCall
, but it's recommended to useDigifi 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 byaccountAccessToken
. -
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 bycode
andaccountAccessToken
. -
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 onreference
passed to the service) bycode
andaccountAccessToken
. -
deletePhoneNumber(phone: string, accountAccessToken: string, accountPasswordValidationToken: string)
- deletes phone for borrower byaccountAccessToken
andaccountPasswordValidationToken
. -
sendUpdateEmailCode(email: string, accountAccessToken: string, accountPasswordValidationToken: string)
- sends update email code for borrower to account byaccountAccessToken
andaccountPasswordValidationToken
. -
updateEmailAddress(code: string, accountAccessToken: string)
- confirms email update for borrower for account byaccountAccessToken
. -
createPasswordValidationToken(password: string, accountAccessToken: string)
- creates password validation token for borrower account bypassword
andaccountAccessToken
. -
updatePassword(oldPassword: string, newPassword: string, accountAccessToken: string)
- updates password for borrower) account. -
find(params: object)
- finds borrower accounts byparams
object.
-
-
new DigifiApi.borrowerEmailVerification(...)
- api for borrower accounts email verification. -
new DigifiApi.borrowerInvites(apiClient: ApiClient)
- api for borrower invitation management. -
new DigifiApi.borrowerPhoneVerification(...)
- api for borrower phone verification management. -
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 byresetPasswordToken
. -
getResetPasswordTokenInfo(resetPasswordToken: string)
- retrieves reset password token info for borrower account byresetPasswordToken
.
-
-
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 byphoneVerificationCode
. -
sendPhoneVerificationCode(phone: string)
- sends phone verification code for borrower account byphone
. -
validateToken(accountAccessToken: string)
- validates access token for borrower account. -
logout(accountAccessToken: string)
- kills session associated with borrower account byaccountAccessToken
. -
resignAccessToken(accountRefreshToken: string)
- resign access token for borrower account byaccountRefreshToken
.
-
-
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 byaccountAccessToken
. -
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 bycode
andaccountAccessToken
. -
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 bycode
andaccountAccessToken
. -
deletePhoneNumber(phone: string, accountAccessToken: string, accountPasswordValidationToken: string)
- deletes phone for intermediary byaccountAccessToken
andaccountPasswordValidationToken
. -
sendUpdateEmailCode(email: string, accountAccessToken: string, accountPasswordValidationToken: string)
- sends update email code for intermediary to account byaccountAccessToken
andaccountPasswordValidationToken
. -
updateEmailAddress(code: string, accountAccessToken: string)
- confirms email update for intermediaryfor account byaccountAccessToken
. -
createPasswordValidationToken(password: string, accountAccessToken: string)
- creates password validation token for intermediary account bypassword
andaccountAccessToken
. -
updatePassword(oldPassword: string, newPassword: string, accountAccessToken: string)
- updates password forintermediary account. -
find(params: object)
- finds intermediary accounts byparams
object.
-
-
new DigifiApi.intermediaryEmailVerification(...)
- api for intermediary accounts email verification.-
sendVerificationEmail(accountAccessToken: string)
- sends verification email for intermediary account byaccountAccessToken
. -
verifyEmail(code: string, accountAccessToken: string)
- verifies email for intermediary account usingcode
byaccountAccessToken
.
-
-
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 bytoken
.
-
-
new DigifiApi.intermediaryPhoneVerification(...)
- api for borrower/intermediary phone verification management.-
sendMfaCode(phone: string, accountAccessToken: string)
- sends mfa code for intermediary account phone byaccountAccessToken
. -
verifyMfaCode(code: string, accountAccessToken: string)
- verifies mfa code for intermediary account byaccountAccessToken
.
-
-
new DigifiApi.intermediaryResetPassword(...)
- api for borrower/intermediary account reset password management.-
sendResetPasswordLink(email: string)
- sends reset password link to intermediary (depends onreference
passed to the service) account email. -
resetPassword(password: string, resetPasswordToken: string)
- resets password for intermediary account byresetPasswordToken
. -
getResetPasswordTokenInfo(resetPasswordToken: string)
- retrieves reset password token info for intermediary account byresetPasswordToken
.
-
-
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 byphoneVerificationCode
. -
sendPhoneVerificationCode(phone: string)
- sends phone verification code for intermediary account byphone
. -
validateToken(accountAccessToken: string)
- validates access token for intermediary account. -
logout(accountAccessToken: string)
- kills session associated with intermediary account byaccountAccessToken
. -
resignAccessToken(accountRefreshToken: string)
- resign access token for intermediary account byaccountRefreshToken
.
-
-
new DigifiApi.users(...)
- api for users management.-
find(params: object)
- finds organization users byparams
object.
-
-
new DigifiApi.variables(...)
- api for variables management.-
find(params: object)
- finds organization variables byparams
object.
-
-
new DigifiApi.decisions(...)
- api for decisions management.-
find(params; object)
- finds organization decisions byparams
object. -
findById(id: string)
- finds organization decision byid
. -
delete(id: string)
- deletes organization decision byid
.
-
-
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 byparams
object.
-
-
new DigifiApi.integrationFileDownload(...)
- api for integration files downloads management.-
downloadById(id: string)
- downloads integration result file byid
.
-
-
new DigifiApi.integrationProcessing(...)
- api for processing integrations.-
processIntegration(params: object)
- processes integration for current organization byparams
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 byparams
object. -
findById(id: string)
- finds integration result byid
. -
delete(id: string)
- deletes integration result byid
.
-
-
new DigifiApi.applicationDecisionProcessing(...)
- api for processing application decisions.-
makeDecision(params: object)
- processes application decision for current organization byparams
object.
-
-
new DigifiApi.applicationDocumentConfiguration(...)
- api for application document configuration management.-
find(productId: string)
- finds application document configurations for current organization and mode (depends onapi-key
provided to api client) byproductId
.
-
-
new DigifiApi.applicationDocuments(...)
- api for application documents management.-
find(params: object)
- finds application documents byparams
object. -
findById(id)
- finds application document byid
. -
create(params: object)
- uploads application document byparams
object. -
createMany(params: object)
- uploads few application documents byparams
object. -
update(id: string, params: object)
- updates application document byid
andparams
object. -
createFolder(params: object)
- creates application document folder byparams
. -
delete(id: string)
- deletes application document byid
.
-
-
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 bydocumentId
.
-
-
new DigifiApi.applicationIntegrationProcessing(...)
- api for processing application integrations.-
processIntegration(params: object)
- processes integration for application byparams
object.
-
-
new DigifiApi.applicationNotes(...)
- api for application notes management.-
find(params: object)
- finds application notes byparams
object. -
findById(id: string)
- finds application note byid
. -
create(params: object)
- creates application note byparams
object. -
update(id: string, params: object)
- updates application note byid
andparams
object. -
delete(id: string)
- deletes application note byid
.
-
-
new DigifiApi.applications(...)
- api for applications management.-
search(params: object)
- search applications byparams
object. -
list(params: object)
- lists applications byparams
object. -
findById(id: string)
- finds application byid
. -
findByDisplayId(displayId: string)
- finds application bydisplayId
. -
create(params: object)
- creates application byparams
object. -
update(id: string, params: object)
- updates application byid
andparams
object. -
delete(id: string)
- deletes application byid
. -
updateCoBorrowers(id: string, params: object)
- updates application co-borrowers byid
andparams
object. -
updateIntermediary(id: string, params: object)
- updates application intermediary byid
andparams
object. -
getVariables(id: string, variablesToInclude?: string[])
- retrieves application variables byid
(optional argumentvariablesToInclude
includes only specified variables). -
runCalculations(id: string, params: object)
- re-runs applications calculations byid
and optionalparams
object (providevariablesToRun
inparams
object to re-run only specified variables). -
addLabels(id: string, labelsIds: string[])
- adds labels to application byid
. -
addTeamMembers(id: string, teamMembersIds: string[])
- adds team members to application byid
. -
runAutomation(id: string, params: object)
- triggers automation workflow on application byid
andparams
object.
-
-
new DigifiApi.applicationStatuses(...)
- api for application statuses management.-
find(productId: string)
- finds application statuses for current organization and mode (depends onapi-key
provided to api client) byproductId
.
-
-
new DigifiApi.borrowers(...)
- api for borrowers management.-
search(params: object)
- search borrowers byparams
object. -
list(params: object)
- lists borrowers byparams
object. -
findById(id: string)
- finds borrower byid
. -
create(params: object)
- creates borrower byparams
object. -
update(id: string, params: object)
- updates borrower byid
andparams
object. -
delete(id: string)
- deletes borrower byid
.
-
-
new DigifiApi.comments(...)
- api for comments management.-
find(params: object)
- finds comments byparams
object. -
findById(id: string)
- finds comment byid
. -
create(params: object)
- creates comment byparams
object. -
update(id: string, params: object)
- updates comment byid
andparams
object. -
delete(id: string)
- deletes comment byid
.
-
-
new DigifiApi.intermediaries(...)
- api for intermediaries management.-
search(params: object)
- search intermediaries byparams
object. -
list(params: object)
- lists intermediaries byparams
object. -
findById(id: string)
- finds intermediary byid
. -
create(params: object)
- creates intermediary byparams
object. -
update(id: string, params: object)
- updates intermediary byid
andparams
object. -
delete(id: string)
- deletes intermediary byid
. -
getSuggestions(params: object)
- retrieves intermediary suggestions byparams
object. -
createMany(intermediaries: object[])
- creates few intermediaries.
-
-
new DigifiApi.layoutConfiguration(...)
- api for layout configuration management.-
find(params: object)
- finds layout configuration byparams
object.
-
-
new DigifiApi.productCalculations(...)
- api for product calculations management.-
find(productId: string)
- finds product calculations for current organization and mode (depends onapi-key
provided to api client) byproductId
.
-
-
new DigifiApi.products(...)
- api for products management.-
find(params: object)
- finds products for current organization and mode (depends onapi-key
provided to api client) byparams
. -
findById(id: string)
- finds product for current organization and mode (depends onapi-key
provided to api client) byid
.
-
-
new DigifiApi.tasks(...)
- api for application tasks management.-
search(params: object)
- search tasks byparams
object. -
list(params: object)
- lists tasks byparams
object. -
findById(id: string)
- finds task byid
. -
create(params: object)
- creates task byparams
object. -
update(id: string, params: object)
- updates task byid
andparams
object. -
delete(id: string)
- deletes task byid
. -
bulkCreate(params: object)
- creates many tasks byparams
object.
-
-
new DigifiApi.webhookEndpoints(...)
- api for webhooks management.-
find(params: object)
- finds webhook endpoints byparams
object. -
findById(id: string)
- finds webhook endpoints byid
. -
create(params: object)
- creates webhook endpoint byparams
object. -
update(id: string, params: object)
- updates webhook endpoints byid
andparams
object. -
delete(id: string)
- deletes webhook endpoint byid
.
-
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:
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`)
});
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.