CLI Reference

Complete command-line interface documentation for lsvault

Getting Started

The Lifestream Vault CLI (lsvault) provides a powerful command-line interface for managing vaults, documents, and all SaaS features.

Installation

Install globally via npm:

npm install -g @lifestreamdynamics/vault-cli

OS Keychain Support (Optional)

For secure credential storage via OS keychain on Linux:

sudo apt install libsecret-1-dev

On macOS and Windows, keychain support is built-in.

Authentication

Login with an API key:

lsvault auth login --api-key lsv_k_your_api_key_here

Set the API URL if using a custom instance:

lsvault auth login --api-key lsv_k_abc123 --api-url https://api.example.com

Email/Password Authentication

Login with email and password for JWT-based auth:

lsvault auth login --email user@example.com
# Password will be prompted interactively

Check your authentication status:

lsvault auth whoami

Configuration

Configuration Sources (Precedence Order)

The CLI loads configuration from multiple sources in this order:

  1. Environment variables: LSVAULT_API_URL and LSVAULT_API_KEY
  2. OS Keychain (if keytar available): Secure credential storage
  3. Encrypted config: ~/.lsvault/credentials.enc (AES-256-GCM)
  4. Plaintext config (deprecated): ~/.lsvault/config.json

Default Values

  • API URL: http://localhost:4660 (development)
  • Output format: text (when stdout is a TTY), json otherwise

Managing Configuration

View current configuration:

lsvault auth status

Migrate plaintext credentials to secure storage:

lsvault auth migrate

Clear all stored credentials:

lsvault auth logout

Global Flags

All commands support these global flags:

FlagDescriptionDefault
--output <format>Output format: text, json, or tabletext
--no-colorDisable colored outputColor enabled
--verboseEnable verbose/debug outputDisabled

Output Format Examples

Text output (default for terminals):

lsvault vaults list

JSON output (pipe to jq):

lsvault vaults list --output json | jq '.[] | .name'

Table output:

lsvault docs list <vaultId> --output table

Quick Start Example

# 1. Login
lsvault auth login --api-key lsv_k_abc123

# 2. Create a vault
lsvault vaults create "My Notes"

# 3. List vaults to get the vault ID
lsvault vaults list --output json

# 4. Create a document
echo "# Hello World" | lsvault docs put <vaultId> notes/hello.md

# 5. Read it back
lsvault docs get <vaultId> notes/hello.md

# 6. Search across all vaults
lsvault search "hello"

Next Steps

auth

Authentication and credential management

login

$ lsvault auth login [options]

Authenticate with an API key or email/password credentials

Options

FlagDescriptionDefault
--api-key <key>API key (lsv_k_... prefix)
--email <email>Email address for password login
--password <password>Password (prompts interactively if omitted)
--api-url <url>API server URLhttp://localhost:4660

Examples

Login with API key

bash
lsvault auth login --api-key lsv_k_abc123

Login with email (password prompted)

bash
lsvault auth login --email user@example.com

Login with email and custom API URL

bash
lsvault auth login --email user@example.com --api-url https://api.example.com

refresh

$ lsvault auth refresh

Refresh the JWT access token using the stored refresh token

Examples

Refresh access token

bash
lsvault auth refresh

logout

$ lsvault auth logout

Clear all stored credentials from keychain and config

Examples

Logout and clear credentials

bash
lsvault auth logout

status

$ lsvault auth status

Show credential storage method, auth type, and connection info

Examples

View authentication status

bash
lsvault auth status

migrate

$ lsvault auth migrate

Migrate plaintext credentials from config.json to secure storage

Examples

Migrate credentials to OS keychain

bash
lsvault auth migrate

whoami

$ lsvault auth whoami

Show the currently authenticated user, plan, and API URL

Examples

View current user info

bash
lsvault auth whoami

config

Manage CLI configuration profiles

show

$ lsvault config show

Display current configuration and active profile

Examples

Show current configuration

bash
lsvault config show

set-profile

$ lsvault config set-profile <name>

Switch to a different configuration profile

Arguments

NameRequiredDescription
<name>YesProfile name

Examples

Switch to production profile

bash
lsvault config set-profile production

get-profile

$ lsvault config get-profile

Show the currently active profile name

Examples

Get active profile

bash
lsvault config get-profile

list-profiles

$ lsvault config list-profiles

List all available configuration profiles

Examples

List all profiles

bash
lsvault config list-profiles

remove-profile

$ lsvault config remove-profile <name>

Delete a configuration profile

Arguments

NameRequiredDescription
<name>YesProfile name to remove

Examples

Remove old profile

bash
lsvault config remove-profile old-staging

vaults

Create, list, and inspect document vaults

list

$ lsvault vaults list

List all vaults accessible to the current user

Examples

List all vaults

bash
lsvault vaults list

List vaults in JSON format

bash
lsvault vaults list --output json

get

$ lsvault vaults get <vaultId>

Show detailed information about a vault

Arguments

NameRequiredDescription
<vaultId>YesVault ID or slug

Examples

Get vault details

bash
lsvault vaults get abc123

Get vault by slug

bash
lsvault vaults get my-notes

create

$ lsvault vaults create <name> [options]

Create a new vault

Arguments

NameRequiredDescription
<name>YesVault name (used to generate URL slug)

Options

