ProjectionLab Plugin API
    Preparing search index...

    ProjectionLab Plugin API

    Enable plugins in Account Settings, then use window.projectionlabPluginAPI with your Plugin API Key. Never put a real key or an exported profile in an issue, log, or shared code sample.

    See PluginAPI for the complete method reference.

    Use getAccounts() to match accounts and updateAccountValues() to update them. Neither needs a full backup or a history request. Discovery reads the open profile's latest local values; updates use ordinary autosave.

    const api = window.projectionlabPluginAPI
    if (!api || api.version !== 2) {
    throw new Error('This integration requires ProjectionLab Plugin API version 2 (V5).')
    }

    const accounts = await api.getAccounts({ key })
    // let the person choose an account, then retain its id in your integration's mapping.
    const account = accounts.find(account => account.id === mappedAccountId)
    if (!account) {
    throw new Error('Choose an active ProjectionLab account before syncing.')
    }
    const values = account.kind === 'real-asset'
    ? { value: sourceMarketValueInProfileCurrency }
    : { balance: sourceBalanceInProfileCurrency }
    await api.updateAccountValues({
    accountId: account.id,
    values,
    key,
    })

    Each account has id, name, kind, and type, plus subtype when applicable. Match by id, not name or array position. The native monetary fields have the same meaning in discovery and updates:

    Kind Fields
    account balance; explicit costBasis where the account type supports it
    debt balance, positive for money owed
    real-asset value (market value) and purchasePrice (original price paid)

    New account types may be added without a new API major version. Convert your source's units, currency, and debt sign before calling; these methods do no conversion or rounding. A loan is its own debt account, not a second value on its collateral asset. A real asset never exposes its market value under balance.

    A secured debt also includes securedByAssetId, the id of its collateral asset. This discovery field is not an input to updateAccountValues(). Use it to find the debt for a saved V4 asset-loan mapping; never derive a debt id from its spelling. More than one debt can secure the same asset, so ask the person to choose when the mapping is ambiguous. The collateral may be archived and therefore absent from discovery even though its active debt remains in the list.

    Pass only fields you intend to change: values: { balance, costBasis } can update both facts on a supported financial account; values: { value } changes an asset's market value without changing its purchase price. Omitted fields stay unchanged. Missing basis stays absent in discovery; it is never filled with an estimate. You can add supported basis explicitly, even when none was previously recorded. Invalid fields or non-finite values reject the entire patch before any edits are applied. Purchase price remains a current fact, not a dated history observation.

    The list excludes archived accounts and custom plan copies, but includes active accounts hidden from a plan or excluded from household totals. Refresh it before each sync. Returned records are detached: changing them does not edit the app. updateAccountValues() rejects a stale mapping to an archived or deleted account. Its promise resolves after the local edit, not after a server acknowledgement; the app's normal save status shows persistence progress.

    exportData() saves pending edits and requests a complete, versioned backup, including archived accounts and recorded history. It requires an online profile. Use the app's Restore action to restore the complete backup.

    The schema-1 envelope retains documents.currentFinances, documents.plans, documents.settings, and documents.accountHistory. Values keep their source document schemas; export does not run migrations. Optional documents.progress retains older recorded history for Restore to convert. A source that has not yet created Current Finances or Settings can omit that document. Use getAccounts() for current application values; backup readers must inspect each document's schema. These rules also apply to support's historical exports.

    updateAccount() remains available for advanced field edits. The individual restoreCurrentFinances(), restorePlans(), and restoreSettings() methods update only their named document family, not account history. Do not present a sequence of those calls as a complete backup restore, and do not pass a discovery record to a document restore method.

    V5 exposes api.version === 2. The legacy V4 API has no version property; consumers supporting both can use api.version ?? 1. This is the plugin contract version, separate from the app version and an export's schema. Breaking contract changes advance this major version; additive methods and account types need not.

    An extension can support both releases by checking the API on each connection and choosing its V4 or V5 path before reading or writing. Do not infer the contract from the hostname or cache the version across connections. Reject an unsupported version clearly; never retry a failed V5 write through the V4 path. A dual-compatible extension can ship while Production still runs V4, avoiding a synchronized app/extension release. Installed older extensions still need an update before use with V5.

    Legacy usage V5 replacement
    exportData().today.savingsAccounts / investmentAccounts / assets / debts for discovery await api.getAccounts({ key })
    updateAccount(id, { amount, balance }, ...) with kind-dependent V4 fields await api.updateAccountValues({ accountId, values: { balance }, key }) for financial accounts/debts; use { value } for real assets
    Asset id plus a synthetic suffix for its loan balance Find debts by securedByAssetId, then write their own ids; ask the person to choose if more than one matches
    Full snapshot's today, plans, settings backup.documents.currentFinances, backup.documents.plans, backup.documents.settings
    Four arrays within current finances backup.documents.currentFinances.accounts, keyed by account id
    progress / restoreProgress() Progress data is retired; restoreProgress() rejects with guidance and never writes. Current-value updates record history automatically; full recorded history is in backup.documents.accountHistory
    meta Removed from portable exports; operational metadata is not plugin backup data

    The new export is { schema, exportedAt, documents }. Its schema versions the portable document contract, not the discovery API. Plans and settings also have V5 schemas: moving an old property path alone does not migrate an integration that interprets their contents. Do not re-create the old arrays, write old amount fields, or treat a real asset's old loan balance as its market value. Read current document types when using advanced methods.

    Released V4 backups remain importable through the app's Restore flow. V5 does not downgrade exports to V4 or expose a legacy restore adapter. The retained restoreProgress() name only gives old callers an actionable error; it neither imports history nor reports success. restoreCurrentFinances() expects current account identities, not unchanged V4 arrays. Check the API version before any writes, and show a clear unsupported-version message until your integration supports it. A rejection later in a third-party restore sequence cannot undo earlier successful calls.

    • Test V4 and the V5 Early Access build separately if you support both.
    • Verify account matching, positive debt balances, real-asset values, and separate loans.
    • Refresh discovery before syncing and handle archived/deleted mappings without recreating them.
    • Verify native-field edits reach the app's saved state and history; method completion alone is not a save acknowledgement.
    • Verify omitted basis and purchase price stay unchanged, and explicit supported updates use the correct fields.
    • For backup tools, verify the versioned envelope, online/save errors, and complete Restore through the app.
    • AI tools must update their prompts and tool schemas too. Do not advertise removed methods or claim document-by-document restores recover account history.