Documentation

Mini App SDK (AppContext)


Before getting started with building a Mini App for the Tenseri Accounting System, please be sure to go over the Overview and Structure guides to get a general understand, setup process and important pre-requisites for building on the system.


The Mini App SDK serves as a client-side Javascript library that extends the underlying APIs of the system. Mini Apps requires no more than browser based tech, thus HTML, CSS and Javascript.


Developers are free to use any additional tooling required to support their development as long as the final app is composed of HTML, CSS and Javascript.


Please follow the Structure guide to learn more about the required development environment needed to develop Mini Apps for the accounting system.


The rest of the guide will focus on explaining and detailing the methods available with the SDK.



Note

> There is no need to explicitly Pull-in and initialize the SDK, as this is done automatically inside the Mini App's iframe and made available as a the global window.AppContext object. Follow the Structure guide for more details.





Accounts


Managing the charts of accounts


Get all accounts

getAccounts()


Fetches all active accounts.


Parameters:

None


Returns

Promise<Array> Account objects.


Field Type Description
id number Account identifier.
name string Account name.
type string One of 'asset', 'liability', 'equity', 'revenue', 'expense'.
subType string Sub-type per the allowed type / subType combinations listed under createAccount() below ('' if not applicable).
balance number Current account balance.
balanceSide string Normal balance side for this account: 'debit' or 'credit'.

Example Response

[
    { "id": 1, "name": "Brokerage Cash", "type": "asset", "subType": "cash", "balance": 0, "balanceSide": "debit" },
    { "id": 5, "name": "Dividend Income", "type": "revenue", "subType": "", "balance": 0, "balanceSide": "credit" },
    { "id": 8, "name": "General Liability", "type": "liability", "subType": "non-current", "balance": 0, "balanceSide": "credit" },
    { "id": 9, "name": "Owner's Equity", "type": "equity", "subType": "", "balance": 0, "balanceSide": "credit" }
]

Sample Code

(async () => {
    const accounts = await AppContext.getAccounts();
    console.log(accounts);
})();

Get a list of all archived accounts


getArchivedAccounts()


Fetches archived accounts.


Parameters:

none


Returns:

Promise<Array> same shape as getAccounts().


Sample Code

(async () => {
    const archived = await AppContext.getArchivedAccounts();
    console.log(archived);
})();

Create an account


createAccount(name, type, subType = '')


Creates a new account.


Parameters

Parameter Type Description
name string Account name.
type string Must be one of: 'asset', 'liability', 'equity', 'revenue', 'expense'.
subType string (default: '') Must be a valid sub-type for the given type (see table below).

Returns

Promise<number> Returns account id.


Errors

Condition Error / Behavior
If type is not one of the five allowed values. Throws Invalid Account Type: {type}
If subType is not valid for the given type. Throws Invalid subType '{subType}' for account type '{type}'
Any server-side issue occurs (e.g., duplicate name). Propagates the server-side error.

Allowed type / subType combinations:


Type Allowed subType Values
asset '', 'current', 'non-current', 'cash' (used for bank as well), 'receivable'
liability '', 'current', 'non-current', 'payable'
equity '' only
revenue '' only
expense '' only

Example code

(async () => {
    await AppContext.createAccount('Accounts Receivable', 'asset', 'receivable');
    await AppContext.createAccount('Owner Equity', 'equity'); // subType omitted
})();

Rename an account


updateAccount(id, newName)


Change the name of an existing account.


Parameter Type Description
id number Account identifier.
newName string New account name.

Returns

Promise<boolean> i.e. true | false.


Throws

Throws internal errors if account does not exist or name already exists..


Sample Code

 (async () => {
    response = await AppContext.updateAccount(16, "New Name");
    console.log(response);
    })();

Archive an account

archiveAccount(id)



Archives an account.

The account must have a zero balance.

Parameter

id (number)


Returns

Promise<boolean> i.e. true | false.


Throws

Server-side error if the account has a non-zero balance.


(async () => {
    const response = await AppContext.archiveAccount(16);
    console.log(response);
})();


Restore an archived account

restoreAccount(id)


Restores a previously archived account.


Parameters

id (number)


Returns

Promise<boolean>


Sample Code

(async () => {
    const response = await AppContext.restoreAccount(16);
    console.log(response);
})();

Transactions


Get transactions

getTransactions(offset = 0, size = 10, queryParams)


Fetches a paginated, filterable list of ledger transactions.


Parameters

Parameter Type Description
offset number Default 0. Row offset for pagination.
size number Default 10. Page size.
queryParams Object Optional. Used to filter down results. See fitler keys below.

queryParams filter keys

Key Type Description
id number Exact journal entry ID match.
description string Loosely matched against the entry's explanation text.
fromDate / toDate string Format YYYY-MM-DD. Inclusive posting-date range.
debitAccountIDs Array<Number> Fetches transactions where the account(s) was/were debited.
debitAccountComparison <|=|>|<=|>= Compares against debitAccountAmount. Omit key entirely for "any amount".
debitAccountAmount number Paired with debitAccountComparison.
creditAccountIDs Array<Number> Fetches transactions where the account(s) was/were credit.
creditAccountComparison <|=|>|<=|>= Compares against creditAccountAmount.
creditAccountAmount number Paired with creditAccountComparison.
anyAccountIds Array<string> Used to fetch all debit and credit transactions involving the accounts
anyAccountComparison <|=|>|<=|>= Applies to whichever side the matched account is on.
anyAccountAmount number Paired with anyAccountComparison.

