# Extensions quickstart

> From zero to a deployed extension, running on a real journal, in about five minutes.

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

This walks one extension all the way through: scaffold it, write it, validate it, deploy it to an entity, make it run, and read what it did. The extension logs a line every time a journal is posted.

You'll need Node 22 or later, and a Prosaic login that is a workspace admin or owner — deploying an extension requires one of those roles. Use an entity you don't mind experimenting on; a test client is ideal.

## 1. Install the CLI

```bash
npm install -g prosaic-cli
```

The package is `prosaic-cli`; the command it installs is `prosaic`. Confirm it works:

```bash
prosaic --version
```

## 2. Log in

```bash
prosaic auth login
```

This opens a browser, you sign in, and the CLI saves its credentials to `~/.prosaic/config.toml`. It uses them for every later command — deploy, logs, the lot. `prosaic auth whoami` shows who you're signed in as.

In CI, pass an API key instead: `prosaic auth login --token <api-key>`.

## 3. Scaffold a project

```bash
prosaic extension init journal-posted-logger --trigger event
cd journal-posted-logger
```

What you just got:

```
journal-posted-logger/
  prosaic.extension.toml    # Manifest: name, scopes, triggers
  src/
    index.ts                # Your code
  package.json
  tsconfig.json
```

The project is named after its folder. The scaffolded manifest listens for `journal.created` with the `read:transactions` scope, and its first line is a `#:schema` directive, so TOML editors check the file as you type — see [Validation in your editor](/docs/extensions/manifest#validation-in-your-editor).

`--trigger` picks the starting point:

| `--trigger`   | What it sets up                                          |
| ------------- | -------------------------------------------------------- |
| `event`       | `[[targets.events]]` for `journal.created` (the default) |
| `cron`        | `[targets.cron]` running daily at 09:00 UTC              |
| `action-link` | Two `[[targets.actions]]` on single + bulk transactions  |
| `manual`      | No trigger — a commented example for you to fill in      |

## 4. Write the extension

Replace the scaffolded manifest with one that listens for posted journals and can read them.

`prosaic.extension.toml`:

```toml
#:schema https://developer.prosaic.works/schemas/extension-manifest.json
name = "journal-posted-logger"
version = "0.0.1"
description = "Logs posted journals"

[scopes]
required = ["read:journals"]

[[targets.events]]
type = "journal.posted"
```

Then replace `src/index.ts`:

```typescript
const { input } = prosaic.context;
const journal = await prosaic.journals.get(input.journalId);

prosaic.log.info('Journal posted', {
  journalId: journal.id,
  date: journal.date,
  narration: journal.narration,
});
```

`prosaic` is a global the runtime provides — there's nothing to import. For a `journal.posted` event, `prosaic.context.input` is `{ journalId }`. Reading the journal needs `read:journals`, which is why the manifest asks for it; without it the call throws a permission error.

## 5. Validate

```bash
prosaic extension validate
```

This runs the same manifest checks as a deploy and a trial build of `src/`. It needs no network and no login, so run it whenever you change either file.

## 6. Find your entity ID

Extensions install per entity — each business or client is its own entity. Open the entity in Prosaic and take the ID from the address bar; it's the part after `/entities/`:

```
https://app.prosaic.works/entities/<entity-id>
```

Or list them from the CLI:

```bash
prosaic entities list
```

## 7. Deploy

```bash
prosaic extension deploy --entity-id <entity-id>
```

The first time, this:

1. Validates your manifest
2. Bundles `src/index.ts` with esbuild into a single ES module with no runtime imports
3. Creates the extension in your workspace
4. Uploads the bundle
5. Installs it on the entity you passed

Later deploys find the extension by its `name` and update it in place, so it's safe to re-run as often as you like.

## 8. Make it run

Post a journal on that entity in Prosaic — a manual journal is quickest. Then pull the extension's runs:

```bash
prosaic extension logs --dir . --follow
```

Each run prints its status, ID, trigger and start time, then the lines it logged. Something like:

```
completed  8c41…  journal.posted  2026-10-27T21:04:12.381Z
  [21:04:12] INFO  Journal posted {"journalId":"5d1e…","narration":"Office supplies"}
```

`--dir .` tells the CLI to look the extension up by the name in your manifest; unlike the other commands, `logs` doesn't assume the current folder. You can pass the extension's ID instead: `prosaic extension logs <extension-id>`.

## 9. See it in Prosaic

Open **Settings → Extensions** in the app (`https://app.prosaic.works/settings/extensions` if it isn't in your settings menu yet). Your extension is listed with its version and counts; open it to see its triggers and scopes, the entity it's installed on with a switch to turn it off, and its recent runs. [Using extensions](/docs/extensions/using-extensions) covers that page, and what everyone else in the workspace sees.

## 10. Iterate with `extension dev`

```bash
prosaic extension dev --entity-id <entity-id>
```

`dev` deploys, then watches `src/` and the manifest and redeploys when you save. It polls for runs every 3 seconds and prints them, so post another journal and the result appears in your terminal. `Ctrl+C` stops it; what you deployed stays deployed.

That's the full loop: write, validate, deploy, trigger, read the logs.

## Next

- [Triggers](/docs/extensions/triggers) — swap the event for a schedule or an action button, with a handler for each.
- [Sandbox API](/docs/extensions/sandbox-api) — the whole `prosaic.*` surface: reports, GST, email, AI, outbound HTTP.
- [Using extensions](/docs/extensions/using-extensions) — install it on more entities, connect credentials, and approve wider permissions.
- [Build with an LLM](/docs/extensions/llm-tools) — skip the typing and have Claude write it for you.
