Bkper

This is the main entry point of the bkper-js library.

You start by setting the API Config object.

Example:

Bkper.setConfig({
  apiKeyProvider: () => process.env.BKPER_API_KEY,
  oauthTokenProvider: () => process.env.BKPER_OAUTH_TOKEN
})

Once the config is set, you can start using the library.

getApps(): Promise<

App

[]>

Gets all Apps available for the user.

Returns The retrieved list of Apps

getBillingPortalUrl(returnUrl:

string

): Promise<

string

|

undefined

>

Gets the URL to redirect the User to the billing portal.

Returns The URL to redirect the User to the billing portal

Parameters:
Name
Description
returnUrl

The URL to return to after the User has been redirected to the billing portal

getBook(id:

string

, includeAccounts?:

boolean

): Promise<

Book

>

Gets the Book with the specified bookId from url param.

Returns The retrieved Book

Parameters:
Name
Description
id

The universal book id - The same bookId param of URL you access at app.bkper.com

includeAccounts

Optional parameter to include accounts in the retrieved Book

getBooks(query?:

string

): Promise<

Book

[]>

Gets all Books the user has access to.

Returns The retrieved list of Books

Parameters:
Name
Description
query

Optional search term to filter books

getCollections(): Promise<

Collection

[]>

Gets all Collections the user has access to.

Returns The retrieved list of Collections

getConversations(): Promise<

Conversation

[]>

Gets all Conversations available for the user.

Returns The retrieved list of Conversations

getTemplates(): Promise<

Template

[]>

Gets all Template available for the user.

Returns The retrieved list of Templates

getUser(): Promise<

User

>

Gets the current logged User.

Returns The retrieved User

setApiKey(key:

string

):

App

Sets the API key to identify the agent.

Returns The defined App object

deprecated ** Use setConfig() instead

Parameters:
Name
Description
key

The API key

setConfig(config:

Config

):

void

Sets the API Config object.

Parameters:
Name
Description
config

The Config object

setOAuthTokenProvider(oauthTokenProvider:): Promise<

void

>

Sets the provider of the valid OAuth2 access token

deprecated ** Use setConfig() instead

Account

This class defines an Account of a Book.

It maintains a balance of all amount credited and debited in it by Transactions.

An Account can be grouped by Groups.

addGroup(group:

Group

|

bkper.Group

):

Account

Adds a group to the Account.

Returns This Account, for chaining

Parameters:
Name
Description
group

The group to add

create(): Promise<

Account

>

Performs create new Account.

Returns Promise with this Account after creation

deleteProperty(key:

string

):

Account

Deletes a custom property.

Returns This Account, for chaining

Parameters:
Name
Description
key

The property key

getBalance():

Amount

Gets the balance based on credit nature of this Account.

Returns The balance of this Account.

deprecated ** Use Book.getBalancesReport instead.

getBalanceRaw():

Amount

Gets the raw balance, no matter credit nature of this Account.

Returns The balance of this Account.

deprecated ** Use Book.getBalancesReport instead.

getGroups(): Promise<

Group

[]>

Gets the Groups of this Account.

Returns Promise with the Groups of this Account

getId():

string

|

undefined

Gets the Account internal id.

Returns The Account internal id

getName():

string

|

undefined

Gets the Account name.

Returns The Account name

getNormalizedName():

string

Gets the normalized name of this Account without spaces or special characters.

Returns The name of this Account without spaces or special characters

getProperties(): any

Gets the custom properties stored in this Account.

Returns The custom properties object

getProperty(keys:

string

[]):

string

|

undefined

Gets the property value for given keys. First property found will be retrieved.

Returns The property value or undefined if not found

Parameters:
Name
Description
keys

The property key

getType():

AccountType

Gets the type of this Account.

Returns The AccountType of this Account

hasTransactionPosted():

boolean

|

undefined

Tells if the Account has any transaction already posted.

Accounts with transaction posted, even with zero balance, can only be archived.

Returns True if the Account has transactions posted

isArchived():

boolean

|

undefined

Tells if this Account is archived.

Returns True if the Account is archived

isCredit():

boolean

|

undefined

Tells if the Account has a Credit nature or Debit otherwise.

Credit Accounts are just for representation purposes. It increase or decrease the absolute balance. It doesn’t affect the overall balance or the behavior of the system.

The absolute balance of credit Accounts increase when it participate as a credit/origin in a transaction. Its usually for Accounts that increase the balance of the assets, like revenue Accounts.

        Crediting a credit
  Thus ---------------------> Account increases its absolute balance
        Debiting a debit


        Debiting a credit
  Thus ---------------------> Account decreases its absolute balance
        Crediting a debit

As a rule of thumb, and for simple understanding, almost all Accounts are Debit nature (NOT credit), except the ones that “offers” amount for the books, like revenue Accounts.

Returns True if the Account has credit nature

isInGroup(group:

string

|

Group

): Promise<

boolean

>

Tells if this Account is in the Group.

Returns Promise with true if the Account is in the group

Parameters:
Name
Description
group

The Group name, id or object

isPermanent():

boolean

|

undefined

Tells if the Account is permanent.

Permanent Accounts are the ones which final balance is relevant and keep its balances over time.

They are also called Real Accounts

Usually represents assets or tangibles, capable of being perceived by the senses or the mind, like bank Accounts, money, debts and so on.

Returns True if its a permanent Account

json():

bkper.Account

Gets an immutable copy of the JSON payload.

Returns An immutable copy of the json payload

remove(): Promise<

Account

>

Performs delete Account.

Returns Promise with this Account after deletion

removeGroup(group:

string

|

Group

): Promise<

Account

>

Removes a group from the Account.

Returns Promise with this Account, for chaining

Parameters:
Name
Description
group

The group name, id or object to remove

setArchived(archived:

boolean

):

Account

Sets Account archived/unarchived.

Returns This Account, for chaining

Parameters:
Name
Description
archived

True to archive, false to unarchive

setGroups(groups:

Group

[] |

bkper.Group

[]):

Account

Sets the groups of the Account.

Returns This Account, for chaining

Parameters:
Name
Description
groups

The groups to set

setName(name:

string

):

Account

Sets the name of the Account.

Returns This Account, for chaining

Parameters:
Name
Description
name

The name to set

setProperties(properties: any):

Account

Sets the custom properties of the Account.

Returns This Account, for chaining

Parameters:
Name
Description
properties

Object with key/value pair properties

setProperty(key:

string

, value:

string

|

null

):

Account

Sets a custom property in the Account.

Returns This Account, for chaining

Parameters:
Name
Description
key

The property key

value

The property value

setType(type:

AccountType

):

Account

Sets the type of the Account.

Returns This Account, for chaining

Parameters:
Name
Description
type

The AccountType to set

update(): Promise<

Account

>

Performs update Account, applying pending changes.

Returns Promise with this Account after update

Agent

Defines an Agent on Bkper.

An Agent represents an entity (such as an App or Bot) that interacts with Bkper, executing actions on behalf of users.

getId():

string

|

undefined

Gets the Agent universal identifier.

Returns The Agent universal identifier

getLogoUrl():

string

|

undefined

Gets the Agent logo URL.

Returns The Agent logo url

getLogoUrlDark():

string

|

undefined

Gets the Agent logo URL in dark mode.

Returns The Agent logo url in dark mode

getName():

string

|

undefined

Gets the Agent name.

Returns The Agent name

json():

bkper.Agent

Gets the wrapped plain JSON object.

Returns The wrapped plain json object

Amount

This class defines an Amount for arbitrary-precision decimal arithmetic.

It inherits methods from big.js library

abs():

Amount

Returns an absolute Amount.

Returns The absolute value as a new Amount

cmp(n:

number

|

string

|

Amount

):

-1

|

0

|

1

Compares this Amount with another value.

Returns -1 if less than, 0 if equal, 1 if greater than

Parameters:
Name
Description
n

The value to compare with

div(n:

number

|

string

|

Amount

):

Amount

Divides this Amount by another value.

Returns The division result as a new Amount

Parameters:
Name
Description
n

The divisor value

eq(n:

number

|

string

|

Amount

):

boolean

Checks if this Amount equals another value.

Returns True if equal, false otherwise

