Complete command-line interface documentation for lsvault
The Lifestream Vault CLI (lsvault) provides a powerful command-line interface for managing vaults, documents, and all SaaS features.
Install globally via npm:
npm install -g @lifestreamdynamics/vault-cli
For secure credential storage via OS keychain on Linux:
sudo apt install libsecret-1-dev
On macOS and Windows, keychain support is built-in.
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
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
The CLI loads configuration from multiple sources in this order:
LSVAULT_API_URL and LSVAULT_API_KEY~/.lsvault/credentials.enc (AES-256-GCM)~/.lsvault/config.jsonhttp://localhost:4660 (development)text (when stdout is a TTY), json otherwiseView current configuration:
lsvault auth status
Migrate plaintext credentials to secure storage:
lsvault auth migrate
Clear all stored credentials:
lsvault auth logout
All commands support these global flags:
| Flag | Description | Default |
|---|---|---|
--output <format> | Output format: text, json, or table | text |
--no-color | Disable colored output | Color enabled |
--verbose | Enable verbose/debug output | Disabled |
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
# 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"
Authentication and credential management
Authenticate with an API key or email/password credentials
| Flag | Description | Default |
|---|---|---|
| --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 URL | http://localhost:4660 |
Login with API key
lsvault auth login --api-key lsv_k_abc123Login with email (password prompted)
lsvault auth login --email user@example.comLogin with email and custom API URL
lsvault auth login --email user@example.com --api-url https://api.example.comRefresh the JWT access token using the stored refresh token
Refresh access token
lsvault auth refreshClear all stored credentials from keychain and config
Logout and clear credentials
lsvault auth logoutShow credential storage method, auth type, and connection info
View authentication status
lsvault auth statusMigrate plaintext credentials from config.json to secure storage
Migrate credentials to OS keychain
lsvault auth migrateShow the currently authenticated user, plan, and API URL
View current user info
lsvault auth whoamiManage CLI configuration profiles
Display current configuration and active profile
Show current configuration
lsvault config showSwitch to a different configuration profile
| Name | Required | Description |
|---|---|---|
| <name> | Yes | Profile name |
Switch to production profile
lsvault config set-profile productionShow the currently active profile name
Get active profile
lsvault config get-profileList all available configuration profiles
List all profiles
lsvault config list-profilesDelete a configuration profile
| Name | Required | Description |
|---|---|---|
| <name> | Yes | Profile name to remove |
Remove old profile
lsvault config remove-profile old-stagingCreate, list, and inspect document vaults
List all vaults accessible to the current user
List all vaults
lsvault vaults listList vaults in JSON format
lsvault vaults list --output jsonShow detailed information about a vault
| Name | Required | Description |
|---|---|---|
| <vaultId> | Yes | Vault ID or slug |
Get vault details
lsvault vaults get abc123Get vault by slug
lsvault vaults get my-notesCreate a new vault
| Name | Required | Description |
|---|---|---|
| <name> | Yes | Vault name (used to generate URL slug) |
| Flag | Description | Default |
|---|---|---|
| -d, --description <desc> | Vault description | — |
| --encrypted | Enable client-side encryption (AES-256-GCM) | — |
Create a simple vault
lsvault vaults create "My Notes"Create vault with description
lsvault vaults create "Work Journal" --description "Daily work log"Create encrypted vault
lsvault vaults create "Secrets" --encryptedExport the encryption key for an encrypted vault
| Name | Required | Description |
|---|---|---|
| <vaultId> | Yes | Vault ID |
Export vault encryption key
lsvault vaults export-key abc123Save key to file
lsvault vaults export-key abc123 > vault-key.txtImport an encryption key for an encrypted vault
| Name | Required | Description |
|---|---|---|
| <vaultId> | Yes | Vault ID |
| Flag | Description | Default |
|---|---|---|
| --key <key> | Encryption key (64-character hex string) | — |
Import vault key
lsvault vaults import-key abc123 --key 0123456789abcdef...Read, write, move, and delete documents in a vault
List documents in a vault, optionally filtered by directory
| Name | Required | Description |
|---|---|---|
| <vaultId> | Yes | Vault ID |
| Flag | Description | Default |
|---|---|---|
| --dir <path> | Filter by directory path | — |
List all documents in vault
lsvault docs list abc123List documents in a subdirectory
lsvault docs list abc123 --dir notes/meetingsList with table output
lsvault docs list abc123 --output tablePrint document content to stdout, or show metadata with --meta
| Name | Required | Description |
|---|---|---|
| <vaultId> | Yes | Vault ID |
| <path> | Yes | Document path (e.g., notes/todo.md) |
| Flag | Description | Default |
|---|---|---|
| --meta | Show metadata instead of content | — |
Print document content
lsvault docs get abc123 notes/todo.mdShow document metadata
lsvault docs get abc123 notes/todo.md --metaSave to local file
lsvault docs get abc123 notes/todo.md > local-copy.mdCreate or update a document by reading content from stdin
| Name | Required | Description |
|---|---|---|
| <vaultId> | Yes | Vault ID |
| <path> | Yes | Document path (must end with .md) |
Create document from echo
echo "# Hello" | lsvault docs put abc123 notes/hello.mdUpload local file
cat local-file.md | lsvault docs put abc123 docs/imported.mdPipe from pandoc conversion
pandoc input.docx -t markdown | lsvault docs put abc123 converted.mdPermanently delete a document from a vault
| Name | Required | Description |
|---|---|---|
| <vaultId> | Yes | Vault ID |
| <path> | Yes | Document path to delete |
Delete a document
lsvault docs delete abc123 notes/old.mdMove or rename a document within a vault
| Name | Required | Description |
|---|---|---|
| <vaultId> | Yes | Vault ID |
| <source> | Yes | Current document path |
| <dest> | Yes | New document path |
| Flag | Description | Default |
|---|---|---|
| --overwrite | Overwrite if destination already exists | — |
Rename a document
lsvault docs move abc123 notes/old.md notes/new.mdMove to different directory
lsvault docs move abc123 draft.md published/final.mdMove with overwrite
lsvault docs move abc123 temp.md final.md --overwriteFull-text search across documents using PostgreSQL websearch syntax
Search across all documents with full-text query
| Name | Required | Description |
|---|---|---|
| <query> | Yes | Search query (PostgreSQL websearch_to_tsquery syntax) |
| Flag | Description | Default |
|---|---|---|
| --vault <vaultId> | Filter to specific vault | — |
| --tags <tags> | Filter by comma-separated tags | — |
| --limit <n> | Maximum results to return | 20 |
Search across all vaults
lsvault search "hello world"Search in specific vault
lsvault search "meeting notes" --vault abc123Search with tag filter
lsvault search "project" --tags "work,important"Boolean search query
lsvault search "typescript & react"Search and export results
lsvault search "todo" --output json > results.jsonManage API keys for programmatic access
List all API keys for the current user
List API keys
lsvault keys listList with table output
lsvault keys list --output tableShow detailed information about an API key
| Name | Required | Description |
|---|---|---|
| <keyId> | Yes | API key ID |
Get API key details
lsvault keys get key_abc123Create a new API key with scopes and optional vault restriction
| Name | Required | Description |
|---|---|---|
| <name> | Yes | API key name |
| Flag | Description | Default |
|---|---|---|
| --scopes <scopes> | Comma-separated scopes (e.g., "documents:read,documents:write") | — |
| --vault <vaultId> | Restrict key to specific vault | — |
| --expires <date> | Expiration date (ISO 8601) | — |
Create read-only key
lsvault keys create "Read Only" --scopes "documents:read"Create vault-specific key
lsvault keys create "Mobile App" --scopes "documents:read,documents:write" --vault abc123Create key with expiration
lsvault keys create "Temp Key" --scopes "documents:read" --expires "2024-12-31"Update API key name or activation status
| Name | Required | Description |
|---|---|---|
| <keyId> | Yes | API key ID |
| Flag | Description | Default |
|---|---|---|
| --name <name> | New name for the API key | — |
| --deactivate | Deactivate the key | — |
| --activate | Reactivate the key | — |
Rename API key
lsvault keys update key_abc123 --name "Production Key"Deactivate API key
lsvault keys update key_abc123 --deactivatePermanently delete an API key
| Name | Required | Description |
|---|---|---|
| <keyId> | Yes | API key ID to delete |
Delete API key
lsvault keys delete key_abc123View current user information and storage usage
Show current user profile and subscription details
View user profile
lsvault user meShow storage usage and quota information
Check storage usage
lsvault user storageGet storage in JSON format
lsvault user storage --output jsonView subscription status and available plans
Show current subscription tier and expiration
Check subscription status
lsvault subscription statusList available subscription plans and features
View available plans
lsvault subscription plansGet plans in JSON format
lsvault subscription plans --output jsonManage teams, members, and team vaults
List all teams you are a member of
List teams
lsvault teams listShow detailed information about a team
| Name | Required | Description |
|---|---|---|
| <teamId> | Yes | Team ID |
Get team details
lsvault teams get team_abc123Create a new team
| Name | Required | Description |
|---|---|---|
| <name> | Yes | Team name |
| Flag | Description | Default |
|---|---|---|
| --description <desc> | Team description | — |
Create a team
lsvault teams create "Engineering Team"Create team with description
lsvault teams create "Marketing" --description "Marketing department"List all members of a team
| Name | Required | Description |
|---|---|---|
| <teamId> | Yes | Team ID |
List team members
lsvault teams members team_abc123Invite a user to join a team
| Name | Required | Description |
|---|---|---|
| <teamId> | Yes | Team ID |
| <email> | Yes | Email address of user to invite |
| Flag | Description | Default |
|---|---|---|
| --role <role> | Team role: member, admin, or owner | member |
Invite team member
lsvault teams invite team_abc123 user@example.comInvite as admin
lsvault teams invite team_abc123 admin@example.com --role adminList pending invitations for a team
| Name | Required | Description |
|---|---|---|
| <teamId> | Yes | Team ID |
List pending invitations
lsvault teams invitations team_abc123Revoke a pending team invitation
| Name | Required | Description |
|---|---|---|
| <teamId> | Yes | Team ID |
| <invitationId> | Yes | Invitation ID |
Revoke invitation
lsvault teams revoke-invitation team_abc123 inv_xyz789Update a team member's role
| Name | Required | Description |
|---|---|---|
| <teamId> | Yes | Team ID |
| <userId> | Yes | User ID |
| <role> | Yes | New role: member, admin, or owner |
Promote to admin
lsvault teams update-role team_abc123 user_xyz789 adminRemove a member from a team
| Name | Required | Description |
|---|---|---|
| <teamId> | Yes | Team ID |
| <userId> | Yes | User ID to remove |
Remove team member
lsvault teams remove-member team_abc123 user_xyz789Leave a team (owners cannot leave)
| Name | Required | Description |
|---|---|---|
| <teamId> | Yes | Team ID to leave |
Leave a team
lsvault teams leave team_abc123List all vaults owned by a team
| Name | Required | Description |
|---|---|---|
| <teamId> | Yes | Team ID |
List team vaults
lsvault teams vaults team_abc123Create a new vault owned by the team
| Name | Required | Description |
|---|---|---|
| <teamId> | Yes | Team ID |
| <name> | Yes | Vault name |
Create team vault
lsvault teams create-vault team_abc123 "Team Documents"Manage vault hooks for automated document processing
List all hooks configured for a vault
| Name | Required | Description |
|---|---|---|
| <vaultId> | Yes | Vault ID |
List vault hooks
lsvault hooks list abc123Create a new hook for automated processing
| Name | Required | Description |
|---|---|---|
| <vaultId> | Yes | Vault ID |
| <name> | Yes | Hook name |
| Flag | Description | Default |
|---|---|---|
| --event <event> | Trigger event: create, update, or delete | — |
| --action <action> | Action type: auto-tag, template, etc. | — |
| --config <json> | Hook configuration as JSON string | — |
Create auto-tag hook
lsvault hooks create abc123 "Auto Tag" --event create --action auto-tag --config '{"tags":["new"]}'Update hook configuration or activation status
| Name | Required | Description |
|---|---|---|
| <vaultId> | Yes | Vault ID |
| <hookId> | Yes | Hook ID |
| Flag | Description | Default |
|---|---|---|
| --deactivate | Deactivate the hook | — |
Deactivate hook
lsvault hooks update abc123 hook_xyz789 --deactivatePermanently delete a hook
| Name | Required | Description |
|---|---|---|
| <vaultId> | Yes | Vault ID |
| <hookId> | Yes | Hook ID to delete |
Delete hook
lsvault hooks delete abc123 hook_xyz789View execution history for a hook
| Name | Required | Description |
|---|---|---|
| <vaultId> | Yes | Vault ID |
| <hookId> | Yes | Hook ID |
View hook execution history
lsvault hooks executions abc123 hook_xyz789Manage webhooks for external integrations
List all webhooks configured for a vault
| Name | Required | Description |
|---|---|---|
| <vaultId> | Yes | Vault ID |
List vault webhooks
lsvault webhooks list abc123Create a new webhook endpoint
| Name | Required | Description |
|---|---|---|
| <vaultId> | Yes | Vault ID |
| <url> | Yes | Webhook URL |
| Flag | Description | Default |
|---|---|---|
| --events <events> | Comma-separated event types: create, update, delete | — |
Create webhook for all events
lsvault webhooks create abc123 https://api.example.com/webhook --events "create,update,delete"Create webhook for document creation only
lsvault webhooks create abc123 https://api.example.com/webhook --events "create"Update webhook configuration or activation status
| Name | Required | Description |
|---|---|---|
| <vaultId> | Yes | Vault ID |
| <webhookId> | Yes | Webhook ID |
| Flag | Description | Default |
|---|---|---|
| --deactivate | Deactivate the webhook | — |
Deactivate webhook
lsvault webhooks update abc123 webhook_xyz789 --deactivatePermanently delete a webhook
| Name | Required | Description |
|---|---|---|
| <vaultId> | Yes | Vault ID |
| <webhookId> | Yes | Webhook ID to delete |
Delete webhook
lsvault webhooks delete abc123 webhook_xyz789View delivery history and status for a webhook
| Name | Required | Description |
|---|---|---|
| <vaultId> | Yes | Vault ID |
| <webhookId> | Yes | Webhook ID |
View webhook delivery history
lsvault webhooks deliveries abc123 webhook_xyz789Publish documents to public URLs with SEO metadata
List all published documents in a vault
| Name | Required | Description |
|---|---|---|
| <vaultId> | Yes | Vault ID |
List published documents
lsvault publish list abc123Publish a document to a public URL
| Name | Required | Description |
|---|---|---|
| <vaultId> | Yes | Vault ID |
| <path> | Yes | Document path |
| Flag | Description | Default |
|---|---|---|
| --slug <slug> | Custom URL slug | — |
| --title <title> | SEO title override | — |
| --description <desc> | SEO meta description | — |
| --og-image <url> | Open Graph image URL | — |
Publish document
lsvault publish create abc123 blog/first-post.mdPublish with custom slug
lsvault publish create abc123 blog/post.md --slug "my-first-post"Publish with SEO metadata
lsvault publish create abc123 blog/post.md --title "My Post" --description "A great post"Update published document metadata
| Name | Required | Description |
|---|---|---|
| <vaultId> | Yes | Vault ID |
| <path> | Yes | Document path |
| Flag | Description | Default |
|---|---|---|
| --slug <slug> | New URL slug | — |
Update publication slug
lsvault publish update abc123 blog/post.md --slug "new-slug"Unpublish a document
| Name | Required | Description |
|---|---|---|
| <vaultId> | Yes | Vault ID |
| <path> | Yes | Document path |
Unpublish document
lsvault publish delete abc123 blog/post.mdManage external service connectors (Google Drive, etc.)
List all configured connectors
| Flag | Description | Default |
|---|---|---|
| --vault <vaultId> | Filter to specific vault | — |
List all connectors
lsvault connectors listList connectors for vault
lsvault connectors list --vault abc123Show detailed information about a connector
| Name | Required | Description |
|---|---|---|
| <connectorId> | Yes | Connector ID |
Get connector details
lsvault connectors get conn_abc123Create a new external connector
| Flag | Description | Default |
|---|---|---|
| --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 bidirectional | bidirectional |
Create Google Drive connector
lsvault connectors create --provider google-drive --name "My Drive" --vault abc123Test connector connection and permissions
| Name | Required | Description |
|---|---|---|
| <connectorId> | Yes | Connector ID |
Test connector
lsvault connectors test conn_abc123Trigger manual synchronization
| Name | Required | Description |
|---|---|---|
| <connectorId> | Yes | Connector ID |
Manually sync connector
lsvault connectors sync conn_abc123View sync logs and history
| Name | Required | Description |
|---|---|---|
| <connectorId> | Yes | Connector ID |
View sync logs
lsvault connectors logs conn_abc123Delete a connector configuration
| Name | Required | Description |
|---|---|---|
| <connectorId> | Yes | Connector ID to delete |
Delete connector
lsvault connectors delete conn_abc123System administration commands (admin role required)
Show system-wide statistics and metrics
View system stats
lsvault admin statsView timeseries metrics for signups, documents, storage
| Flag | Description | Default |
|---|---|---|
| --metric <metric> | Metric type: signups, documents, or storage | — |
| --period <period> | Time period: day, week, month, year | week |
View signups over past week
lsvault admin timeseries --metric signups --period weekView document creation trends
lsvault admin timeseries --metric documents --period monthList and search system users
| Flag | Description | Default |
|---|---|---|
| --search <query> | Search by email or name | — |
| --tier <tier> | Filter by subscription tier | — |
List all users
lsvault admin usersSearch for user
lsvault admin users --search "user@example.com"List pro users
lsvault admin users --tier proShow detailed user information
| Name | Required | Description |
|---|---|---|
| <userId> | Yes | User ID |
View user details
lsvault admin user user_abc123Update user role or subscription tier
| Name | Required | Description |
|---|---|---|
| <userId> | Yes | User ID |
| Flag | Description | Default |
|---|---|---|
| --role <role> | User role: user or admin | — |
| --tier <tier> | Subscription tier: free, pro, or business | — |
Promote to admin
lsvault admin update-user user_abc123 --role adminUpdate subscription tier
lsvault admin update-user user_abc123 --tier proView recent system activity
| Flag | Description | Default |
|---|---|---|
| --limit <n> | Maximum results | 50 |
View recent activity
lsvault admin activityView last 100 events
lsvault admin activity --limit 100View subscription statistics across all users
View subscription breakdown
lsvault admin subscriptionsCheck system health (database, Redis, workers)
Check system health
lsvault admin healthView audit logs for security and compliance
List audit log entries
| Flag | Description | Default |
|---|---|---|
| --type <type> | Event type filter | — |
| --output <format> | Output format: text, json, or table | — |
List recent audit logs
lsvault audit listFilter by event type
lsvault audit list --type loginExport audit logs to JSON
lsvault audit list --output json > audit-logs.jsonLocal file synchronization with vault documents
Initialize a local sync folder for a vault
| Name | Required | Description |
|---|---|---|
| <vaultId> | Yes | Vault ID to sync |
| <localPath> | Yes | Local directory path |
| Flag | Description | Default |
|---|---|---|
| --mode <mode> | Sync mode: push, pull, or bidirectional | bidirectional |
| --on-conflict <strategy> | Conflict resolution: newer, local, or remote | newer |
Initialize bidirectional sync
lsvault sync init abc123 ~/Documents/vaultInitialize pull-only sync
lsvault sync init abc123 ~/vault --mode pullList all configured sync folders
List sync configurations
lsvault sync listPull changes from vault to local folder
| Name | Required | Description |
|---|---|---|
| <syncId> | Yes | Sync configuration ID |
| Flag | Description | Default |
|---|---|---|
| --dry-run | Preview changes without applying | — |
Pull changes
lsvault sync pull sync_abc123Preview pull changes
lsvault sync pull sync_abc123 --dry-runPush local changes to vault
| Name | Required | Description |
|---|---|---|
| <syncId> | Yes | Sync configuration ID |
| Flag | Description | Default |
|---|---|---|
| --dry-run | Preview changes without applying | — |
Push changes
lsvault sync push sync_abc123Preview push changes
lsvault sync push sync_abc123 --dry-runShow sync status and pending changes
| Name | Required | Description |
|---|---|---|
| <syncId> | Yes | Sync configuration ID |
Check sync status
lsvault sync status sync_abc123Start watching for file changes and auto-sync
| Name | Required | Description |
|---|---|---|
| <syncId> | Yes | Sync configuration ID |
Start file watcher
lsvault sync watch sync_abc123Manually resolve a sync conflict
| Name | Required | Description |
|---|---|---|
| <syncId> | Yes | Sync configuration ID |
| <path> | Yes | Conflicted file path |
| Flag | Description | Default |
|---|---|---|
| --use <source> | Use local or remote version | — |
Resolve with local version
lsvault sync resolve sync_abc123 notes/conflict.md --use localResolve with remote version
lsvault sync resolve sync_abc123 notes/conflict.md --use remoteStart the sync daemon for automatic background sync
Start sync daemon
lsvault sync daemon startStop the sync daemon
Stop sync daemon
lsvault sync daemon stopCheck if sync daemon is running
Check daemon status
lsvault sync daemon statusDelete a sync configuration
| Name | Required | Description |
|---|---|---|
| <syncId> | Yes | Sync configuration ID to delete |
Delete sync configuration
lsvault sync delete sync_abc123#!/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"
#!/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
#!/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 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 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
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
#!/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
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.
# 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
# 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})'
#!/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
#!/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
#!/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
# 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
#!/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
#!/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
The CLI supports three output formats optimized for different use cases.
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:
--no-color to disable)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:
jq for filtering/transformationBest 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'
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:
column or csvlookThe CLI automatically selects the best format based on context:
text format with colorsjson format (for better machine parsing)--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
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
# 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
The sync daemon enables automatic background synchronization of local folders with vaults.
# Start daemon in background
lsvault sync daemon start
# Check daemon status
lsvault sync daemon status
# Stop daemon
lsvault sync daemon stop
Daemon logs are written to:
~/.lsvault/daemon.log~/Library/Logs/lsvault-daemon.log%APPDATA%\lsvault\daemon.log# Follow daemon logs
tail -f ~/.lsvault/daemon.log
# View recent errors
grep ERROR ~/.lsvault/daemon.log | tail -20
The daemon watches all configured sync folders and:
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
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
#!/bin/bash
# Monitor daemon activity
watch -n 5 'lsvault sync daemon status && echo "" && tail -10 ~/.lsvault/daemon.log'
# 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
# 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