FlagDescriptionDefault
-d, --description <desc>Vault description
--encryptedEnable client-side encryption (AES-256-GCM)

Examples

Create a simple vault

bash
lsvault vaults create "My Notes"

Create vault with description

bash
lsvault vaults create "Work Journal" --description "Daily work log"

Create encrypted vault

bash
lsvault vaults create "Secrets" --encrypted

export-key

$ lsvault vaults export-key <vaultId>

Export the encryption key for an encrypted vault

Arguments

NameRequiredDescription
<vaultId>YesVault ID

Examples

Export vault encryption key

bash
lsvault vaults export-key abc123

Save key to file

bash
lsvault vaults export-key abc123 > vault-key.txt

import-key

$ lsvault vaults import-key <vaultId> --key <keyHex>

Import an encryption key for an encrypted vault

Arguments

NameRequiredDescription
<vaultId>YesVault ID

Options

FlagDescriptionDefault
--key <key>Encryption key (64-character hex string)

Examples

Import vault key

bash
lsvault vaults import-key abc123 --key 0123456789abcdef...

docs

Read, write, move, and delete documents in a vault

list

$ lsvault docs list <vaultId> [options]

List documents in a vault, optionally filtered by directory

Arguments

NameRequiredDescription
<vaultId>YesVault ID

Options

FlagDescriptionDefault
--dir <path>Filter by directory path

Examples

List all documents in vault

bash
lsvault docs list abc123

List documents in a subdirectory

bash
lsvault docs list abc123 --dir notes/meetings

List with table output

bash
lsvault docs list abc123 --output table

get

$ lsvault docs get <vaultId> <path> [options]

Print document content to stdout, or show metadata with --meta

Arguments

NameRequiredDescription
<vaultId>YesVault ID
<path>YesDocument path (e.g., notes/todo.md)

Options

FlagDescriptionDefault
--metaShow metadata instead of content

Examples

Print document content

bash
lsvault docs get abc123 notes/todo.md

Show document metadata

bash
lsvault docs get abc123 notes/todo.md --meta

Save to local file

bash
lsvault docs get abc123 notes/todo.md > local-copy.md

put

$ lsvault docs put <vaultId> <path>

Create or update a document by reading content from stdin

Arguments

NameRequiredDescription
<vaultId>YesVault ID
<path>YesDocument path (must end with .md)

Examples

Create document from echo

bash
echo "# Hello" | lsvault docs put abc123 notes/hello.md

Upload local file

bash
cat local-file.md | lsvault docs put abc123 docs/imported.md

Pipe from pandoc conversion

bash
pandoc input.docx -t markdown | lsvault docs put abc123 converted.md

delete

$ lsvault docs delete <vaultId> <path>

Permanently delete a document from a vault

Arguments

NameRequiredDescription
<vaultId>YesVault ID
<path>YesDocument path to delete

Examples

Delete a document

bash
lsvault docs delete abc123 notes/old.md

move

$ lsvault docs move <vaultId> <source> <dest> [options]

Move or rename a document within a vault

Arguments

NameRequiredDescription
<vaultId>YesVault ID
<source>YesCurrent document path
<dest>YesNew document path

Options

FlagDescriptionDefault
--overwriteOverwrite if destination already exists

Examples

Rename a document

bash
lsvault docs move abc123 notes/old.md notes/new.md

Move to different directory

bash
lsvault docs move abc123 draft.md published/final.md

Move with overwrite

bash
lsvault docs move abc123 temp.md final.md --overwrite

keys

Manage API keys for programmatic access

list

$ lsvault keys list

List all API keys for the current user

Examples

List API keys

bash
lsvault keys list

List with table output

bash
lsvault keys list --output table

get

$ lsvault keys get <keyId>

Show detailed information about an API key

Arguments

NameRequiredDescription
<keyId>YesAPI key ID

Examples

Get API key details

bash
lsvault keys get key_abc123

create

$ lsvault keys create <name> [options]

Create a new API key with scopes and optional vault restriction

Arguments

NameRequiredDescription
<name>YesAPI key name

Options

FlagDescriptionDefault
--scopes <scopes>Comma-separated scopes (e.g., "documents:read,documents:write")
--vault <vaultId>Restrict key to specific vault
--expires <date>Expiration date (ISO 8601)

Examples

Create read-only key

bash
lsvault keys create "Read Only" --scopes "documents:read"

Create vault-specific key

bash
lsvault keys create "Mobile App" --scopes "documents:read,documents:write" --vault abc123

Create key with expiration

bash
lsvault keys create "Temp Key" --scopes "documents:read" --expires "2024-12-31"

update

$ lsvault keys update <keyId> [options]

Update API key name or activation status

Arguments

NameRequiredDescription
<keyId>YesAPI key ID

Options

FlagDescriptionDefault
--name <name>New name for the API key
--deactivateDeactivate the key
--activateReactivate the key

Examples

Rename API key

bash
lsvault keys update key_abc123 --name "Production Key"

Deactivate API key

bash
lsvault keys update key_abc123 --deactivate

delete

$ lsvault keys delete <keyId>

Permanently delete an API key

Arguments

NameRequiredDescription
<keyId>YesAPI key ID to delete

Examples

Delete API key

bash
lsvault keys delete key_abc123

user

View current user information and storage usage

me

$ lsvault user me

Show current user profile and subscription details

Examples

View user profile

bash
lsvault user me

