> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nylio.app/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI commands

> Full reference for every nylio CLI command, flag, and usage pattern.

## Global flags

| Flag                   | Description                                       |
| ---------------------- | ------------------------------------------------- |
| `--help`               | Show help for the current command                 |
| `--json`               | Switch output from compact plain text to raw JSON |
| `--api-base-url <url>` | Override the API origin for this invocation       |

You can also run `nylio help <command>` to view help for any command:

```bash theme={null}
nylio help documents edit
```

## Auth

```bash theme={null}
nylio login
nylio login --print-url
nylio auth status
nylio whoami
nylio logout
```

## Workspaces

```bash theme={null}
nylio workspaces list
```

## Documents

Create a personal document. If you omit `--title`, the document defaults to "Untitled document". You can pass the initial body as a positional argument, with `--markdown`, or piped through `--stdin`:

```bash theme={null}
nylio documents create --title "Draft"
nylio documents create --title "Draft" --markdown "# Draft"
nylio documents create --title "Draft" "# Heading\n\nBody text"
cat body.md | nylio documents create --title "Draft" --stdin
```

List documents:

```bash theme={null}
nylio documents list --limit 10
nylio documents list --workspace-scope personal
nylio documents list --workspace-slug my-workspace --limit 25
```

Fetch a document by id or Nylio URL:

```bash theme={null}
nylio documents get doc_123
nylio documents get https://app.nylio.app/app/doc/doc_123
```

Apply one exact string replacement to a personal document. You can read either `oldString` or `newString` from stdin, but not both in the same call:

```bash theme={null}
nylio documents edit doc_123 "Old heading" "New heading"
nylio documents edit --document doc_123 --old-string "Old heading" --new-string "New heading"
printf 'New heading' | nylio documents edit --document doc_123 --old-string "Old heading" --new-string-stdin
printf 'Old heading' | nylio documents edit --document doc_123 --old-string-stdin --new-string "New heading"
```

Preview a write without sending it:

```bash theme={null}
nylio documents edit --document doc_123 --old-string "Old heading" --new-string "New heading" --dry-run
```

Replace the full enhanced markdown body:

```bash theme={null}
nylio documents replace doc_123 "# New title"
nylio documents replace --document doc_123 --stdin < body.md
cat body.md | nylio documents replace --document doc_123 --stdin
```

Preview a full replace without sending it:

```bash theme={null}
nylio documents replace --document doc_123 --stdin --dry-run < body.md
```

Export one document:

```bash theme={null}
nylio documents export doc_123 --format markdown
nylio documents export doc_123 --format pdf --output ./draft.pdf
nylio documents export doc_123 --format docx
```

## Search

```bash theme={null}
nylio search "project plan"
nylio search "quarterly review" --workspace-slug my-workspace --limit 5
```

## Write-safety rules

* `documents edit` performs one replacement per call.
* `documents edit` supports at most one stdin-backed field (`--old-string-stdin` or `--new-string-stdin`) per invocation.
* Write commands are scoped to personal documents owned by the authenticated user.
* `documents replace` expects [Nylio enhanced markdown](/format/nylio-markdown), not plain rich-text HTML.
