2/25/2026

API Cookbook

Ready-to-run shell scripts for common Leaderbook API patterns — sync local Markdown files, create recurring tasks, export notebooks, and propose changes for review.

API Cookbook

About this cookbook

Each recipe is a complete, copy-paste-ready shell script. Set the variables at the top (API_KEY, NOTEBOOK_ID, etc.) and run them directly. All scripts require curl and jq.


Push a local Markdown file to a note

When: You write in a local editor (Obsidian, iA Writer, VS Code) and want to sync to Leaderbook without opening the browser.

bash#!/usr/bin/env bash
# Usage: ./push-note.sh <note-id> <path-to-markdown-file>
# Example: ./push-note.sh clxnote1 ./standup.md

API_KEY="lb_live_abcd1234_XXXX"
NOTE_ID="$1"
FILE="$2"

if [ -z "$NOTE_ID" ] || [ -z "$FILE" ]; then
  echo "Usage: $0 <note-id> <markdown-file>"
  exit 1
fi

CONTENT=$(cat "$FILE")

curl -s -X PATCH "https://leaderbook.app/api/v1/notes/$NOTE_ID" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d "$(jq -n --arg c "$CONTENT" '{"content": $c}')"

echo "Done."

Create a recurring daily task from cron

When: You want Leaderbook to add a task automatically every morning — a standup reminder, daily review prompt, or any recurring work item.

Add to crontab (crontab -e) with 0 8 * * 1-5 to run at 8 am on weekdays.

bash#!/usr/bin/env bash
API_KEY="lb_live_abcd1234_XXXX"
NOTEBOOK_ID="clxnb1"

TODAY=$(date -u +"%Y-%m-%dT00:00:00Z")
LABEL=$(date +"%Y-%m-%d")

curl -s -X POST https://leaderbook.app/api/v1/tasks \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d "{
    \"title\": \"Daily standup $LABEL\",
    \"notebookId\": \"$NOTEBOOK_ID\",
    \"notes\": \"**Yesterday:**\n\n**Today:**\n\n**Blocker:**\n\n#standup\",
    \"priority\": \"MEDIUM\",
    \"targetAt\": \"$TODAY\"
  }"

Export an entire notebook to local Markdown files

When: You want a local backup of everything in a notebook, or you're migrating content to another tool.

Each note is saved as <note-id>.md in ./export/. The script handles pagination so it works for any notebook size.

bash#!/usr/bin/env bash
API_KEY="lb_live_abcd1234_XXXX"
NOTEBOOK_ID="clxnb1"
OUT_DIR="./export"

mkdir -p "$OUT_DIR"
CURSOR=""
PAGE=1

while true; do
  echo "Fetching page $PAGE…"

  PARAMS="notebookId=$NOTEBOOK_ID&limit=100"
  [ -n "$CURSOR" ] && PARAMS="$PARAMS&cursor=$CURSOR"

  RESPONSE=$(curl -s "https://leaderbook.app/api/v1/notes?$PARAMS" \
    -H "Authorization: Bearer $API_KEY")

  echo "$RESPONSE" | jq -c '.data[]' | while IFS= read -r item; do
    ID=$(echo "$item" | jq -r '.id')
    CONTENT=$(echo "$item" | jq -r '.content')
    echo "$CONTENT" > "$OUT_DIR/$ID.md"
    echo "  Saved $ID.md"
  done

  NEXT=$(echo "$RESPONSE" | jq -r '.nextCursor')
  [ "$NEXT" = "null" ] && break

  CURSOR="$NEXT"
  PAGE=$((PAGE + 1))
done

echo "Export complete. Files saved to $OUT_DIR/"

Propose a change for review instead of overwriting

When: A script generates updated content, but you want a human to review the diff before it goes live. This creates a paper trail and keeps the owner in control.

Use this instead of a direct PATCH whenever the content matters.

bash#!/usr/bin/env bash
API_KEY="lb_live_abcd1234_XXXX"
NOTE_ID="clxnote1"
UPDATED_FILE="./updated-note.md"
RATIONALE="Generated by weekly report script on $(date +%Y-%m-%d)"

CONTENT=$(cat "$UPDATED_FILE")

RESPONSE=$(curl -s -X POST "https://leaderbook.app/api/v1/notes/$NOTE_ID/suggest" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d "$(jq -n --arg c "$CONTENT" --arg r "$RATIONALE" \
    '{"content": $c, "rationale": $r}')")

SUG_ID=$(echo "$RESPONSE" | jq -r '.id')
STATUS=$(echo "$RESPONSE" | jq -r '.status')

echo "Suggestion $SUG_ID created with status: $STATUS"
echo "The note owner will see the diff in Leaderbook and can accept or reject it."

Approve all pending suggestions via script

When: You're running automated tests or a review pipeline and want to bulk-approve suggestions without opening the browser.

bash#!/usr/bin/env bash
API_KEY="lb_live_abcd1234_XXXX"
NOTE_ID="clxnote1"

# Fetch pending suggestions
RESPONSE=$(curl -s "https://leaderbook.app/api/v1/notes/$NOTE_ID/suggestions" \
  -H "Authorization: Bearer $API_KEY")

echo "$RESPONSE" | jq -c '.data[] | select(.status == "PENDING")' | while IFS= read -r item; do
  SUG_ID=$(echo "$item" | jq -r '.id')
  echo "Approving $SUG_ID…"
  curl -s -X POST "https://leaderbook.app/api/v1/suggestions/$SUG_ID/approve" \
    -H "Authorization: Bearer $API_KEY"
  echo ""
done

echo "Done."

Mark all TODO tasks in a notebook as DONE

When: End of sprint cleanup — mark a batch of tasks done after a release.

bash#!/usr/bin/env bash
API_KEY="lb_live_abcd1234_XXXX"
NOTEBOOK_ID="clxnb1"

CURSOR=""

while true; do
  PARAMS="notebookId=$NOTEBOOK_ID&status=TODO&limit=100"
  [ -n "$CURSOR" ] && PARAMS="$PARAMS&cursor=$CURSOR"

  RESPONSE=$(curl -s "https://leaderbook.app/api/v1/tasks?$PARAMS" \
    -H "Authorization: Bearer $API_KEY")

  echo "$RESPONSE" | jq -c '.data[]' | while IFS= read -r item; do
    ID=$(echo "$item" | jq -r '.id')
    TITLE=$(echo "$item" | jq -r '.title')
    echo "Marking done: $TITLE"
    curl -s -X PATCH "https://leaderbook.app/api/v1/tasks/$ID" \
      -H "Authorization: Bearer $API_KEY" \
      -H "Content-Type: application/json" \
      -d '{ "status": "DONE" }'
    echo ""
  done

  NEXT=$(echo "$RESPONSE" | jq -r '.nextCursor')
  [ "$NEXT" = "null" ] && break
  CURSOR="$NEXT"
done

echo "All TODO tasks marked as done."

Ready to get started?

Lead with clarity. Work with confidence.

Leaderbook helps you organize decisions, meetings, priorities, and follow-ups. All in one private notebook built for managers who want less chaos and more impact.

Get started