storage

$ lsvault user storage

Show storage usage and quota information

Examples

Check storage usage

bash
lsvault user storage

Get storage in JSON format

bash
lsvault user storage --output json

subscription

pro+ required

View subscription status and available plans

status

$ lsvault subscription status

Show current subscription tier and expiration

Examples

Check subscription status

bash
lsvault subscription status

plans

$ lsvault subscription plans

List available subscription plans and features

Examples

View available plans

bash
lsvault subscription plans

Get plans in JSON format

bash
lsvault subscription plans --output json

teams

business+ required

Manage teams, members, and team vaults

list

$ lsvault teams list

List all teams you are a member of

Examples

List teams

bash
lsvault teams list

get

$ lsvault teams get <teamId>

Show detailed information about a team

Arguments

NameRequiredDescription
<teamId>YesTeam ID

Examples

Get team details

bash
lsvault teams get team_abc123

create

$ lsvault teams create <name> [options]

Create a new team

Arguments

NameRequiredDescription
<name>YesTeam name

Options

FlagDescriptionDefault
--description <desc>Team description

Examples

Create a team

bash
lsvault teams create "Engineering Team"

Create team with description

bash
lsvault teams create "Marketing" --description "Marketing department"

members

$ lsvault teams members <teamId>

List all members of a team

Arguments

NameRequiredDescription
<teamId>YesTeam ID

Examples

List team members

bash
lsvault teams members team_abc123

invite

$ lsvault teams invite <teamId> <email> [options]

Invite a user to join a team

Arguments

NameRequiredDescription
<teamId>YesTeam ID
<email>YesEmail address of user to invite

Options

FlagDescriptionDefault
--role <role>Team role: member, admin, or ownermember

Examples

Invite team member

bash
lsvault teams invite team_abc123 user@example.com

Invite as admin

bash
lsvault teams invite team_abc123 admin@example.com --role admin

invitations

$ lsvault teams invitations <teamId>

List pending invitations for a team

Arguments

NameRequiredDescription
<teamId>YesTeam ID

Examples

List pending invitations

bash
lsvault teams invitations team_abc123

revoke-invitation

$ lsvault teams revoke-invitation <teamId> <invitationId>

Revoke a pending team invitation

Arguments

NameRequiredDescription
<teamId>YesTeam ID
<invitationId>YesInvitation ID

Examples

Revoke invitation

bash
lsvault teams revoke-invitation team_abc123 inv_xyz789

update-role

$ lsvault teams update-role <teamId> <userId> <role>

Update a team member's role

Arguments

NameRequiredDescription
<teamId>YesTeam ID
<userId>YesUser ID
<role>YesNew role: member, admin, or owner

Examples

Promote to admin

bash
lsvault teams update-role team_abc123 user_xyz789 admin

remove-member

$ lsvault teams remove-member <teamId> <userId>

Remove a member from a team

Arguments

NameRequiredDescription
<teamId>YesTeam ID
<userId>YesUser ID to remove

Examples

Remove team member

bash
lsvault teams remove-member team_abc123 user_xyz789

leave

$ lsvault teams leave <teamId>

Leave a team (owners cannot leave)

Arguments

NameRequiredDescription
<teamId>YesTeam ID to leave

Examples

Leave a team

bash
lsvault teams leave team_abc123

vaults

$ lsvault teams vaults <teamId>

List all vaults owned by a team

Arguments

NameRequiredDescription
<teamId>YesTeam ID

Examples

List team vaults

bash
lsvault teams vaults team_abc123

create-vault

$ lsvault teams create-vault <teamId> <name>

Create a new vault owned by the team

Arguments

NameRequiredDescription
<teamId>YesTeam ID
<name>YesVault name

Examples

Create team vault

bash
lsvault teams create-vault team_abc123 "Team Documents"

hooks

pro+ required

Manage vault hooks for automated document processing

list

$ lsvault hooks list <vaultId>

List all hooks configured for a vault

Arguments

NameRequiredDescription
<vaultId>YesVault ID

Examples

List vault hooks

bash
lsvault hooks list abc123

create

$ lsvault hooks create <vaultId> <name> [options]

Create a new hook for automated processing

Arguments

NameRequiredDescription
<vaultId>YesVault ID
<name>YesHook name

Options

FlagDescriptionDefault
--event <event>Trigger event: create, update, or delete
--action <action>Action type: auto-tag, template, etc.
--config <json>Hook configuration as JSON string

Examples

Create auto-tag hook

bash
lsvault hooks create abc123 "Auto Tag" --event create --action auto-tag --config '{"tags":["new"]}'

update

$ lsvault hooks update <vaultId> <hookId> [options]

Update hook configuration or activation status

Arguments

NameRequiredDescription
<vaultId>YesVault ID
<hookId>YesHook ID

Options

FlagDescriptionDefault
--deactivateDeactivate the hook

Examples

Deactivate hook

bash
lsvault hooks update abc123 hook_xyz789 --deactivate

delete

$ lsvault hooks delete <vaultId> <hookId>

Permanently delete a hook

Arguments

NameRequiredDescription
<vaultId>YesVault ID
<hookId>YesHook ID to delete

Examples

Delete hook

bash
lsvault hooks delete abc123 hook_xyz789

executions

$ lsvault hooks executions <vaultId> <hookId>

View execution history for a hook

Arguments