Parameters:
Name
Description
n

The value to compare with

gt(n:

number

|

string

|

Amount

):

boolean

Checks if this Amount is greater than another value.

Returns True if greater than, false otherwise

Parameters:
Name
Description
n

The value to compare with

gte(n:

number

|

string

|

Amount

):

boolean

Checks if this Amount is greater than or equal to another value.

Returns True if greater than or equal, false otherwise

Parameters:
Name
Description
n

The value to compare with

lt(n:

number

|

string

|

Amount

):

boolean

Checks if this Amount is less than another value.

Returns True if less than, false otherwise

Parameters:
Name
Description
n

The value to compare with

lte(n:

number

|

string

|

Amount

):

boolean

Checks if this Amount is less than or equal to another value.

Returns True if less than or equal, false otherwise

Parameters:
Name
Description
n

The value to compare with

minus(n:

number

|

string

|

Amount

):

Amount

Subtracts another value from this Amount.

Returns The difference as a new Amount

Parameters:
Name
Description
n

The value to subtract

mod(n:

number

|

string

|

Amount

):

Amount

Calculates the modulo (remainder) of dividing this Amount by another value.

Similar to % operator

Returns The remainder as a new Amount

Parameters:
Name
Description
n

The divisor value

plus(n:

number

|

string

|

Amount

):

Amount

Adds another value to this Amount.

Returns The sum as a new Amount

Parameters:
Name
Description
n

The value to add

round(dp?:

number

):

Amount

Rounds this Amount to a maximum of dp decimal places.

Returns The rounded value as a new Amount

Parameters:
Name
Description
dp

The number of decimal places (optional)

times(n:

number

|

string

|

Amount

):

Amount

Multiplies this Amount by another value.

Returns The product as a new Amount

Parameters:
Name
Description
n

The value to multiply by

toFixed(dp?:

number

):

string

Returns a string representing the value of this Amount in normal notation to a fixed number of decimal places.

Returns The formatted string representation

Parameters:
Name
Description
dp

The number of decimal places (optional)

toNumber():

number

Returns a primitive number representing the value of this Amount.

Returns The numeric value of this Amount

toString():

string

Returns a string representing the value of this Amount.

Returns The string representation of this Amount

App

Defines an App on Bkper.

Apps can be installed on Books by users.

create(): Promise<

App

>

Performs the app creation, applying pending changes.

The App id MUST be unique. If another app is already existing, an error will be thrown.

Returns This App after creation

getDescription():

string

|

undefined

Gets the description of this App.

Returns The description of this App

getEvents():

EventType

[] |

undefined

Gets the events bound to this App.

Returns The events bound to this App

getFilePatterns():

string

[] |

undefined

Gets the file patterns the App handles.

Returns The file patterns the App handles - E.g *.pdf *.csv

getId():

string

|

undefined

Gets the App universal identifier.

Returns The App universal identifier

getLogoUrl():

string

|

undefined

Gets the logo url of this App.

Returns The logo url of this App

getLogoUrlDark():

string

|

undefined

Gets the logo url of this App in dark mode.

Returns The logo url of this App in dark mode

getMenuPopupHeight():

string

|

undefined

Gets the menu popup height of this App.

Returns The menu popup height of this App

getMenuPopupWidth():

string

|

undefined

Gets the menu popup width of this App.

Returns The menu popup width of this App

getMenuText():

string

|

undefined

Gets the menu text of this App.

Returns The menu text of this App

getMenuUrl():

string

|

undefined

Gets the menu url of this App.

Returns The menu url of this App

getMenuUrlDev():

string

|

undefined

Gets the menu development url of this App.

Returns The menu development url of this App

getName():

string

|

undefined

Gets the name of this App.

Returns The name of this App

getOwnerLogoUrl():

string

|

undefined

Gets the logo url of the owner of this App.

Returns The logo url of the owner of this App

getOwnerName():

string

|

undefined

Gets the name of the owner of this App.

Returns The name of the owner of this App

hasEvents():

boolean

Checks if this App has events bound to it.

Returns True if this App has events bound to it

isConversational():

boolean

Checks if this App is conversational.

Returns True if this App is conversational

isPublished():

boolean

Checks if this App is published.

Returns True if this App is published

json():

bkper.App

Gets the wrapped plain JSON object.

Returns The wrapped plain json object

patch(): Promise<

App

>

Partially updates an App, applying pending changes.

Returns This App after the partial update

setClientSecret(clientSecret?:

string

):

App

Sets the client secret.

Returns This App for chaining

Parameters:
Name
Description
clientSecret

The client secret to set

setConversationUrlDev(conversationUrlDev:

string

):

App

Sets the conversation url for development.

Returns This App, for chaining

Parameters:
Name
Description
conversationUrlDev

The conversation URL for development

setDeveloperEmail(email?:

string

):

App

Sets the developer email.

Returns This App for chaining

Parameters:
Name
Description
email

The developer email to set

setReadme(readme?:

string

):

App

Sets the readme text.

Returns This App for chaining

Parameters:
Name
Description
readme

The readme text to set

setUserEmails(emails?:

string

):

App

Sets the whitelabeled user emails.

Returns This App for chaining

Parameters:
Name
Description
emails

The user emails to whitelist

setWebhookUrlDev(webhookUrlDev:

string

):

App

Sets the webhook url for development.

Returns This App, for chaining

Parameters:
Name
Description
webhookUrlDev

The webhook URL for development

update(): Promise<

App

>

Performs a full update of the App, applying pending changes.

Returns This App after the update

BalancesReport

Class representing a Balance Report, generated when calling Book.getBalanceReport

getBalancesContainer(name:

string

):

BalancesContainer

Gets a specific BalancesContainer.

Returns The retrieved BalancesContainer

Parameters:
Name
Description
name

The Account or Group name

getBalancesContainers():

BalancesContainer

[]

Gets all BalancesContainers of the report.

Returns All BalancesContainers of the report

getBook():

Book

Gets the Book that generated the report.

Returns The Book that generated the report

getPeriodicity():

Periodicity

Gets the Periodicity of the query used to generate the report.

Returns The Periodicity of the query used to generate the report

Book

A Book represents a General Ledger for a company or business, but can also represent a Ledger for a project or department

It contains all Accounts where Transactions are recorded/posted;

audit():

void

Trigger Balances Audit async process.

batchCheckTransactions(transactions:

Transaction

[]): Promise<

void

>

Batch check Transactions on the Book.

Parameters:
Name
Description
transactions

The transactions to be checked

batchCreateAccounts(accounts:

Account

[]): Promise<

Account

[]>

Create Accounts on the Book, in batch.

Returns The created Accounts

Parameters:
Name
Description
accounts

The accounts to be created

batchCreateGroups(groups:

Group

[]): Promise<

Group

[]>

Create Groups on the Book, in batch.

Returns The created Groups

Parameters:
Name
Description
groups

The groups to be created

batchCreateTransactions(transactions:

Transaction

[]): Promise<

Transaction

[]>

Batch create Transactions on the Book.

Returns The created Transactions

Parameters:
Name
Description
transactions

The transactions to be created

batchPostTransactions(transactions:

Transaction

[]): Promise<

void

>

Batch post Transactions on the Book.

Parameters:
Name
Description
transactions

The transactions to be posted

batchReplayEvents(events:

Event

[], errorOnly?:

boolean

): Promise<

void

>

Replay Events on the Book, in batch.

Parameters:
Name
Description
events

The events to be replayed

errorOnly

True to only replay events with errors

batchTrashTransactions(transactions:

Transaction

[], trashChecked?:

boolean

): Promise<

void

>

Batch trash Transactions on the Book.

Parameters:
Name
Description
transactions

The transactions to be trashed

trashChecked

True to also trash checked transactions

batchUncheckTransactions(transactions:

Transaction

[]): Promise<

void

>

Batch uncheck Transactions on the Book.

Parameters:
Name
Description
transactions

The transactions to be unchecked

batchUntrashTransactions(transactions:

Transaction

[]): Promise<

void

>

Batch untrash Transactions on the Book.

Parameters:
Name
Description
transactions

The transactions to be untrashed

batchUpdateTransactions(transactions:

Transaction

[], updateChecked?:

boolean

): Promise<