Returns

Promise<{ transactions: Transaction[], transactionCount: number }>


Field Type Description
transactions Array<Object> Each entry: { id: number, date: string, description: string, debits: [{accountId: number, accountName: string, amount: number}], credits: [{accountId: number, accountName: string, amount: number}] }.
transactionCount number Total count of matching rows (used for pagination).

Throws

Condition Error / Behavior
Any server-side issue (e.g., malformed filter, backend error). Propagates the server-side error.

Example code

(async () => {
    const page = await AppContext.getTransactions(0, 20, {
        fromDate: '2026-01-01',
        toDate: '2026-01-31',
        anyAccountId: [1]
    });
    console.log(page.transactions, page.transactionCount);
})();

Post a transaction

postTransaction(day, month, year, description, debits, credits)


Posts a new balanced journal entry to the ledger.


Parameters

Parameter Type Description
day number Day of month (1–31), must form a real calendar date with month/year.
month number Month (1–12).
year number
description string
debits Array<Object> Non-empty array of debit line objects ([{accountID: number, amount: number }]).
credits Array<Object> Non-empty array of credit line objects ([{accountID: number, amount: number }]).

Returns

Promise<boolean>


Throws

Condition Error / Behavior
If day, month, or year are not numeric. Throws `Invalid date: Date components must be numbers.`
If month or day are out of their valid ranges. Throws `Month must be between 1 and 12.` / `Day must be between 1 and 31.`
For a non-existent calendar date (e.g., Feb 30). Throws `Invalid date provided: {day}/{month}/{year} does not exist.`
If debits or credits is not a valid non-empty array. Throws `{debit|credit}s must be a non-empty array.`
If any entry in debits or credits is not an object. Throws `Invalid format for {debit|credit} at index {i}: Must be an object.`
Any server-side issue occurs (e.g., unbalanced entry). Propagates the server-side error.

Example code

(async () => {
    const response = await AppContext.postTransaction(
        16, 9, 2026,
        'Client invoice payment received',
        [{ accountID: 1, amount: 500 }],  // debits
        [{ accountID: 9, amount: 500 }] // credits
    );
    console.log(response);
})();



Financial Reports


Each report method takes optional startDate/endDate as plain string arguments. Reports for the current accounting year is returned if both dates are not set.


Balance sheet

getBalanceSheet(startDate = '', endDate = '')


(async () => {
    const fullHistoryBalanceSheet = await AppContext.getBalanceSheet();
    console.log(fullHistoryBalanceSheet); // no filters

    const balanceSheet = await AppContext.getBalanceSheet('2026-01-01', '2026-09-16');
    console.log(balanceSheet);

})();

Returns

Promise<Object>.


Example code

{
    "assets": [
        {
            "name": "Bank Account",
            "amount": 0,
            "subType": "cash"
        },
        {
            "name": "Brokerage Cash",
            "amount": 550,
            "subType": "cash"
        },
    ],
    "totalAssets": 550,
    "totalCurrentAssets": 0,
    "totalNonCurrentAssets": 0,
    "liabilities": [
        {
            "name": "General Liability",
            "amount": 0,
            "subType": "non-current"
        }
    ],
    "totalLiabilities": 0,
    "totalCurrentLiabilities": 0,
    "totalNonCurrentLiabilities": 0,
    "equity": [
        {
            "name": "Owner's Drawings",
            "amount": 0,
            "subType": ""
        },
        {
            "name": "Owner's Equity",
            "amount": 550,
            "subType": ""
        }
    ],
    "totalEquity": 550,
    "isBalanced": true,
    "startDate": "2026-01-01T00:00:00",
    "endDate": "2026-09-16T00:00:00"
}

Income Statement

getIncomeStatement(startDate = '', endDate = '')


(async () => {
    const currentYearStatement = await AppContext.getIncomeStatement();
    console.log(currentYearStatement); // No filter

    const filteredYearStatement = await AppContext.getIncomeStatement('2026-01-01', '2026-12-31');
    console.log(filteredYearStatement);
})();

Returns

Promise<Object>,


{
    "revenues": [
        {
            "name": "Dividend Income",
            "amount": 0
        },
        {
            "name": "General Income",
            "amount": 0
        },
        {
            "name": "Option Premium Income",
            "amount": 0
        },
        {
            "name": "Realized Investment Gains",
            "amount": 0
        }
    ],
    "totalRevenue": 0,
    "expenses": [
        {
            "name": "General Expense",
            "amount": 0
        }
    ],
    "totalExpenses": 0,
    "netIncome": 0,
    "startDate": null,
    "endDate": null
}

Cashflow Statement

getCashFlowStatement(startDate = '', endDate = '')