NameRequiredDescription
<vaultId>YesVault ID
<hookId>YesHook ID

Examples

View hook execution history

bash
lsvault hooks executions abc123 hook_xyz789

webhooks

pro+ required

Manage webhooks for external integrations

list

$ lsvault webhooks list <vaultId>

List all webhooks configured for a vault

Arguments

NameRequiredDescription
<vaultId>YesVault ID

Examples

List vault webhooks

bash
lsvault webhooks list abc123

create

$ lsvault webhooks create <vaultId> <url> [options]

Create a new webhook endpoint

Arguments

NameRequiredDescription
<vaultId>YesVault ID
<url>YesWebhook URL

Options

FlagDescriptionDefault
--events <events>Comma-separated event types: create, update, delete

Examples

Create webhook for all events

bash
lsvault webhooks create abc123 https://api.example.com/webhook --events "create,update,delete"

Create webhook for document creation only

bash
lsvault webhooks create abc123 https://api.example.com/webhook --events "create"

update

$ lsvault webhooks update <vaultId> <webhookId> [options]

Update webhook configuration or activation status

Arguments

NameRequiredDescription
<vaultId>YesVault ID
<webhookId>YesWebhook ID

Options

FlagDescriptionDefault
--deactivateDeactivate the webhook

Examples

Deactivate webhook

bash
lsvault webhooks update abc123 webhook_xyz789 --deactivate

delete

$ lsvault webhooks delete <vaultId> <webhookId>

Permanently delete a webhook

Arguments

NameRequiredDescription
<vaultId>YesVault ID
<webhookId>YesWebhook ID to delete

Examples

Delete webhook

bash
lsvault webhooks delete abc123 webhook_xyz789

deliveries

$ lsvault webhooks deliveries <vaultId> <webhookId>

View delivery history and status for a webhook

Arguments

NameRequiredDescription
<vaultId>YesVault ID
<webhookId>YesWebhook ID

Examples

View webhook delivery history

bash
lsvault webhooks deliveries abc123 webhook_xyz789

shares

pro+ required

Create and manage share links for documents

list

$ lsvault shares list <vaultId> <path>

List all share links for a document

Arguments

NameRequiredDescription
<vaultId>YesVault ID
<path>YesDocument path

Examples

List share links for a document

bash
lsvault shares list abc123 notes/meeting.md

create

$ lsvault shares create <vaultId> <path> [options]

Create a new share link for a document

Arguments

NameRequiredDescription
<vaultId>YesVault ID
<path>YesDocument path

Options

FlagDescriptionDefault
--permission <perm>Permission level: read or writeread
--password <pwd>Optional password protection
--expires <date>Expiration date (ISO 8601)
--max-views <n>Maximum number of views

Examples

Create simple share link

bash
lsvault shares create abc123 notes/meeting.md

Create password-protected link

bash
lsvault shares create abc123 notes/secret.md --password "s3cr3t"

Create link with expiration

bash
lsvault shares create abc123 notes/temp.md --expires "2024-12-31"

Create link with view limit

bash
lsvault shares create abc123 notes/limited.md --max-views 10

revoke

$ lsvault shares revoke <vaultId> <shareId>

Revoke a share link

Arguments

NameRequiredDescription
<vaultId>YesVault ID
<shareId>YesShare link ID

Examples

Revoke share link

bash
lsvault shares revoke abc123 share_xyz789

publish

pro+ required

Publish documents to public URLs with SEO metadata

list

$ lsvault publish list <vaultId>

List all published documents in a vault

Arguments

NameRequiredDescription
<vaultId>YesVault ID

Examples

List published documents

bash
lsvault publish list abc123

create

$ lsvault publish create <vaultId> <path> [options]

Publish a document to a public URL

Arguments

NameRequiredDescription
<vaultId>YesVault ID
<path>YesDocument path

Options

FlagDescriptionDefault
--slug <slug>Custom URL slug
--title <title>SEO title override
--description <desc>SEO meta description
--og-image <url>Open Graph image URL

Examples

Publish document

bash
lsvault publish create abc123 blog/first-post.md

Publish with custom slug

bash
lsvault publish create abc123 blog/post.md --slug "my-first-post"

Publish with SEO metadata

bash
lsvault publish create abc123 blog/post.md --title "My Post" --description "A great post"

update

$ lsvault publish update <vaultId> <path> [options]

Update published document metadata

Arguments

NameRequiredDescription
<vaultId>YesVault ID
<path>YesDocument path

Options

FlagDescriptionDefault
--slug <slug>New URL slug

Examples

Update publication slug

bash
lsvault publish update abc123 blog/post.md --slug "new-slug"

delete

$ lsvault publish delete <vaultId> <path>

Unpublish a document

Arguments

NameRequiredDescription
<vaultId>YesVault ID
<path>YesDocument path

Examples

Unpublish document

bash
lsvault publish delete abc123 blog/post.md

connectors

pro+ required

Manage external service connectors (Google Drive, etc.)

list

$ lsvault connectors list [options]

List all configured connectors

Options

FlagDescriptionDefault
--vault <vaultId>Filter to specific vault

Examples

List all connectors

bash
lsvault connectors list

List connectors for vault

bash
lsvault connectors list --vault abc123

get

$ lsvault connectors get <connectorId>

Show detailed information about a connector

Arguments