Transaction

[]>

Batch update Transactions on the Book.

Returns The updated draft Transactions

Parameters:
Name
Description
transactions

The transactions to be updated

updateChecked

True to also update checked transactions

copy(name:

string

, copyTransactions?:

boolean

, fromDate?:

number

): Promise<

Book

>

Creates a copy of this Book

Returns The copied Book object

Parameters:
Name
Description
name

The name for the copied book

copyTransactions

True to copy transactions from the source book (user must be the Book owner)

fromDate

Start date to consider if copying transactions (numeric value in YYYYMMDD format)

create(): Promise<

Book

>

Performs create new Book.

Returns The created Book object

createIntegration(integration:

bkper.Integration

|

Integration

): Promise<

Integration

>

Creates a new Integration in the Book.

Returns The created Integration object

Parameters:
Name
Description
integration

The Integration object or wrapped plain json

formatDate(date:

Date

, timeZone?:

string

):

string

Formats a date according to date pattern of the Book.

Returns The formatted date

Parameters:
Name
Description
date

The date to format as string.

timeZone

The output timezone of the result. Default to script’s timeZone

formatValue(value:

Amount

|

number

|

null

|

undefined

):

string

Formats a value according to DecimalSeparator and fraction digits of the Book.

Returns The formatted value

Parameters:
Name
Description
value

The value to be formatted.

getAccount(idOrName?:

string

): Promise<

Account

|

undefined

>

Gets an Account object.

Returns The matching Account object

Parameters:
Name
Description
idOrName

The id or name of the Account

getAccounts(): Promise<

Account

[]>

Gets all Accounts of this Book.

Returns The retrieved Account objects

getApps(): Promise<

App

[]>

Retrieve installed Apps for this Book.

Returns The retrieved Apps objects

getAutoPost():

boolean

|

undefined

Gets the auto post status of the Book.

Returns The auto post status of the Book

getBalancesReport(query:

string

): Promise<

BalancesReport

>

Create a BalancesReport based on query.

Returns The balances report

Example:

var book = BkperApp.getBook("agtzfmJrcGVyLWhyZHITCxIGTGVkZ2VyGICAgPXjx7oKDA");

var balancesReport = book.getBalancesReport("group:'Equity' after:7/2018 before:8/2018");

var accountBalance = balancesReport.getBalancesContainer("Bank Account").getCumulativeBalance();

Parameters:
Name
Description
query

The balances report query

getClosingDate():

string

|

undefined

Gets the closing date of the Book in ISO format yyyy-MM-dd.

Returns The closing date of the Book in ISO format yyyy-MM-dd

getCollection():

Collection

|

undefined

Gets the collection of this Book, if any.

Returns The collection of this Book, if any

getDatePattern():

string

|

undefined

Gets the date pattern of the Book.

Returns The date pattern of the Book. Current: dd/MM/yyyy MM/dd/yyyy yyyy/MM/dd

getDecimalPlaces():

number

|

undefined

Gets the number of decimal places supported by this Book.

Returns The number of decimal places supported by this Book. Same as getFractionDigits

getDecimalSeparator():

DecimalSeparator

Gets the decimal separator of the Book.

Returns The decimal separator of the Book

getFile(id:

string

): Promise<

File

>

Retrieve a file by id.

Returns The File object

Parameters:
Name
Description
id

The file ID

getFractionDigits():

number

|

undefined

Gets the number of fraction digits supported by this Book.

Returns The number of fraction digits supported by this Book. Same as getDecimalPlaces

getGroup(idOrName?:

string

): Promise<

Group

|

undefined

>

Gets a Group object.

Returns The matching Group object

Parameters:
Name
Description
idOrName

The id or name of the Group

getGroups(): Promise<

Group

[]>

Gets all Groups of this Book.

Returns The retrieved Group objects

getId():

string

Gets the unique identifier of this Book.

Returns This Book’s unique identifier

getIntegrations(): Promise<

Integration

[]>

Gets the existing Integrations in the Book.

Returns The retrieved Integration objects

getLastUpdateMs():

number

|

undefined

Gets the last update date of the book, in milliseconds.

Returns The last update date of the book, in milliseconds

getLockDate():

string

|

undefined

Gets the lock date of the Book in ISO format yyyy-MM-dd.

Returns The lock date of the Book in ISO format yyyy-MM-dd

getName():

string

|

undefined

Gets the name of this Book.

Returns The name of this Book

getOwnerName():

string

|

undefined

Gets the name of the owner of the Book.

Returns The name of the owner of the Book

getPageSize():

number

|

undefined

Gets the transactions pagination page size.

Returns The transactions pagination page size

getPeriod():

Period

Gets the period slice for balances visualization.

Returns The period slice for balances visualization

getPeriodStartMonth():

Month

Gets the start month when YEAR period is set.

Returns The start month when YEAR period is set

getPermission():

Permission

Gets the permission for the current user in this Book.

Returns The permission for the current user in this Book

getProperties(): any

Gets the custom properties stored in this Book.

Returns The custom properties object

getProperty(keys:

string

[]):

string

|

undefined

Gets the property value for given keys. First property found will be retrieved.

Returns The property value or undefined if not found

Parameters:
Name
Description
keys

The property keys to search for

getSavedQueries(): Promise<

Query

[]>

Gets the saved queries from this book.

Returns The saved queries from this book

getTimeZone():

string

|

undefined

Gets the time zone of the Book.

Returns The time zone of the Book

getTimeZoneOffset():

number

|

undefined

Gets the time zone offset of the book, in minutes.

Returns The time zone offset of the book, in minutes

getTotalTransactions():

number

Gets the total number of posted transactions.

Returns The total number of posted transactions

getTotalTransactionsCurrentMonth():

number

Gets the total number of posted transactions on current month.

Returns The total number of posted transactions on current month

getTotalTransactionsCurrentYear():

number

Gets the total number of posted transactions on current year.

Returns The total number of posted transactions on current year

getTransaction(id:

string

): Promise<

Transaction

|

undefined

>

Retrieve a transaction by id.

Returns The Transaction object

Parameters:
Name
Description
id

The transaction ID

getVisibility():

Visibility

Gets the visibility of the book.

Returns The visibility of the book

json():

bkper.Book

Gets an immutable copy of the JSON payload for this Book.

Returns An immutable copy of the JSON payload

listEvents(afterDate:

string

|

null

, beforeDate:

string

|

null

, onError:

boolean

, resourceId:

string

|

null

, limit:

number

, cursor?:

string

): Promise<

EventList

>

Lists events in the Book based on the provided parameters.

Returns An EventList object containing the list of events

Parameters:
Name
Description
afterDate

The start date (inclusive) for the events search range, in RFC3339 format. Can be null

beforeDate

The end date (exclusive) for the events search range, in RFC3339 format. Can be null

onError

True to search only for events on error

resourceId

The ID of the event’s resource (Transaction, Account, or Group). Can be null

limit

The maximum number of events to return

cursor

The cursor for pagination. Can be null

listTransactions(query?:

string

, limit?:

number

, cursor?:

string

): Promise<

TransactionList

>

Lists transactions in the Book based on the provided query, limit, and cursor, for pagination.

Returns A TransactionList object containing the list of transactions

Parameters:
Name
Description
query

The query string to filter transactions

limit

The maximum number of transactions to return. Default to 100, max to 1000

cursor

The cursor for pagination

parseDate(date:

string

):

Date

Parse a date string according to date pattern and timezone of the Book. Also parse ISO yyyy-mm-dd format.

Returns The parsed Date object

Parameters:
Name
Description
date

The date string to parse

parseValue(value:

string

):

Amount

|

undefined

Parse a value string according to DecimalSeparator and fraction digits of the Book.

Returns The parsed Amount or undefined if parsing fails

Parameters:
Name
Description
value

The value string to parse

round(value:

Amount

|

number

):

Amount

Rounds a value according to the number of fraction digits of the Book.

Returns The rounded value

Parameters:
Name
Description
value

The value to be rounded

setAutoPost(autoPost:

boolean

):

Book

Sets the auto post status of the Book.

Returns This Book, for chaining

setClosingDate(closingDate:

string

|

null

):

Book

Sets the closing date of the Book in ISO format yyyy-MM-dd.

