# Extensions overview

> What extensions are, when to write one, and where to start — creating one, or using one in a workspace.

Source: https://developer.prosaic.works/docs/extensions/overview

Extensions are small TypeScript programs that run inside Prosaic when something happens — a journal gets posted, a bank transaction is reconciled, IRD accepts a GST return, the clock strikes nine, or someone clicks a button. You write the code and declare what it's allowed to do, and Prosaic hosts and runs it in a sandbox next to the accounting data.

Think of them as the hook system every accountant has asked for, without the spreadsheet macros.

## Start here

### Create an extension

For developers, and for anyone working with a coding agent.

1. [**Quickstart**](/docs/extensions/quickstart) — install the CLI, scaffold a project, deploy it and watch it run, in about five minutes.
2. [**Manifest reference**](/docs/extensions/manifest) — the name, scopes, triggers and connections in `prosaic.extension.toml`.
3. [**Sandbox API**](/docs/extensions/sandbox-api) — everything on the `prosaic` global your code calls.
4. [**Triggers**](/docs/extensions/triggers) — events, cron schedules and action buttons, with a handler for each.
5. [**Testing and deploy**](/docs/extensions/testing-and-deploy) — `validate`, the `dev` loop, `logs`, and how versions and permissions change.
6. [**Examples**](/docs/extensions/examples) — complete extensions to copy.
7. [**Build with an LLM**](/docs/extensions/llm-tools) — have Claude, Cursor or ChatGPT scaffold and validate one through the developer MCP server.

### Use an extension

For the workspace admins, advisors and accountants it runs for.

- [**Using extensions**](/docs/extensions/using-extensions) — install it on a client's entity, connect its credentials, run its actions, read its runs, and pause, approve, update or remove it.

## Extension or API?

Both reach the same ledger. Pick by where the work starts.

- **Use the [API](/docs/getting-started/overview)** when your product is the source of the data. It creates entities, posts journals, imports bank transactions and reads reports back into your app. Your server calls Prosaic.
- **Write an extension** when the work belongs inside Prosaic: reacting to what accountants do in the books, running on a schedule for each client, or adding a button to the app. Prosaic calls your code, and there's no server of yours to run.

## When to build one

Good fits:

- **Notifications** — email a client when their GST return is filed, or post to Slack when a large transaction is reconciled.
- **Reminders and chasers** — ask clients for documents when a new GST period starts, and handle their replies.
- **Scheduled reports** — generate last month's profit and loss on the 1st and email it.
- **Integrations** — push data to another system's API through a connection you declare, with Prosaic holding the credential.
- **Workflow helpers** — add an action to the transaction list that runs whatever you want, such as AI account suggestions.

Not a great fit:

- **Writing to the ledger.** Extensions read journals but can't create, edit or void them, or reconcile a transaction. Post journals from your own server with the [public API](/docs/ledger/journals).
- **Arbitrary network access or runtime dependencies.** Outbound HTTP goes only to hosts you declare, and your code is bundled before it's deployed.
- **Long-running work** (over 10 seconds, or 2 minutes with `use:ai`). Break it up over a cron.
- **UI beyond an action.** An action is a menu item or a button with your label on it; there are no custom screens.
- **Distribution.** An extension runs in the workspace it was deployed to. There's no marketplace for publishing it to other workspaces.

## How it works

```
  trigger fires  →  installation matches  →  runtime executes  →  run recorded
  (event, cron,      (entity, switched on,     (V8 isolate)
   action, reply)     grant still covers it)       ▲ │
                                                   │ ▼
                                           prosaic.* bridge API
```

Each extension has:

- A **manifest** (`prosaic.extension.toml`) that declares its triggers, scopes, connections and metadata.
- An **entry point** (`src/index.ts`) — the code that runs on each trigger.
- An **installation** per entity — each client or business is switched on separately, and each installation records the scopes and hosts it was granted.

When a trigger fires, Prosaic queues a job. The runtime starts a V8 isolate, injects the `prosaic.*` global, runs your code, and records the run — logs, input, output, errors — so you can debug it later. Every call through the global is checked against the scopes in your manifest and the grant on the installation.

## What you get inside the sandbox

The `prosaic` global gives you:

- `context` — what triggered this run, and which entity it's for
- `transactions` — list and read bank transactions, and change a transaction's description
- `journals`, `entities` — read-only
- `reports` — profit and loss, balance sheet, trial balance and the other financial reports
- `gst` — GST returns: status, periods and IRD box amounts
- `email.send` — send from a Prosaic-managed address; replies come back to your extension
- `ai.complete` — call a large language model through Prosaic's account, no API key of your own
- `http.fetch` — call a third-party API you declared, with Prosaic attaching the credential
- `links` — remember which record in another system matches which Prosaic record
- `storage` — a small key-value store for the extension
- `tools` — Prosaic's tool registry, including the chart of accounts
- `log` — structured logs you read with `prosaic extension logs`

No global `fetch`. No `require`. No filesystem. No process environment. Anything that leaves the sandbox goes through one of the bridges above, which is what makes it safe to install one extension on many clients' entities.

The full surface, with examples, is in the [Sandbox API](/docs/extensions/sandbox-api).

Questions? We read every message at [support@prosaic.works](mailto:support@prosaic.works).