NameRequiredDescription
<connectorId>YesConnector ID

Examples

Get connector details

bash
lsvault connectors get conn_abc123

create

$ lsvault connectors create [options]

Create a new external connector

Options

FlagDescriptionDefault
--provider <provider>Provider: google-drive, dropbox, etc.
--name <name>Connector name
--vault <vaultId>Vault ID to sync with
--direction <dir>Sync direction: import, export, or bidirectionalbidirectional

Examples

Create Google Drive connector

bash
lsvault connectors create --provider google-drive --name "My Drive" --vault abc123

test

$ lsvault connectors test <connectorId>

Test connector connection and permissions

Arguments

NameRequiredDescription
<connectorId>YesConnector ID

Examples

Test connector

bash
lsvault connectors test conn_abc123

sync

$ lsvault connectors sync <connectorId>

Trigger manual synchronization

Arguments

NameRequiredDescription
<connectorId>YesConnector ID

Examples

Manually sync connector

bash
lsvault connectors sync conn_abc123

logs

$ lsvault connectors logs <connectorId>

View sync logs and history

Arguments

NameRequiredDescription
<connectorId>YesConnector ID

Examples

View sync logs

bash
lsvault connectors logs conn_abc123

delete

$ lsvault connectors delete <connectorId>

Delete a connector configuration

Arguments

NameRequiredDescription
<connectorId>YesConnector ID to delete

Examples

Delete connector

bash
lsvault connectors delete conn_abc123

admin

System administration commands (admin role required)

stats

$ lsvault admin stats

Show system-wide statistics and metrics

Examples

View system stats

bash
lsvault admin stats

timeseries

$ lsvault admin timeseries [options]

View timeseries metrics for signups, documents, storage

Options

FlagDescriptionDefault
--metric <metric>Metric type: signups, documents, or storage
--period <period>Time period: day, week, month, yearweek

Examples

View signups over past week

bash
lsvault admin timeseries --metric signups --period week

View document creation trends

bash
lsvault admin timeseries --metric documents --period month

users

$ lsvault admin users [options]

List and search system users

Options

FlagDescriptionDefault
--search <query>Search by email or name
--tier <tier>Filter by subscription tier

Examples

List all users

bash
lsvault admin users

Search for user

bash
lsvault admin users --search "user@example.com"

List pro users

bash
lsvault admin users --tier pro

user

$ lsvault admin user <userId>

Show detailed user information

Arguments

NameRequiredDescription
<userId>YesUser ID

Examples

View user details

bash
lsvault admin user user_abc123

update-user

$ lsvault admin update-user <userId> [options]

Update user role or subscription tier

Arguments

NameRequiredDescription
<userId>YesUser ID

Options

FlagDescriptionDefault
--role <role>User role: user or admin
--tier <tier>Subscription tier: free, pro, or business

Examples

Promote to admin

bash
lsvault admin update-user user_abc123 --role admin

Update subscription tier

bash
lsvault admin update-user user_abc123 --tier pro

activity

$ lsvault admin activity [options]

View recent system activity

Options

FlagDescriptionDefault
--limit <n>Maximum results50

Examples

View recent activity

bash
lsvault admin activity

View last 100 events

bash
lsvault admin activity --limit 100

subscriptions

$ lsvault admin subscriptions

View subscription statistics across all users

Examples

View subscription breakdown

bash
lsvault admin subscriptions

health

$ lsvault admin health

Check system health (database, Redis, workers)

Examples

Check system health

bash
lsvault admin health

audit

business+ required

View audit logs for security and compliance

list

$ lsvault audit list [options]

List audit log entries

Options

FlagDescriptionDefault
--type <type>Event type filter
--output <format>Output format: text, json, or table

Examples

List recent audit logs

bash
lsvault audit list

Filter by event type

bash
lsvault audit list --type login

Export audit logs to JSON

bash
lsvault audit list --output json > audit-logs.json

sync

Local file synchronization with vault documents

init

$ lsvault sync init <vaultId> <localPath> [options]

Initialize a local sync folder for a vault

Arguments

NameRequiredDescription
<vaultId>YesVault ID to sync
<localPath>YesLocal directory path

Options

FlagDescriptionDefault
--mode <mode>Sync mode: push, pull, or bidirectionalbidirectional
--on-conflict <strategy>Conflict resolution: newer, local, or remotenewer

Examples

Initialize bidirectional sync

bash
lsvault sync init abc123 ~/Documents/vault

Initialize pull-only sync

bash
lsvault sync init abc123 ~/vault --mode pull

list

$ lsvault sync list

List all configured sync folders

Examples

List sync configurations

bash
lsvault sync list

pull

$ lsvault sync pull <syncId> [options]

Pull changes from vault to local folder

Arguments

NameRequiredDescription
<syncId>YesSync configuration ID

Options

FlagDescriptionDefault
--dry-runPreview changes without applying

Examples

Pull changes

bash
lsvault sync pull sync_abc123

Preview pull changes

bash
lsvault sync pull sync_abc123 --dry-run

push

$ lsvault sync push <syncId> [options]

Push local changes to vault

Arguments

NameRequiredDescription
<syncId>YesSync configuration ID

Options

FlagDescriptionDefault
--dry-runPreview changes without applying

Examples

Push changes

bash
lsvault sync push sync_abc123

Preview push changes

bash
lsvault sync push sync_abc123 --dry-run