Returns This Book, for chaining

setDatePattern(datePattern:

string

):

Book

Sets the date pattern of the Book. Current: dd/MM/yyyy MM/dd/yyyy yyyy/MM/dd

Returns This Book, for chaining

setDecimalSeparator(decimalSeparator:

DecimalSeparator

):

Book

Sets the decimal separator of the Book

Returns This Book, for chaining

setFractionDigits(fractionDigits:

number

):

Book

Sets the number of fraction digits (decimal places) supported by this Book.

Returns This Book, for chaining

Parameters:
Name
Description
fractionDigits

The number of fraction digits to set (0 to 8)

setLockDate(lockDate:

string

|

null

):

Book

Sets the lock date of the Book in ISO format yyyy-MM-dd.

Returns This Book, for chaining

setName(name:

string

):

Book

Sets the name of the Book.

Returns This Book, for chaining

Parameters:
Name
Description
name

The name to set

setPageSize(pageSize:

number

):

Book

Sets the transactions pagination page size.

Returns This Book, for chaining

Parameters:
Name
Description
pageSize

The page size to set

setPeriod(period:

Period

):

Book

Sets the period slice for balances visualization.

Returns This Book, for chaining

Parameters:
Name
Description
period

The period to set

setPeriodStartMonth(month:

Month

):

Book

Sets the start month when YEAR period is set.

Returns This Book, for chaining

Parameters:
Name
Description
month

The start month to set

setProperties(properties: any):

Book

Sets the custom properties of the Book.

Returns This Book, for chaining

Parameters:
Name
Description
properties

Object with key/value pair properties

setProperty(key:

string

, value:

string

|

null

):

Book

Sets a custom property in the Book.

Returns This Book, for chaining

Parameters:
Name
Description
key

The property key

value

The property value

setTimeZone(timeZone:

string

):

Book

Sets the time zone of the Book.

Returns This Book, for chaining

update(): Promise<

Book

>

Perform update Book, applying pending changes.

Returns The updated Book object

updateIntegration(integration:

bkper.Integration

): Promise<

Integration

>

Updates an existing Integration in the Book.

Returns The updated Integration object

Parameters:
Name
Description
integration

The Integration wrapped plain json

BotResponse

This class defines a Bot Response associated to an Event.

getAgentId():

string

|

undefined

Gets the agent id of this Bot Response.

Returns The agent id of this Bot Response

getCreatedAt():

Date

|

undefined

Gets the date this Bot Response was created.

Returns The date this Bot Response was created

getEvent():

Event

Gets the Event this Bot Response is associated to.

Returns The Event this Bot Response is associated to

getMessage():

string

|

undefined

Gets the message of this Bot Response.

Returns The message of this Bot Response

getType():

BotResponseType

|

undefined

Gets the type of this Bot Response.

Returns The type of this Bot Response

remove(): Promise<

BotResponse

>

Delete this Bot Response.

Returns The deleted Bot Response

replay(): Promise<

BotResponse

>

Replay this Bot Response.

Returns The updated Bot Response

Collection

This class defines a Collection of Books.

addBooks(books:

Book

[]): Promise<

Book

[]>

Adds Books to this Collection.

Returns The added Book objects

Parameters:
Name
Description
books

The Books to add to this Collection

create(): Promise<

Collection

>

Performs create new Collection.

Returns The created Collection object

getBooks():

Book

[]

Gets all Books of this collection.

Returns All Books of this collection

getId():

string

|

undefined

Gets the unique identifier of this Collection.

Returns The id of this Collection

getName():

string

|

undefined

Gets the name of this Collection.

Returns The name of this Collection

getOwnerUsername():

string

|

undefined

Gets the username of the owner of this Collection

Returns The Collection’s owner username

getPermission():

Permission

|

undefined

Gets the user permission for this Collection

Returns The permission for the current user

getUpdatedAt():

string

|

undefined

Gets the last update date of this Collection

Returns The Collection’s last update timestamp, in milliseconds

json():

bkper.Collection

Gets an immutable copy of the JSON payload for this Collection.

Returns The wrapped plain json object

remove(): Promise<

Book

[]>

Performs delete Collection.

Returns The list of Books the user has access to that were affected by the deletion of this Collection

removeBooks(books:

Book

[]): Promise<

Book

[]>

Removes Books from this Collection.

Returns The removed Book objects

Parameters:
Name
Description
books

The Books to remove from this Collection

setName(name:

string

):

Collection

Sets the name of the Collection.

Returns This Collection, for chaining

Parameters:
Name
Description
name

The name to set

update(): Promise<

Collection

>

Performs update Collection, applying pending changes.

Returns The updated Collection object

Connection

This class defines a Connection from an User to an external service.

clearTokenProperties():

void

Cleans any token property stored in the Connection.

create(): Promise<

Connection

>

Performs create new Connection.

Returns The created Connection, for chaining

deleteProperty(key:

string

):

Connection

Deletes a custom property stored in the Connection.

Returns The Connection, for chaining

Parameters:
Name
Description
key

The property key

getAgentId():

string

|

undefined

Gets the agentId of the Connection.

Returns The Connection’s agentId

getDateAddedMs():

string

|

undefined

Gets the date when the Connection was added.

Returns The Connection add date in milliseconds

getEmail():

string

|

undefined

Gets the email of the owner of the Connection.

Returns The Connection owner’s email

getId():

string

|

undefined

Gets the id of the Connection.

Returns The Connection’s id

getIntegrations(): Promise<

Integration

[]>

Gets the existing Integrations on the Connection.

Returns The existing Integration objects

Gets the logo of the Connection.

Returns The Connection logo

getName():

string

|

undefined

Gets the name of the Connection.

Returns The Connection name

getProperties(): any

Gets the custom properties stored in the Connection

Returns Object with key/value pair properties

getProperty(keys:

string

[]):

string

|

undefined

Gets the property value for given keys. First property found will be retrieved.

Returns The retrieved property value

Parameters:
Name
Description
keys

The property key

getPropertyKeys():

string

[]

Gets the custom properties keys stored in the Connection.

Returns The retrieved property keys

getType(): | |

undefined

Gets the type of the Connection.

Returns The Connection type

getUUID():

string

|

undefined

Gets the universal unique identifier of this Connection.

Returns The Connection’s universal unique identifier name

json():

bkper.Connection

Gets an immutable copy of the JSON payload for this Connection.

Returns An immutable copy of the json payload

remove(): Promise<

Connection

>

Performs remove Connection.

Returns The removed Connection object

setAgentId(agentId:

string

):

Connection

Sets the Connection agentId.

Returns The Connection, for chaining

Parameters:
Name
Description
agentId

The Connection agentId

setName(name:

string

):

Connection

Sets the name of the Connection.

Returns The Connection, for chaining

Parameters:
Name
Description
name

The name of the Connection

setProperties(properties: any):

Connection

Sets the custom properties of the Connection.

Returns The Connection, for chaining

Parameters:
Name
Description
properties

Object with key/value pair properties

setProperty(key:

string

, value:

string

|

null

):

Connection

Sets a custom property in the Connection.

Returns The Connection, for chaining

Parameters:
Name
Description
key

The property key

value

The property value

setType(type: |):

Connection

Sets the Connection type.

Returns The Connection, for chaining

Parameters:
Name
Description
type

The Connection type

setUUID(uuid:

string

):

Connection

Sets the universal unique identifier of the Connection.

Returns The Connection, for chaining

Parameters:
Name
Description
uuid

The universal unique identifier of the Connection

Conversation

Defines a Conversation on Bkper.

A Conversation represents an interaction between Users and Apps.

create(): Promise<

Conversation

>

Performs create Conversation.

Returns The created Conversation object

getAgent():

Agent

Gets the Agent associated to this Conversation.

Returns The Agent associated to this Conversation

getCreatedAt():

Date

|

undefined

Gets the Date the Conversation was created.

Returns The Date the Conversation was created

getId():

string

|

undefined

Gets the Conversation universal identifier.

Returns The Conversation universal identifier

getMessages(): Promise<

Message

[]>

Gets the Messages that compose this Conversation.

Returns The Messages in this Conversation

getTitle():

string

|

undefined