(async () => {
    const currentYearStatement = await AppContext.getCashFlowStatement();
    console.log(currentYearStatement); // No filter

    const filteredYearStatement = await AppContext.getCashFlowStatement('2026-01-01', '2026-12-31');
    console.log(filteredYearStatement);
})();

Returns

Promise<Object>


Example response


{
    "netIncome": 1800,
    "adjustments": [
        { "name": "Accounts Receivable", "amount": -700, "category": "Receivable", "direction": "increaseDecrease" },
        { "name": "Prepaid Insurance", "amount": -200, "category": "Current Asset", "direction": "increaseDecrease" },
        { "name": "Accounts Payable", "amount": 400, "category": "Payable", "direction": "increaseDecrease" },
        { "name": "Accrued Expenses", "amount": 150, "category": "Current Liability", "direction": "increaseDecrease" }
    ],
    "netOperating": 1450,
    "investing": [
        { "name": "Office Equipment", "amount": -1200, "direction": "purchaseDisposal" }
    ],
    "netInvesting": -1200,
    "financing": [
        { "name": "Bank Loan", "amount": 2000, "direction": "proceedsRepayment" },
        { "name": "Owner's Equity", "amount": 550, "direction": "movement" },
        { "name": "Owner's Drawings", "amount": -300, "direction": "movement" }
    ],
    "netFinancing": 2250,
    "netChange": 2500,
    "closingCash": 2500,
    "start_date": "2026-01-01T00:00:00",
    "end_date": "2026-12-31T00:00:00"
}

Response attributes


Key Type Description
netIncome number Total revenue minus total expenses for the period. This is the starting point of the operating section.
adjustments Array<LineItem> Working-capital changes that adjust net income to operating cash flow. Built from current and receivable/payable accounts. Each item has a category.
netOperating number netIncome plus the sum of all adjustments amounts.
investing Array<LineItem> Purchases and disposals of non-current assets.
netInvesting number Sum of all investing amounts. Negative means cash was spent.
financing Array<LineItem> Non-current liabilities (loans) and all equity accounts (contributions, drawings).
netFinancing number Sum of all financing amounts.
netChange number netOperating + netInvesting + netFinancing.
closingCash number Combined balance of all accounts with sub-type cash. Calculated separately from netChange. With a date filter, it reflects movement inside the range only.
start_date string | null The startDate filter that was applied, as an ISO datetime, or null.
end_date string | null The endDate filter that was applied, as an ISO datetime, or null.

LineItem


Field Type Description
name string Account name.
amount number Cash-flow signed. Positive is a cash inflow and negative is a cash outflow.
direction string What kind of movement the item represents. See the direction values below.
category string Only present on adjustments items. See the category values below.

direction values


Value Appears in Source account Meaning
increaseDecrease adjustments Current, receivable and payable accounts Change in a working-capital balance. An asset increase shows as negative and a liability increase as positive.
purchaseDisposal investing Asset, sub-type non-current Negative for a purchase (cash out), positive for a disposal (cash in).
proceedsRepayment financing Liability, sub-type non-current Positive for loan proceeds, negative for repayments.
movement financing Any equity account Net equity movement. Contributions are positive and drawings are negative.

category values (adjustments only)


Value Source account
Receivable Asset, sub-type receivable
Current Asset Asset, sub-type current
Payable Liability, sub-type payable
Current Liability Liability, sub-type current


App Data (Storage)


Every mini app gets its own isolated JSON data blob, keyed by your app's ID, for storing non-ledger data (app-specific settings, metadata, records that are not accounting facts).


Get app meta data

getData()


Fetches your app's stored data blob.


  • Parameters: none
  • Returns: Promise<Object>, whatever you last saved with saveData(); shape is entirely app-defined.

(async () => {
    const response = await AppContext.getData();
    console.log(response) // {"clients":[],"settings":{"theme":"dark"}}
})();

Get app meta data

saveData(data)


Saves (overwrites) your app's data blob.


  • Parameters: data (Object), arbitrary JSON, app-defined.
  • Returns: Promise<boolean>

(async () => {
  const response = await AppContext.saveData({
  clients: [],
  settings: { theme: 'dark' }
  });
  console.log(response)
})();

> Design convention: use getData()/saveData() only for data that is not itself an accounting fact (e.g. client records, catalog items, UI preferences). Anything that represents money movement should be posted as a real ledger transaction via postTransaction() so it shows up correctly across all financial reports, do not duplicate ledger data inside your app's data blob.



Currency & Config


Get platform currency

getCurrency()


Returns the currency used for all underlying transactions in ISO 4217 format.


(async () => {
    const response = await AppContext.getCurrency();
    console.log(response) // USD
})();

  • Returns: Promise<Object> , TODO: document shape (likely { code, symbol }).


Update platform currency

updateCurrency(currency)


Allowsthe currency for all underlying transactions to be set. Accepted format is ISO 4217.


await AppContext.updateCurrency('GHS');
  • Parameters: currency (string) , currency code. TODO: confirm accepted format.
  • Returns: Promise<boolean>
×