status

$ lsvault sync status <syncId>

Show sync status and pending changes

Arguments

NameRequiredDescription
<syncId>YesSync configuration ID

Examples

Check sync status

bash
lsvault sync status sync_abc123

watch

$ lsvault sync watch <syncId>

Start watching for file changes and auto-sync

Arguments

NameRequiredDescription
<syncId>YesSync configuration ID

Examples

Start file watcher

bash
lsvault sync watch sync_abc123

resolve

$ lsvault sync resolve <syncId> <path> --use <source>

Manually resolve a sync conflict

Arguments

NameRequiredDescription
<syncId>YesSync configuration ID
<path>YesConflicted file path

Options

FlagDescriptionDefault
--use <source>Use local or remote version

Examples

Resolve with local version

bash
lsvault sync resolve sync_abc123 notes/conflict.md --use local

Resolve with remote version

bash
lsvault sync resolve sync_abc123 notes/conflict.md --use remote

daemon start

$ lsvault sync daemon start

Start the sync daemon for automatic background sync

Examples

Start sync daemon

bash
lsvault sync daemon start

daemon stop

$ lsvault sync daemon stop

Stop the sync daemon

Examples

Stop sync daemon

bash
lsvault sync daemon stop

daemon status

$ lsvault sync daemon status

Check if sync daemon is running

Examples

Check daemon status

bash
lsvault sync daemon status

delete

$ lsvault sync delete <syncId>

Delete a sync configuration

Arguments

NameRequiredDescription
<syncId>YesSync configuration ID to delete

Examples

Delete sync configuration

bash
lsvault sync delete sync_abc123

Common Workflows

Backup All Documents from a Vault

#!/bin/bash
# Backup script for a vault

VAULT_ID="abc123"
BACKUP_DIR="./backup-$(date +%Y%m%d)"

# Create backup directory
mkdir -p "$BACKUP_DIR"

# Get list of documents and download each
lsvault docs list $VAULT_ID --output json | jq -r '.[] | .path' | while read path; do
  echo "Backing up: $path"
  mkdir -p "$BACKUP_DIR/$(dirname "$path")"
  lsvault docs get $VAULT_ID "$path" > "$BACKUP_DIR/$path"
done

echo "Backup complete: $BACKUP_DIR"

Bulk Upload Markdown Files

#!/bin/bash
# Upload all markdown files from a directory

VAULT_ID="abc123"
SOURCE_DIR="./local-docs"

find "$SOURCE_DIR" -name "*.md" -type f | while read file; do
  # Calculate relative path
  rel_path="${file#$SOURCE_DIR/}"
  echo "Uploading: $rel_path"
  cat "$file" | lsvault docs put $VAULT_ID "$rel_path"
done

Mirror a Vault to Another

#!/bin/bash
# Copy all documents from one vault to another

SOURCE_VAULT="abc123"
DEST_VAULT="xyz789"

lsvault docs list $SOURCE_VAULT --output json | jq -r '.[] | .path' | while read path; do
  echo "Copying: $path"
  lsvault docs get $SOURCE_VAULT "$path" | lsvault docs put $DEST_VAULT "$path"
done

Search and Export Results

# Search and save matching documents
VAULT_ID="abc123"
QUERY="important & meeting"

# Get search results
lsvault search "$QUERY" --vault $VAULT_ID --output json > search-results.json

# Download all matching documents
cat search-results.json | jq -r '.[] | .path' | while read path; do
  echo "Downloading: $path"
  lsvault docs get $VAULT_ID "$path" > "export/${path}"
done

Convert and Upload Documents

# Convert Word documents to Markdown and upload
VAULT_ID="abc123"

find ./docs -name "*.docx" | while read file; do
  basename="${file%.docx}"
  md_path="${basename#./docs/}.md"

  echo "Converting: $file -> $md_path"
  pandoc "$file" -t markdown | lsvault docs put $VAULT_ID "$md_path"
done

Automated Daily Backup with Cron

Add to crontab (crontab -e):

# Daily backup at 2 AM
0 2 * * * /home/user/scripts/vault-backup.sh >> /var/log/vault-backup.log 2>&1

Backup script (vault-backup.sh):

#!/bin/bash
set -e

VAULT_ID="abc123"
BACKUP_ROOT="/backups/vault"
DATE=$(date +%Y%m%d)
BACKUP_DIR="$BACKUP_ROOT/$DATE"

mkdir -p "$BACKUP_DIR"

# Backup all documents
lsvault docs list $VAULT_ID --output json | jq -r '.[] | .path' | while read path; do
  mkdir -p "$BACKUP_DIR/$(dirname "$path")"
  lsvault docs get $VAULT_ID "$path" > "$BACKUP_DIR/$path"
done

# Create tarball
tar -czf "$BACKUP_ROOT/vault-$DATE.tar.gz" -C "$BACKUP_ROOT" "$DATE"

# Remove directory (keep tarball)
rm -rf "$BACKUP_DIR"

# Keep only last 30 days
find "$BACKUP_ROOT" -name "vault-*.tar.gz" -mtime +30 -delete

echo "Backup complete: vault-$DATE.tar.gz"
# Create share links for multiple documents
VAULT_ID="abc123"

# Documents to share
DOCS=("blog/post1.md" "blog/post2.md" "blog/post3.md")