Gets the title of the Conversation.

Returns The title of the Conversation

getUpdatedAt():

Date

|

undefined

Gets the Date the Conversation was last updated.

Returns The Date the Conversation was last updated

json():

bkper.Conversation

Gets an immutable copy of the JSON payload for this Conversation.

Returns The wrapped plain json object

Event

This class defines an Event from a Book.

An event is an object that represents an action (such as posting or deleting a Transaction) made by an actor (such as a user or a Bot acting on behalf of a user).

getAgent():

Agent

|

undefined

Gets the Agent who performed the Event.

Returns The Agent who performed the Event

getBook():

Book

Gets the book in which the Event was created.

Returns The book in which the Event was created

getBotResponses():

BotResponse

[]

Gets the Bot Responses associated to this Event.

Returns The Bot Responses associated to this Event

getCreatedAt():

Date

|

undefined

Gets the date the Event was created.

Returns The date the Event was created

getId():

string

|

undefined

Gets the id of the Event.

Returns The id of the Event

getType():

EventType

|

undefined

Gets the type of the Event.

Returns The type of the Event

getUser():

User

|

undefined

Gets the user who performed the Event.

Returns The user who performed the Event

hasErrorResponse():

boolean

Checks if this Event has at least one Bot Response of type ERROR.

Returns True if this Event has at least one Bot Response of type ERROR

json():

bkper.Event

Gets an immutable copy of the JSON payload for this Event.

Returns The wrapped plain json object

EventList

A list associated with an event query.

getCursor():

string

|

undefined

Gets the cursor associated with the query for pagination.

Returns The cursor associated with the query for pagination

getFirst():

Event

|

undefined

Gets the first Event in the list.

Returns The first Event in the list

getItems():

Event

[]

Get the events in the list.

Returns An array of Event objects

size():

number

Get the total number of events in the list.

Returns The total number of events

File

This class defines a File uploaded to a Book.

A File can be attached to a Transaction or used to import data.

create(): Promise<

File

>

Perform create new File.

Returns The created File object

getContent(): Promise<

string

|

undefined

>

Gets the file content Base64 encoded.

Returns The file content Base64 encoded

getContentType():

string

|

undefined

Gets the File content type.

Returns The File content type

getId():

string

|

undefined

Gets the File id.

Returns The File id

getName():

string

|

undefined

Gets the File name.

Returns The File name

getSize():

number

|

undefined

Gets the file size in bytes.

Returns The file size in bytes

getUrl():

string

|

undefined

Gets the file serving url for accessing via browser.

Returns The file serving url

json():

bkper.File

Gets an immutable copy of the JSON payload for this File.

Returns An immutable copy of the json payload

setContent(content:

string

):

File

Sets the File content Base64 encoded.

Returns This File, for chaining

Parameters:
Name
Description
content

The content to set (Base64 encoded)

setContentType(contentType:

string

):

File

Sets the File content type.

Returns This File, for chaining

Parameters:
Name
Description
contentType

The content type to set

setName(name:

string

):

File

Sets the name of the File.

Returns This File, for chaining

Parameters:
Name
Description
name

The name to set

Group

This class defines a Group of Accounts.

Accounts can be grouped by different meaning, like Expenses, Revenue, Assets, Liabilities and so on

Its useful to keep organized and for high level analysis.

create(): Promise<

Group

>

Performs create new group.

Returns A promise that resolves to this Group

deleteProperty(key:

string

):

Group

Delete a custom property

Returns This Group, for chaining

Parameters:
Name
Description
key

The property key

getAccounts(): Promise<

Account

[]>

Gets all Accounts of this group.

Returns All Accounts of this group

getChildren():

Group

[]

Gets the children of the Group.

Returns An array of child Groups

getDepth():

number

Gets the depth of the Group in the hierarchy.

Returns The depth of the Group

getDescendantTreeIds():

Set

Gets the IDs of all descendant Groups in a tree structure.

Returns A set of descendant Group IDs

getDescendants():

Set

Gets all descendant Groups of the current Group.

Returns A set of descendant Groups

getId():

string

|

undefined

Gets the id of this Group.

Returns The id of this Group

getName():

string

|

undefined

Gets the name of this Group.

Returns The name of this Group

getNormalizedName():

string

Gets the normalized name of this group without spaces and special characters.

Returns The name of this group without spaces and special characters

getParent():

Group

|

undefined

Gets the parent Group.

Returns The parent Group

getProperties(): any

Gets the custom properties stored in this Group.

Returns The custom properties as a key/value object

getProperty(keys:

string

[]):

string

|

undefined

Gets the property value for given keys. First property found will be retrieved.

Returns The property value, or undefined if not found

Parameters:
Name
Description
keys

The property key

getRoot():

Group

Gets the root Group of the current Group.

Returns The root Group

getRootName():

string

Gets the name of the root Group.

Returns The name of the root Group

getType():

AccountType

Gets the type of the accounts of this group.

Returns The type for of the accounts of this group. Null if mixed

hasAccounts():

boolean

|

undefined

Tells if this group has any account in it.

Returns True if this group has any account in it

hasChildren():

boolean

Checks if the Group has any children.

Returns True if the Group has children, otherwise false

hasParent():

boolean

Checks if the Group has a parent.

Returns True if the Group has a parent, otherwise false

isCredit():

boolean

|

undefined

Tells if this is a credit (Incoming and Liabilities) group.

Returns True if this is a credit group

isHidden():

boolean

|

undefined

Tells if the Group is hidden on main transactions menu.

Returns True if the Group is hidden, false otherwise

isLeaf():

boolean

Checks if the Group is a leaf node (i.e., has no children).

Returns True if the Group is a leaf, otherwise false

isLocked():

boolean

Tells if the Group is locked by the Book owner.

Returns True if the Group is locked

isMixed():

boolean

|

undefined

Tells if this is a mixed (Assets/Liabilities or Incoming/Outgoing) group.

Returns True if this is a mixed group

isPermanent():

boolean

|

undefined

Tells if the Group is permanent.

Returns True if the Group is permanent

isRoot():

boolean

Checks if the Group is a root node (i.e., has no parent).

Returns True if the Group is a root, otherwise false

json():

bkper.Group

Gets an immutable copy of the json payload.

Returns An immutable copy of the json payload

remove(): Promise<

Group

>

Performs delete group.

Returns A promise that resolves to this Group

setHidden(hidden:

boolean

):

Group

Hide/Show group on main menu.

Returns This Group, for chaining

Parameters:
Name
Description
hidden

Whether to hide the group

setLocked(locked:

boolean

):

Group

Sets the locked state of the Group.

Returns This Group, for chaining

Parameters:
Name
Description
locked

The locked state of the Group.

setName(name:

string

):

Group

Sets the name of the Group.

Returns This Group, for chaining

setParent(group:

Group

|

null

|

undefined

):

Group

Sets the parent Group.

Returns This Group, for chaining

Parameters:
Name
Description
group

The parent Group to set

setProperties(properties: any):

Group

Sets the custom properties of the Group

Returns This Group, for chaining

Parameters:
Name
Description
properties

Object with key/value pair properties

setProperty(key:

string

, value:

string

|

null

):

Group

Sets a custom property in the Group.

Returns This Group, for chaining

Parameters:
Name
Description
key

The property key

value

The property value

update(): Promise<

Group

>

Performs update group, applying pending changes.

Returns A promise that resolves to this Group

Integration

This class defines a Integration from an User to an external service.

deleteProperty(key:

string

):

Integration

Deletes a custom property stored in the Integration.

Returns The Integration, for chaining

Parameters:
Name
Description
key

The property key

getAddedBy():

string

|

undefined

Gets the name of the user who added the Integration.

Returns The user name of who added the Integration

getAgentId():

string

|

undefined

Gets the agent id of the Integration.

Returns The Integration’s agent id

getBookId():

string

|

undefined

Gets the Book id of the Integration.

Returns The Integration’s Book id

getDateAddedMs():

string

|

undefined

Gets the date when the Integration was added.

Returns The Integration add date in milliseconds

getId():

string

|

undefined

Gets the id of the Integration.

Returns This Integration’s id

getLastUpdateMs():

string

|

undefined

Gets the date when the Integration was last updated.

