Write a script with TypeScript

Write a TypeScript script that saves a note in your library and lists the latest ones, using a key that reaches notes and nothing else.

  • You'll build Standup, a TypeScript script that saves a note for the day and lists your last five.
  • You need your own Marfa instance, with the CLI signed in to it, as the Quickstart leaves you, at http://localhost:8600. You also need Node.js 22.18 or later.
  • You'll have a script that runs with a key of its own, which can read and write notes and nothing else.

The CLI's sign-in stays in your keychain, on your computer. A script carries a key instead: a secret that names exactly which types it can read or write. It works from any computer that can reach your instance, such as a server or a scheduled job.

Step 1 of 5: Make a key for the script

Make a key for the script

Ask the CLI for a key that can write notes:

Terminal
marfa keys create --label "Standup script" --source standup --type-permission core.note=write
marfa_k1_…
key 01a1f184-1bed-74ae-afc6-32fc15c97ef3 (Standup script); the plaintext is shown once, keep it now
  core.note  Read and edit

The first line is the key. Copy it now: Marfa shows it only once and keeps only a hash of it.

--type-permission core.note=write lets the key read and write notes, the type core.note, and nothing else. --source standup names where the notes it writes come from, so an app can show and filter them by it.

On this page