for doc in "${DOCS[@]}"; do
  echo "Creating share link for: $doc"
  lsvault shares create $VAULT_ID "$doc" --expires "2024-12-31" --output json | \
    jq -r '"Share link: " + .url'
done

Monitor Webhook Deliveries

#!/bin/bash
# Check webhook delivery status

VAULT_ID="abc123"
WEBHOOK_ID="webhook_xyz789"

while true; do
  clear
  echo "Webhook Deliveries (refreshing every 30s)"
  echo "=========================================="
  lsvault webhooks deliveries $VAULT_ID $WEBHOOK_ID --output table
  sleep 30
done

Scripting & Piping

Piping Basics

The CLI is designed for Unix-style piping. Most commands that output content (like docs get) write to stdout, while status messages go to stderr.

Document Content Flow

# Pipe document between vaults
lsvault docs get vault1 "notes.md" | lsvault docs put vault2 "copied-notes.md"

# Pipe to/from local files
cat local-file.md | lsvault docs put abc123 "uploaded.md"
lsvault docs get abc123 "downloaded.md" > local-copy.md

# Process with standard tools
lsvault docs get abc123 "notes.md" | wc -w  # Word count
lsvault docs get abc123 "notes.md" | grep "TODO"  # Search content

JSON Processing with jq

# Extract specific fields
lsvault vaults list --output json | jq '.[] | .name'

# Filter results
lsvault docs list abc123 --output json | jq '.[] | select(.tags | contains(["important"]))'

# Complex transformations
lsvault search "meeting" --output json | \
  jq 'group_by(.vaultId) | map({vault: .[0].vaultId, count: length})'

Error Handling in Scripts

#!/bin/bash
set -e  # Exit on error
set -o pipefail  # Catch errors in pipes

VAULT_ID="abc123"

# Check if document exists before processing
if lsvault docs get $VAULT_ID "notes.md" --meta &>/dev/null; then
  echo "Document exists, proceeding..."
else
  echo "Error: Document not found" >&2
  exit 1
fi

# Capture output and exit code
if content=$(lsvault docs get $VAULT_ID "notes.md" 2>&1); then
  echo "Success: $content"
else
  echo "Failed to fetch document" >&2
  exit 1
fi

Batch Operations with Parallel Processing

#!/bin/bash
# Upload multiple files in parallel

VAULT_ID="abc123"

# Export function for parallel execution
upload_file() {
  local file="$1"
  local vault_id="$2"
  local rel_path="${file#./docs/}"

  echo "Uploading: $rel_path"
  cat "$file" | lsvault docs put "$vault_id" "$rel_path"
}

export -f upload_file

# Upload up to 4 files in parallel
find ./docs -name "*.md" | \
  parallel -j 4 upload_file {} $VAULT_ID

Conditional Logic Based on Output

#!/bin/bash
# Check subscription tier and act accordingly

tier=$(lsvault user me --output json | jq -r '.subscriptionTier')

if [ "$tier" = "pro" ] || [ "$tier" = "business" ]; then
  echo "Creating share link (available on $tier plan)..."
  lsvault shares create abc123 "notes.md"
else
  echo "Share links require Pro or Business plan"
fi

Output Formatting in Scripts

# Always use --output json for machine parsing
VAULT_COUNT=$(lsvault vaults list --output json | jq 'length')
echo "You have $VAULT_COUNT vaults"

# Use --no-color for log files
lsvault docs list abc123 --no-color --output table > report.txt

# Combine verbose mode with log redirection
lsvault docs put abc123 "test.md" --verbose 2> debug.log

Credential Management in CI/CD

#!/bin/bash
# CI/CD script using environment variables

# Set credentials via environment (no interactive login needed)
export LSVAULT_API_URL="https://vault.lifestreamdynamics.com"
export LSVAULT_API_KEY="lsv_k_ci_key_here"

# Verify connection
if ! lsvault auth whoami --output json &>/dev/null; then
  echo "Authentication failed" >&2
  exit 1
fi

# Run operations
lsvault docs list abc123 --output json > docs-list.json

Advanced: Sync Script with Conflict Detection

#!/bin/bash
# Sync local files to vault with conflict detection

VAULT_ID="abc123"
LOCAL_DIR="./docs"

sync_file() {
  local file="$1"
  local vault_id="$2"
  local rel_path="${file#$LOCAL_DIR/}"

  # Get local file hash
  local_hash=$(sha256sum "$file" | cut -d' ' -f1)

  # Get remote document hash (if exists)
  remote_hash=$(lsvault docs get "$vault_id" "$rel_path" --meta --output json 2>/dev/null | \
    jq -r '.contentHash // empty')

  if [ -z "$remote_hash" ]; then
    echo "New file: $rel_path"
    cat "$file" | lsvault docs put "$vault_id" "$rel_path"
  elif [ "$local_hash" != "$remote_hash" ]; then
    echo "Modified file: $rel_path"
    cat "$file" | lsvault docs put "$vault_id" "$rel_path"
  else
    echo "Unchanged: $rel_path"
  fi
}

export -f sync_file

find "$LOCAL_DIR" -name "*.md" -type f | \
  parallel -j 2 sync_file {} $VAULT_ID

Output Formats

The CLI supports three output formats optimized for different use cases.

Text Format (Default)

Human-readable output with colors and formatting.