Returns The Integration last update date in milliseconds

Gets the logo of the Integration.

Returns The Integration’s logo

getName():

string

|

undefined

Gets the name of the Integration.

Returns The Integration’s name

getProperties(): any

Gets the custom properties stored in the Integration.

Returns Object with key/value pair properties

getProperty(keys:

string

[]):

string

|

undefined

Gets the property value for given keys. First property found will be retrieved.

Returns The retrieved property value

Parameters:
Name
Description
keys

The property key

json():

bkper.Integration

Gets an immutable copy of the JSON payload for this Integration.

Returns An immutable copy of the json payload

remove(): Promise<

Integration

>

Performs remove Integration.

Returns The removed Integration object

setProperties(properties: any):

Integration

Sets the custom properties of the Integration.

Returns The Integration, for chaining

Parameters:
Name
Description
properties

Object with key/value pair properties

setProperty(key:

string

, value:

string

|

null

):

Integration

Sets a custom property in the Integration.

Returns The Integration, for chaining

Parameters:
Name
Description
key

The property key

value

The property value

Message

Defines a Message on Bkper.

A Message is a building block of a Conversation.

create(): Promise<

Message

>

Creates the Message and receives the synchronous Agent response.

Returns The Agent response Message, with the created Message as its parent

deleteProperty(key:

string

):

Message

Deletes a custom property from the Message.

Returns This Message, for chaining

Parameters:
Name
Description
key

The property key

getAgent():

Agent

|

undefined

Gets the Agent associated with the Message.

Returns The Agent associated with the Message, if any

getContent():

string

|

undefined

Gets the text content of the Message.

Returns The text content of the Message

getConversation():

Conversation

Gets the Conversation of the Message.

Returns The Conversation of the Message

getCreatedAt():

Date

|

undefined

Gets the Date the Message was created.

Returns The Date the Message was created

getId():

string

|

undefined

Gets the Message universal identifier.

Returns The Message universal identifier

getProperties(): any

Gets the custom properties stored in this Message.

Returns The custom properties stored in this Message

getProperty(keys:

string

[]):

string

|

undefined

Gets the property value for given keys. First property found will be retrieved.

Returns The retrieved property value

Parameters:
Name
Description
keys

The property key

getUser():

User

|

undefined

Gets the User associated with the Message.

Returns The User associated with the Message

json():

bkper.Message

Gets the wrapped plain json object.

Returns The wrapped plain json object

setContent(content:

string

):

Message

Sets the text content of the Message.

Returns This Message, for chaining

Parameters:
Name
Description
content

The text content of the Message

setProperties(properties: any):

Message

Sets the custom properties of the Message

Returns This Message, for chaining

Parameters:
Name
Description
properties

Object with key/value pair properties

setProperty(key:

string

, value:

string

|

null

):

Message

Sets a custom property in the Message.

Returns This Message, for chaining

Parameters:
Name
Description
key

The property key

value

The property value

stream(): Promise<

void

>

Streams the Message to the Bkper API.

Returns A Promise that resolves when the streaming is complete

Query

Defines a saved Query in a Book.

Queries can be saved on Books by users.

create(): Promise<

Query

>

Perform create new Query.

Returns This Query, for chaining

getId():

string

|

undefined

Gets the Query universal identifier.

Returns The Query universal identifier

getQuery():

string

|

undefined

Gets the query string to be executed.

Returns This Query string to be executed

getTitle():

string

|

undefined

Gets the title of this saved Query.

Returns The title of this saved Query

json():

bkper.Query

Gets the wrapped plain json object.

Returns The wrapped plain json object

remove(): Promise<

Query

>

Perform delete Query.

Returns This Query, for chaining

setQuery(query:

string

):

Query

Sets the query string associated with this saved Query.

Returns This Query, for chaining

Parameters:
Name
Description
query

The query string to be executed

setTitle(title:

string

):

Query

Sets the title of this saved Query.

Returns This Query, for chaining

Parameters:
Name
Description
title

The title of this saved Query

update(): Promise<

Query

>

Perform update Query, applying pending changes.

Returns This Query, for chaining

Template

This class defines a Template.

A Template is a pre-configured setup for Books and associated Google Sheets that provides users with a starting point for specific accounting or financial management needs.

getBookId():

string

|

undefined

Gets the bookId of the Book associated with the Template.

Returns The bookId of the Book associated with the Template

Gets the link of the Book associated with the Template.

Returns The link of the Book associated with the Template

getCategory():

string

|

undefined

Gets the category of the Template.

Returns The Template’s category. Example: “PERSONAL”, “BUSINESS”, etc

getDescription():

string

|

undefined

Gets the description of the Template.

Returns The Template’s description

getImageUrl():

string

|

undefined

Gets the url of the image of the Template.

Returns The url of the Template’s image

getName():

string

|

undefined

Gets the name of the Template.

Returns The Template’s name

Gets the link of the Google Sheets spreadsheet associated with the Template.

Returns The link of the Google Sheets spreadsheet associated with the Template

getTimesUsed():

number

Gets the times the Template has been used.

Returns The number of times the Template has been used

json():

bkper.Template

Gets an immutable copy of the JSON payload for this Template.

Returns An immutable copy of the json payload

Transaction

This class defines a Transaction between credit and debit Accounts.

A Transaction is the main entity on the Double Entry Bookkeeping system.

addFile(file:

File

):

Transaction

Adds a file attachment to the Transaction.

Files MUST be previously created in the Book.

Returns This Transaction, for chaining

Parameters:
Name
Description
file

The file to add

addRemoteId(remoteId:

string

):

Transaction

Add a remote id to the Transaction.

Returns This Transaction, for chaining

Parameters:
Name
Description
remoteId

The remote id to add

addUrl(url:

string

):

Transaction

Add a url to the Transaction. Url starts with https://

Returns This Transaction, for chaining

Parameters:
Name
Description
url

The url to add

check(): Promise<

Transaction

>

Perform check transaction.

Returns This Transaction, for chaining

create(): Promise<

Transaction

>

Perform create new draft transaction.

Returns This Transaction, for chaining

deleteProperty(key:

string

):

Transaction

Delete a custom property

Returns This Transaction, for chaining

Parameters:
Name
Description
key

The property key

from(account:

Account

|

bkper.Account

):

Transaction

Sets the credit/origin Account of this Transaction. Same as setCreditAccount()

Returns This Transaction, for chaining

Parameters:
Name
Description
account

The Account object

getAccountBalance(raw?:

boolean

): Promise<

Amount

|

undefined

>

Gets the balance that the Account has at that day, when listing transactions of that Account.

Evolved balances is returned when searching for transactions of a permanent Account.

Only comes with the last posted transaction of the day.

Returns The account balance at the transaction date

Parameters:
Name
Description
raw

True to get the raw balance, no matter the credit nature of the Account

getAgentId():

string

|

undefined

Gets the unique identifier of the agent that created this transaction.

Returns The id of the agent that created this transaction

getAgentLogoUrl():

string

|

undefined

Gets the logo URL of the agent that created this transaction.

Returns The logo of the agent that created this transaction

getAgentLogoUrlDark():

string

|

undefined

Gets the dark mode logo URL of the agent that created this transaction.

Returns The logo of the agent that created this transaction in dark mode

getAgentName():

string

|

undefined

Gets the name of the agent that created this transaction.

Returns The name of the agent that created this transaction

getAmount():

Amount

|

undefined

Gets the amount of this Transaction.

Returns The amount of this Transaction

getAmountFormatted():

string

|

undefined

Gets the formatted amount of this Transaction according to the Book format.

Returns The amount of this Transaction, formatted according to the Book format

getBook():

Book

Gets the book associated with this transaction.

Returns The book of the Transaction

getCreatedAt():

Date

Gets the date when the transaction was created.

Returns The date the transaction was created

getCreatedAtFormatted():

string

Gets the formatted creation date of the transaction.

Returns The date the transaction was created, formatted according to the date pattern of the Book

getCreditAccount(): Promise<

Account

|

undefined

>

Gets the credit account associated with this Transaction. Same as origin account

Returns The credit (origin) account

getCreditAccountName(): Promise<

string

|

undefined

>

Gets the name of this Transaction’s credit account.