lsvault vaults list
# Output:
# My Notes (my-notes) [encrypted] -- Personal notes
# Work Journal (work-journal) -- Daily work log

Features:

  • Colored output when stdout is a TTY
  • Emoji and symbols for status indicators
  • Optimized for readability
  • Automatic color detection (--no-color to disable)

JSON Format

Machine-readable structured data.

lsvault vaults list --output json
# Output:
# [
#   {
#     "id": "abc123",
#     "name": "My Notes",
#     "slug": "my-notes",
#     "encrypted": true,
#     "description": "Personal notes",
#     "createdAt": "2024-01-01T00:00:00.000Z"
#   }
# ]

Use cases:

  • Piping to jq for filtering/transformation
  • Parsing in scripts
  • Integration with other tools
  • CI/CD pipelines

Best practices:

# Extract specific fields
lsvault vaults list --output json | jq -r '.[] | .name'

# Filter and count
lsvault docs list abc123 --output json | jq 'length'

# Complex queries
lsvault search "meeting" --output json | \
  jq '.[] | select(.tags | contains(["important"]))| .path'

Table Format

Structured tabular output.

lsvault docs list abc123 --output table
# Output:
# +-------------------+-------------+-------+------+
# | Path              | Title       | Tags  | Size |
# +-------------------+-------------+-------+------+
# | notes/hello.md    | Hello World | new   | 1024 |
# | notes/meeting.md  | Meeting     | work  | 2048 |
# +-------------------+-------------+-------+------+

Use cases:

  • Reports and dashboards
  • Piping to column or csvlook
  • Better readability for list commands

Automatic Format Selection

The CLI automatically selects the best format based on context:

  • TTY detected: Uses text format with colors
  • Pipe/redirect: Uses json format (for better machine parsing)
  • Explicit flag: Always honors --output flag
# TTY: colorful text output
lsvault vaults list

# Piped: JSON output (auto-selected)
lsvault vaults list | jq '.[] | .name'

# Force text in pipe
lsvault vaults list --output text | less

Raw Output for Document Content

Document content commands (docs get) output raw content by default:

# Raw markdown (no JSON wrapping)
lsvault docs get abc123 "notes.md"

# Use --meta flag for metadata as JSON
lsvault docs get abc123 "notes.md" --meta --output json

Color Control

# Disable colors (useful for log files)
lsvault vaults list --no-color

# Force colors even when piped
FORCE_COLOR=1 lsvault vaults list

# Environment variable
export LSVAULT_NO_COLOR=1
lsvault vaults list

Daemon Mode

The sync daemon enables automatic background synchronization of local folders with vaults.

Starting the Daemon

# Start daemon in background
lsvault sync daemon start

# Check daemon status
lsvault sync daemon status

# Stop daemon
lsvault sync daemon stop

Daemon Logs

Daemon logs are written to:

  • Linux: ~/.lsvault/daemon.log
  • macOS: ~/Library/Logs/lsvault-daemon.log
  • Windows: %APPDATA%\lsvault\daemon.log
# Follow daemon logs
tail -f ~/.lsvault/daemon.log

# View recent errors
grep ERROR ~/.lsvault/daemon.log | tail -20

Daemon Behavior

The daemon watches all configured sync folders and:

  1. Detects file changes (create, modify, delete)
  2. Waits for a 2-second debounce period
  3. Syncs changes to the vault based on sync mode
  4. Resolves conflicts using the configured strategy

Systemd Service (Linux)

Create a systemd user service for automatic startup:

# Create service file
cat > ~/.config/systemd/user/lsvault-sync.service <<EOF
[Unit]
Description=Lifestream Vault Sync Daemon
After=network.target

[Service]
ExecStart=/usr/bin/lsvault sync daemon start
Restart=on-failure
RestartSec=10

[Install]
WantedBy=default.target
EOF

# Enable and start service
systemctl --user enable lsvault-sync
systemctl --user start lsvault-sync

# Check status
systemctl --user status lsvault-sync

launchd Service (macOS)

Create a LaunchAgent for automatic startup:

# Create plist file
cat > ~/Library/LaunchAgents/com.lifestream.vault.sync.plist <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>com.lifestream.vault.sync</string>
  <key>ProgramArguments</key>
  <array>
    <string>/usr/local/bin/lsvault</string>
    <string>sync</string>
    <string>daemon</string>
    <string>start</string>
  </array>
  <key>RunAtLoad</key>
  <true/>
  <key>KeepAlive</key>
  <true/>
</dict>
</plist>
EOF

# Load service
launchctl load ~/Library/LaunchAgents/com.lifestream.vault.sync.plist

# Check status
launchctl list | grep lifestream

Monitoring Daemon Activity

#!/bin/bash
# Monitor daemon activity

watch -n 5 'lsvault sync daemon status && echo "" && tail -10 ~/.lsvault/daemon.log'

Troubleshooting

Daemon Won't Start

# Check for existing daemon process
ps aux | grep "lsvault sync daemon"

# Kill stale process
pkill -f "lsvault sync daemon"

# Remove PID file if stuck
rm ~/.lsvault/daemon.pid

# Restart
lsvault sync daemon start

Sync Not Working

# Check sync configurations
lsvault sync list

# Verify vault access
lsvault vaults get <vaultId>

# Check for conflicts
lsvault sync status <syncId>

# Review logs
tail -50 ~/.lsvault/daemon.log