Returns The credit account name

getCreditAmount(account:

Account

|

string

): Promise<

Amount

|

undefined

>

Get the absolute amount of this Transaction if the given account is at the credit side.

Returns The credit amount or undefined

Parameters:
Name
Description
account

The account object, id or name

getDate():

string

|

undefined

Gets the transaction date in ISO format.

Returns The Transaction date, in ISO format yyyy-MM-dd

getDateFormatted():

string

|

undefined

Gets the transaction date formatted according to the book’s date pattern.

Returns The Transaction date, formatted on the date pattern of the Book

getDateObject():

Date

Gets the transaction date as a Date object in the book’s timezone.

Returns The Transaction Date object, on the time zone of the Book

getDateValue():

number

|

undefined

Gets the transaction date as a numeric value.

Returns The Transaction date number, in format YYYYMMDD

getDebitAccount(): Promise<

Account

|

undefined

>

Gets the debit account associated with this Transaction. Same as destination account

Returns The debit (destination) account

getDebitAccountName(): Promise<

string

|

undefined

>

Gets the name of this Transaction’s debit account.

Returns The debit account name

getDebitAmount(account:

Account

|

string

): Promise<

Amount

|

undefined

>

Gets the absolute amount of this Transaction if the given account is at the debit side.

Returns The debit amount or undefined

Parameters:
Name
Description
account

The account object, id or name

getDescription():

string

Gets the description of this Transaction.

Returns The description of this Transaction

getFiles():

File

[]

Gets all files attached to the transaction.

Returns The files attached to the transaction

getId():

string

|

undefined

Gets the unique identifier of the transaction.

Returns The id of the Transaction

getOtherAccount(account:

Account

|

string

): Promise<

Account

|

undefined

>

Gets the Account at the other side of the transaction given the one in one side.

Returns The account at the other side of the transaction

Parameters:
Name
Description
account

The account object, id or name

getOtherAccountName(account:

string

|

Account

): Promise<

string

|

undefined

>

The Account name at the other side of this Transaction given the one in one side.

Returns The name of the Account at the other side

Parameters:
Name
Description
account

The Account object, id or name

getProperties(): any

Gets the custom properties stored in this Transaction.

Returns Object with key/value pair properties

getProperty(keys:

string

[]):

string

|

undefined

Gets the property value for given keys. First property found will be retrieved

Returns The property value or undefined if not found

Parameters:
Name
Description
keys

The property key

getPropertyKeys():

string

[]

Gets the custom properties keys stored in this Transaction.

Returns Array of property keys

getRemoteIds():

string

[]

Gets the remote IDs associated with this transaction. Remote ids are used to avoid duplication.

Returns The remote ids of the Transaction

getTags():

string

[]

Gets all hashtags used in the transaction.

Returns All #hashtags used on the transaction

getUpdatedAt():

Date

Gets the date when the transaction was last updated.

Returns The date the transaction was last updated

getUpdatedAtFormatted():

string

Gets the formatted last update date of the transaction.

Returns The date the transaction was last updated, formatted according to the date pattern of the Book

getUrls():

string

[]

Gets all URLs associated with the transaction.

Returns All urls of the transaction

hasTag(tag:

string

):

boolean

Check if the transaction has the specified tag.

Returns True if the transaction has the specified tag

Parameters:
Name
Description
tag

The tag to check for

isChecked():

boolean

|

undefined

Checks if the transaction is marked as checked.

Returns True if transaction is checked

isCredit(account?:

Account

): Promise<

boolean

>

Tell if the given account is credit on this Transaction

Returns True if the account is the credit account

Parameters:
Name
Description
account

The Account object

isDebit(account?:

Account

): Promise<

boolean

>

Tell if the given account is debit on the Transaction

Returns True if the Account is the debit account

Parameters:
Name
Description
account

The Account object

isLocked():

boolean

Checks if the transaction is locked by the book’s lock or closing date.

Returns True if a transaction is locked by the book lock/closing date

isPosted():

boolean

|

undefined

Checks if the transaction has been posted to the accounts.

Returns True if transaction was already posted to the accounts. False if is still a Draft

isTrashed():

boolean

|

undefined

Checks if the transaction is in the trash.

Returns True if transaction is in trash

json():

bkper.Transaction

Gets the JSON representation of the transaction.

Returns An immutable copy of the json payload

post(): Promise<

Transaction

>

Perform post transaction, changing credit and debit Account balances.

Returns This Transaction, for chaining

remove(): Promise<

Transaction

>

deprecated **

restore(): Promise<

Transaction

>

deprecated **

setAmount(amount:

Amount

|

number

|

string

):

Transaction

Sets the amount of this Transaction.

Returns This Transaction, for chaining

Parameters:
Name
Description
amount

The amount to set

setChecked(checked:

boolean

):

Transaction

Set the check state of the Transaction.

Returns This Transaction, for chaining

Parameters:
Name
Description
checked

The check state

setCreditAccount(account:

Account

|

bkper.Account

):

Transaction

Sets the credit/origin Account of this Transaction. Same as from()

Returns This Transaction, for chaining

Parameters:
Name
Description
account

The Account object

setDate(date:

string

|

Date

):

Transaction

Sets the date of the Transaction.

Returns This Transaction, for chaining

Parameters:
Name
Description
date

The date to set as string or Date object

setDebitAccount(account:

Account

|

bkper.Account

):

Transaction

Sets the debit/destination Account of this Transaction. Same as to()

Returns This Transaction, for chaining

Parameters:
Name
Description
account

The Account object

setDescription(description:

string

):

Transaction

Sets the description of the Transaction.

Returns This Transaction, for chaining

Parameters:
Name
Description
description

The description to set

setProperties(properties: any):

Transaction

Sets the custom properties of the Transaction

Returns This Transaction, for chaining

Parameters:
Name
Description
properties

Object with key/value pair properties

setProperty(key:

string

, value:

string

|

null

):

Transaction

Sets a custom property in the Transaction.

Returns This Transaction, for chaining

Parameters:
Name
Description
key

The property key

value

The property value

setUrls(urls:

string

[]):

Transaction

Sets the Transaction urls. Url starts with https://

Returns This Transaction, for chaining

Parameters:
Name
Description
urls

The urls array

to(account:

Account

|

bkper.Account

):

Transaction

Sets the debit/destination Account of this Transaction. Same as setDebitAccount()

Returns This Transaction, for chaining

Parameters:
Name
Description
account

The Account object

trash(): Promise<

Transaction

>

Trash the transaction.

Returns This Transaction, for chaining

uncheck(): Promise<

Transaction

>

Perform uncheck transaction.

Returns This Transaction, for chaining

untrash(): Promise<

Transaction

>

Untrash the transaction.

Returns This Transaction, for chaining

update(): Promise<

Transaction

>

Update transaction, applying pending changes.

Returns This Transaction, for chaining

TransactionList

A list associated with a transaction query.

getAccount(): Promise<

Account

|

undefined

>

Retrieves the account associated with the query, when filtering by account.

Returns The account associated with the query, or undefined if not set

getCursor():

string

|

undefined

Gets the cursor associated with the query for pagination.

Returns The cursor associated with the query for pagination

getFirst():

Transaction

|

undefined

Gets the first Transaction in the list.

Returns The first Transaction in the list

getItems():

Transaction

[]

Gets the transactions in the list.

Returns An array of Transaction objects

size():

number

Gets the total number of transactions in the list.

Returns The total number of transactions

User

This class defines a User on the Bkper platform.

Users can own and collaborate on Books, manage Collections, and connect to external services through Connections.

Each User has a unique identity, subscription plan details, and access permissions across the platform.

getAvatarUrl():

string

|

undefined

Gets the avatar url of the User.

Returns The User’s avatar url

getConnection(id:

string

): Promise<

Connection

>

Gets a Connection of the User.

Returns The retrieved Connection object

Parameters:
Name
Description
id

The Connection’s id

getConnections(): Promise<

Connection

[]>

Gets the Connections of the User.

Returns The retrieved Connection objects

getDaysLeftInTrial():

number

|

undefined

Gets the days left in User’s trial.

Returns The User’s days left in trial

getEmail():

string

|

undefined

Gets the email of the User.

Returns The User’s email

getFullName():

string

|

undefined

Gets the full name of the User.

Returns The User’s full name

getHostedDomain():

string

|

undefined

Gets the hosted domain of the User.

Returns The User’s hosted domain

getId():

string

|

undefined

Gets the id of the User.

Returns The User’s id

getName():

string

|

undefined

Gets the name of the User.

Returns The User’s name

getPlan():

string

|

undefined

Gets the plan of the User.

Returns The User’s plan

hasBillingEnabled():

boolean

|

undefined

Tells if billing is enabled for the User.

Returns True if billing is enabled for the User

hasStartedTrial():

boolean

|

undefined

Tells if the User has started the trial.

Returns True if the User has started the trial

hasUsedConnections():

boolean

|

undefined

Tells if the User has already used Connections.

Returns True if the User has already used Connections

isFree():

boolean

|

undefined

Tells if the User is in the free plan.

Returns True if the User is in the free plan

json():

bkper.User

Gets an immutable copy of the JSON payload for this User.

Returns An immutable copy of the json payload

BalancesContainer

The container of balances of an Account or Group

The container is composed of a list of Balances for a window of time, as well as its period and cumulative totals.

getAccount(): Promise<

Account

|

null

>

Gets the Account associated with this container.

returns ** The Account associated with this container

getBalancesContainer(name:

string

):

BalancesContainer

Gets a specific BalancesContainer.

param name The Account or Group name

returns ** The retrieved BalancesContainer

getBalancesContainers():

BalancesContainer

[]

Gets all child BalancesContainers.

NOTE: Only for Group balance containers. Accounts returns null.

returns ** All child BalancesContainers

getBalancesReport():

BalancesReport

Gets the parent BalancesReport of the container.

returns ** The parent BalancesReport of the container

getCumulativeBalance():

Amount

Gets the cumulative balance to the date.

returns ** The cumulative balance to the date

getCumulativeBalanceRaw():

Amount

Gets the cumulative raw balance to the date.

returns ** The cumulative raw balance to the date

getCumulativeBalanceRawText():

string

Gets the cumulative raw balance formatted according to Book decimal format and fraction digits.

returns ** The cumulative raw balance formatted according to Book decimal format and fraction digits

getCumulativeBalanceText():

string

Gets the cumulative balance formatted according to Book decimal format and fraction digits.

returns ** The cumulative balance formatted according to Book decimal format and fraction digits

getDepth():

number

Gets the depth in the parent chain up to the root.

returns ** The depth in the parent chain up to the root

getGroup(): Promise<

Group

|

null

>

Gets the Group associated with this container.

returns ** The Group associated with this container

getName():

string

|

undefined

Gets the Account or Group name.

returns ** The Account or Group name

getNormalizedName():

string

|

undefined

Gets the Account or Group name without spaces or special characters.

returns ** The Account or Group name without spaces or special characters

getParent():

BalancesContainer

|

null

Gets the parent BalanceContainer.

returns ** The parent BalanceContainer

getPeriodBalance():

Amount

Gets the balance on the date period.

returns ** The balance on the date period

getPeriodBalanceRaw():

Amount

Gets the raw balance on the date period.

returns ** The raw balance on the date period

getPeriodBalanceRawText():

string

Gets the raw balance on the date period formatted according to Book decimal format and fraction digits.

returns ** The raw balance on the date period formatted according to Book decimal format and fraction digits

getPeriodBalanceText():

string

Gets the balance on the date period formatted according to Book decimal format and fraction digits.

returns ** The balance on the date period formatted according to Book decimal format and fraction digits

hasGroupBalances():

boolean

Gets whether the balance container is from a parent group.

returns ** True if the balance container is from a parent group

isCredit():

boolean

|

undefined

Gets the credit nature of the BalancesContainer, based on Account or Group.

For Account, the credit nature will be the same as the one from the Account.

For Group, the credit nature will be the same, if all accounts containing on it has the same credit nature. False if mixed.

returns ** The credit nature of the BalancesContainer

isFromAccount():

boolean

Gets whether this balance container is from an Account.

returns ** True if this balance container if from an Account

isFromGroup():

boolean

Gets whether this balance container is from a Group.

returns ** True if this balance container if from a Group

isPermanent():

boolean

|

undefined

Tell if this balance container is permanent, based on the Account or Group.

Permanent are the ones which final balance is relevant and keep its balances over time.

They are also called Real Accounts.

Usually represents assets or liabilities, capable of being perceived by the senses or the mind, like bank accounts, money, debts and so on.

returns ** True if its a permanent Account

Config

This class defines the Bkper API Config.

apiBaseUrl():

Sets the base api url. Default to https://app.bkper.com/_ah/api/bkper

apiKeyProvider(): Promise<

string

>

The API key to identify the agent.

API keys are intended for agent identification only, not for authentication. Learn more

See how to create your api key here.

oauthTokenProvider(): Promise<

string

|

undefined

>

Issue a valid OAuth2 access token with https://www.googleapis.com/auth/userinfo.email scope authorized.

requestErrorHandler(error:

any

):

any

Custom request error handler

param error The error object of the failed request.

requestHeadersProvider(): Promise<any>

Provides additional headers to append to the API request

requestRetryHandler(status?:

number

, error?:

any

, attempt?:

number

): Promise<

void

>

Custom request retry handler.

This function is called when a request fails and needs to be retried. It provides the HTTP status code, error message, and the number of retry attempts made so far.

param code The HTTP status code of the failed request.

param error The error object of the failed request.

param attempt The number of retry attempts made so far.

AccountType Enum

Enum that represents account types.

Name
Description
ASSET

Asset account type

INCOMING

Incoming account type

LIABILITY

Liability account type

OUTGOING

Outgoing account type

BotResponseType Enum

Enum that represents the type of a Bot Response

Name
Description
ERROR

Error bot response

INFO

Info bot response

WARNING

Warning bot response

DecimalSeparator Enum

Decimal separator of numbers on book

Name
Description
COMMA

,

DOT

.

EventType Enum

Enum that represents event types.

Name
Description
ACCOUNT_CREATED

ACCOUNT_DELETED

ACCOUNT_UPDATED

BOOK_DELETED

BOOK_UPDATED

COLLABORATOR_ADDED

COLLABORATOR_REMOVED

COLLABORATOR_UPDATED

COMMENT_CREATED

COMMENT_DELETED

FILE_CREATED

GROUP_CREATED

GROUP_DELETED

GROUP_UPDATED

INTEGRATION_CREATED

INTEGRATION_DELETED

INTEGRATION_UPDATED

QUERY_CREATED

QUERY_DELETED

QUERY_UPDATED

TRANSACTION_CHECKED

TRANSACTION_CREATED

TRANSACTION_DELETED

TRANSACTION_POSTED

TRANSACTION_RESTORED

TRANSACTION_UNCHECKED

TRANSACTION_UPDATED

Month Enum

Enum that represents a Month.

Name
Description
APRIL

AUGUST

DECEMBER

FEBRUARY

JANUARY

JULY

JUNE

MARCH

MAY

NOVEMBER

OCTOBER

SEPTEMBER

Period Enum

Enum that represents a period slice.

Name
Description
MONTH

Monthly period

QUARTER

Quarterly period

YEAR

Yearly period

Periodicity Enum

The Periodicity of the query. It may depend on the level of granularity you write the range params.

Name
Description
DAILY

Example: after:25/01/1983, before:04/03/2013, after:$d-30, before:$d, after:$d-15/$m

MONTHLY

Example: after:jan/2013, before:mar/2013, after:$m-1, before:$m

YEARLY

Example: on:2013, after:2013, $y

Permission Enum

Enum representing permissions of user in the Book

Learn more at share article.

Name
Description
EDITOR

Manage accounts, transactions, book configuration and sharing

NONE

No permission

OWNER

Manage everything, including book visibility and deletion. Only one owner per book.

POSTER

View transactions, accounts, record and delete drafts

RECORDER

Record and delete drafts only. Useful to collect data only

VIEWER

View transactions, accounts and balances.

Visibility Enum

Enum representing the visibility of a Book

Name
Description
PRIVATE

The book can be accessed by the owner and collaborators

PUBLIC

The book can be accessed by anyone with the link