@andrzejchm/notion-cli 0.11.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,13 @@
1
1
  ---
2
2
  name: using-notion-cli
3
- description: Use when reading or writing Notion pages, searching a Notion workspace, querying or creating Notion databases, appending or editing page content, creating pages, updating page properties, moving pages, adding comments, or archiving pages — via the `notion` CLI tool in the terminal.
3
+ description: Use when reading or writing Notion pages, searching a Notion workspace, querying or creating Notion databases, updating database schemas, batch-updating database rows, appending or editing page content, creating pages, updating page properties, moving pages, attaching files, adding comments, deleting blocks, or archiving pages and databases — via the `notion` CLI tool in the terminal.
4
4
  ---
5
5
 
6
- ## Overview - skill version 0.11.0
6
+ ## Overview - skill version 0.13.0
7
7
 
8
- `notion` is a CLI tool for reading and writing Notion content from the terminal or agent workflows. Use it any time you need to interact with Notion: read pages, search, query databases, append or edit content, create pages, update properties, move pages, post comments, or archive pages.
8
+ `notion` is a CLI tool for reading and writing Notion content from the terminal or agent workflows. Use it any time you need to interact with Notion: read pages, search, query databases, create and update database schemas, batch-update rows, append or edit content, create pages, update properties, move pages, post comments, attach files, delete blocks, or archive pages and databases.
9
9
 
10
- > **Version check:** Run `notion --version`. If your installed version is older than 0.11.0, update with `npm install -g @andrzejchm/notion-cli` and refresh this skill with `notion skill`.
10
+ > **Version check:** Run `notion --version`. If your installed version is older than 0.13.0, update with `npm install -g @andrzejchm/notion-cli` and refresh this skill with `notion skill`.
11
11
 
12
12
  ## Setup
13
13
 
@@ -34,7 +34,11 @@ Pages must be shared with your integration: open page → `⋯` → **Add connec
34
34
  - `notion append`, `notion append --after`, `notion create-page` (page parent): also need **Insert content**
35
35
  - `notion create-page --parent <db>`: also need **Insert content** + database must be shared with integration
36
36
  - `notion edit-page`: also need **Update content** + **Insert content**
37
+ - `notion attach`: also need **Insert content**
37
38
  - `notion comment`: also need **Read comments** + **Insert comments**
39
+ - `notion db update`: also need **Update content**
40
+ - `notion db update-rows`: also need **Read content** + **Update content**
41
+ - `notion delete-block`: also need **Update content**
38
42
 
39
43
  ---
40
44
 
@@ -115,6 +119,52 @@ notion db query <id|url> --columns "Title,Status" # limit columns
115
119
  notion db query <id|url> --json | jq '.[] | .properties'
116
120
 
117
121
  notion db create --parent <page-id|url> --title "My Database" # create a new database
122
+ notion db create --parent <page-id|url> --title "Tasks" \
123
+ --prop "Status:select:To Do,In Progress,Done" \
124
+ --prop "Priority:select:High,Medium,Low" \
125
+ --prop "Due:date:" \
126
+ --prop "Notes:rich_text:" # with property definitions
127
+ ```
128
+
129
+ #### Creating Databases with Properties
130
+
131
+ Use `--prop "Name:type[:options]"` (repeatable) to define columns when creating a database.
132
+
133
+ ```bash
134
+ # Database with select, date, and text properties
135
+ notion db create --parent "$PAGE_ID" --title "Project Tracker" \
136
+ --prop "Status:select:To Do,In Progress,Done" \
137
+ --prop "Priority:select:High,Medium,Low" \
138
+ --prop "Due:date:" \
139
+ --prop "Notes:rich_text:"
140
+
141
+ # Minimal — title column is added automatically if not specified
142
+ notion db create --parent "$PAGE_ID" --title "Simple List"
143
+ ```
144
+
145
+ Supported property types: `title`, `rich_text`, `number`, `select`, `multi_select`, `status`, `date`, `checkbox`, `url`, `email`, `phone_number`, `people`, `files`, `created_time`, `last_edited_time`.
146
+
147
+ **Important:** After creating a database, use `notion search "DB Title" --type database` to find the database ID for subsequent operations. The ID returned by `db create` is a URL-based ID that may differ from the API-accessible database ID.
148
+
149
+ #### Updating Database Schema
150
+
151
+ ```bash
152
+ notion db update <id|url> --add-prop "Priority:number" # add a number property
153
+ notion db update <id|url> --add-prop "Severity:select:Low,Medium,High" # add select with options
154
+ notion db update <id|url> --remove-prop "Old Column" # remove a property
155
+ notion db update <id|url> --rename-prop "Status:Project Status" # rename a property
156
+ notion db update <id|url> --set-options "Priority:P1,P2,P3" # replace select options
157
+ notion db update <id|url> --title "New Database Title" # update title
158
+ notion db update <id|url> --add-prop "URL:url" --remove-prop "Notes" # multiple ops in one call
159
+ ```
160
+
161
+ #### Batch Updating Database Rows
162
+
163
+ ```bash
164
+ notion db update-rows <id|url> --filter "Status=Open" --prop "Priority=P3" # update filtered rows
165
+ notion db update-rows <id|url> --prop "Status=Closed" # update ALL rows
166
+ notion db update-rows <id|url> --filter "Status=Done" --prop "Priority=Low" --dry-run # preview
167
+ notion db update-rows <id|url> --filter "Category=Bug" --prop "Status=Done" --json # JSON output
118
168
  ```
119
169
 
120
170
  ### Write Operations
@@ -122,19 +172,26 @@ notion db create --parent <page-id|url> --title "My Database" # create a new da
122
172
  ```bash
123
173
  notion append <id|url> -m "## Heading\nParagraph text" # append markdown blocks to a page
124
174
  notion append <id|url> -m "$(cat notes.md)" # append file contents
175
+ notion append <id|url> --file screenshot.png # attach a local file
176
+ notion append <id|url> -m "See results:" --file chart.png # markdown + file attachment
177
+ notion append <id|url> --file a.png --file b.pdf # multiple files (repeatable)
125
178
 
126
179
  notion create-page --parent <page-id|url> --title "Title" # child page under a page
127
180
  notion create-page --parent <page-id|url> --title "Title" -m "# Hello" # with markdown body
128
181
  echo "# Content" | notion create-page --parent <page-id|url> --title "Title" # from stdin
182
+ notion create-page --parent <page-id|url> --title "Report" --file report.pdf # with file attachment
183
+ notion create-page --parent <page-id|url> --title "Notes" -m "# Agenda" --file slides.pdf --file notes.txt
129
184
 
130
185
  # Create entry in a database (auto-detected from parent ID)
131
186
  notion create-page --parent <db-id|url> --title "New Task"
132
187
  notion create-page --parent <db-id|url> --title "Task" --prop "Status=To Do" --prop "Priority=High"
133
188
  notion create-page --parent <db-id|url> --title "Task" --prop "Due=2026-04-01" -m "# Details"
134
189
 
135
- # Icon and cover
190
+ # Icon and cover (emoji, URL, or local file path)
136
191
  notion create-page --parent <id|url> --title "Page" --icon "🚀"
192
+ notion create-page --parent <id|url> --title "Page" --icon ./logo.png # upload local file as icon
137
193
  notion create-page --parent <id|url> --title "Page" --cover "https://example.com/img.jpg"
194
+ notion create-page --parent <id|url> --title "Page" --cover ./banner.jpg # upload local file as cover
138
195
 
139
196
  URL=$(notion create-page --parent <id|url> --title "Summary" -m "...") # capture URL
140
197
 
@@ -142,12 +199,32 @@ notion comment <id|url> -m "Reviewed and approved." # add comme
142
199
  notion comment <id|url> -m "Reply" --reply-to <discussion-id> # reply to a discussion thread
143
200
  notion comment <id|url> -m "Note" --block <block-id> # comment on a specific block
144
201
 
145
- notion archive <id|url> # move page to trash
202
+ notion archive <id|url> # move page or database to trash
203
+ notion delete-block <id|url> # delete a block (inline db, paragraph, etc.)
146
204
 
147
205
  notion move <ids|urls...> --to <id|url> # move pages to a new parent page
148
206
  notion move <ids|urls...> --to-db <id|url> # move pages to a database parent
149
207
  ```
150
208
 
209
+ #### File Attachments
210
+
211
+ Upload local files to Notion and attach them as blocks (image, file, PDF, audio, video). Block type is auto-detected from file extension. Files ≤20 MB upload in one request; larger files are chunked automatically.
212
+
213
+ ```bash
214
+ notion attach <id|url> screenshot.png # attach a single file
215
+ notion attach <id|url> report.pdf data.csv image.png # attach multiple files
216
+ notion attach <id|url> diagram.png --caption "Architecture diagram" # with caption
217
+ notion attach <id|url> file.svg --type image # override auto-detected type
218
+ ```
219
+
220
+ | Flag | Description |
221
+ |------|-------------|
222
+ | `--caption <text>` | Caption for the file block(s) |
223
+ | `--type <type>` | Override block type (`image\|file\|pdf\|audio\|video`) |
224
+ | `--json` | Output JSON response |
225
+
226
+ The `--file <path>` flag (repeatable) is also available on `notion append` and `notion create-page` for inline file attachment alongside markdown content.
227
+
151
228
  #### Updating Page Properties
152
229
 
153
230
  ```bash
@@ -160,7 +237,16 @@ notion update <id|url> --prop "Done=true" # checkbox (tru
160
237
  notion update <id|url> --prop "Status=" # clear a property (empty value)
161
238
  ```
162
239
 
163
- Supported types: title, rich_text, select, status, multi_select, number, checkbox, url, email, phone_number, date.
240
+ Supported types: title, rich_text, select, status, multi_select, number, checkbox, url, email, phone_number, date, files.
241
+
242
+ ```bash
243
+ # Files property — local file paths or URLs (comma-separated for multiple)
244
+ notion update <id|url> --prop "Attachments=./report.pdf" # upload local file
245
+ notion update <id|url> --prop "Attachments=https://example.com/file.pdf" # external URL
246
+ notion update <id|url> --prop "Attachments=./a.pdf,./b.png" # multiple files
247
+ ```
248
+
249
+ > **Note:** Setting a `files` property **replaces** all existing files (Notion API behavior). To keep existing files, re-include them in the value.
164
250
 
165
251
  #### Surgical Editing
166
252
 
@@ -243,9 +329,14 @@ notion edit-page "$PAGE_ID" \
243
329
  --find "Status: In Progress" --replace "Status: Done" \
244
330
  --find "Blocked: yes" --replace "Blocked: none"
245
331
 
246
- # Create a database entry with properties
247
- DB_ID=$(notion search "Tasks" --type database | jq -r '.[0].id')
248
- notion db schema "$DB_ID" # check property names and valid values first
332
+ # Create a database with typed columns, then add entries
333
+ notion db create --parent "$PAGE_ID" --title "Sprint Tasks" \
334
+ --prop "Status:select:To Do,In Progress,Done" \
335
+ --prop "Priority:select:High,Medium,Low" \
336
+ --prop "Due:date:" --prop "Notes:rich_text:"
337
+ # Use search to get the API-accessible database ID (may differ from db create output)
338
+ DB_ID=$(notion search "Sprint Tasks" --type database | jq -r '.[0].id')
339
+ notion db schema "$DB_ID" # verify property names and valid values
249
340
  notion create-page --parent "$DB_ID" --title "Fix login bug" \
250
341
  --prop "Status=To Do" --prop "Priority=High" --prop "Due=2026-04-15"
251
342
 
@@ -259,6 +350,34 @@ notion move "$PAGE_ID" --to "$ARCHIVE_ID"
259
350
 
260
351
  # Move multiple pages into a database
261
352
  notion move page1-id page2-id --to-db "$DB_ID"
353
+
354
+ # Attach a generated screenshot to a documentation page
355
+ notion attach "$PAGE_ID" ./screenshot.png --caption "Current UI state"
356
+
357
+ # Create a report page with attached artifacts
358
+ notion create-page --parent "$PAGE_ID" --title "Build Report $(date +%Y-%m-%d)" \
359
+ -m "# Build Results\nAll tests passed." --file ./test-results.pdf --file ./coverage.png
360
+
361
+ # Append analysis with supporting data file
362
+ notion append "$PAGE_ID" -m "## Data Analysis\nSee attached CSV:" --file ./export.csv
363
+
364
+ # Upload a local file as icon for a page
365
+ notion update "$PAGE_ID" --icon ./logo.png
366
+
367
+ # Modify a database schema — add a column after creation
368
+ notion db update "$DB_ID" --add-prop "Sprint:select:S1,S2,S3"
369
+
370
+ # Clean up stale select options
371
+ notion db update "$DB_ID" --set-options "Status:To Do,In Progress,Done"
372
+
373
+ # Batch close all "In Progress" tasks
374
+ notion db update-rows "$DB_ID" --filter "Status=In Progress" --prop "Status=Done"
375
+
376
+ # Preview a batch update before applying
377
+ notion db update-rows "$DB_ID" --filter "Priority=Low" --prop "Status=Archived" --dry-run
378
+
379
+ # Delete an inline database from a page
380
+ notion delete-block "$BLOCK_ID"
262
381
  ```
263
382
 
264
383
  ---
@@ -284,3 +403,9 @@ notion move page1-id page2-id --to-db "$DB_ID"
284
403
  **`--find` text not found** — Run `notion read <id>` to see the exact page content. The `--find` value must match text on the page exactly.
285
404
 
286
405
  **`--after` selector not found** — Run `notion read <id>` to see the exact page content. The selector must match real text: `"start...end"` with ~10 chars from the beginning and end of the target range.
406
+
407
+ **`notion db update` fails with "Property not found"** — Run `notion db schema <id>` to see exact property names. For `--rename-prop` and `--set-options`, the property must exist.
408
+
409
+ **`notion db update-rows` updates 0 rows** — Check that your `--filter` matches rows: run `notion db query <id> --filter "..."` first.
410
+
411
+ **`notion archive` fails for a database** — Try using the data source ID (from `notion db schema <id> --json`) instead of the database page ID.
package/README.md CHANGED
@@ -96,21 +96,48 @@ notion ls
96
96
  | `notion open <id\|url>` | Open a page in your browser |
97
97
  | `notion read <id\|url>` | Read a page as markdown |
98
98
  | `notion db create --parent <id\|url> --title <title>` | Create a new database with property definitions |
99
+ | `notion db update [options] <id\|url>` | Update database schema (add/remove/rename properties, manage options) |
99
100
  | `notion db schema <id\|url>` | Show database property schema and valid values |
100
101
  | `notion db query <id\|url>` | Query database entries with filtering and sorting |
102
+ | `notion db update-rows [options] <id\|url>` | Batch update properties on filtered database rows |
101
103
  | `notion users` | List workspace members |
102
104
  | `notion comments <id\|url>` | Read page comments |
103
105
  | `notion comment [id\|url] -m <text>` | Add a comment to a page, block, or thread |
104
106
  | `notion append <id\|url> -m <markdown>` | Append markdown blocks to a page |
107
+ | `notion attach <id\|url> <file> [files...]` | Upload and attach file(s) to a page |
105
108
  | `notion edit-page <id\|url> --find <old> --replace <new>` | Search-and-replace text on a page |
106
109
  | `notion edit-page <id\|url> -m <markdown>` | Replace entire page content |
107
110
  | `notion create-page --parent <id\|url> --title <title>` | Create a new page, prints URL |
108
111
  | `notion update <id\|url> --prop "Name=Value"` | Update properties on a page |
109
- | `notion archive <id\|url>` | Archive (trash) a page |
112
+ | `notion archive <id\|url>` | Archive (trash) a page or database |
113
+ | `notion delete-block <id\|url>` | Delete a block by ID or URL |
110
114
  | `notion move <ids\|urls...> --to <id\|url>` | Move pages to a new parent page |
111
115
  | `notion move <ids\|urls...> --to-db <id\|url>` | Move pages to a database parent |
112
116
  | `notion completion bash\|zsh\|fish` | Install shell tab completion |
113
117
 
118
+ ### `notion attach` flags
119
+
120
+ | Flag | Example | Description |
121
+ |------|---------|-------------|
122
+ | `--caption <text>` | `--caption "My screenshot"` | Caption for the file block(s) |
123
+ | `--type <type>` | `--type image` | Override auto-detected block type (`image\|file\|pdf\|audio\|video`) |
124
+ | `--json` | `--json` | Output JSON response |
125
+
126
+ ### `notion append` / `notion create-page` — `--file` flag
127
+
128
+ Both commands accept a repeatable `--file <path>` option to attach local files after the markdown content is written:
129
+
130
+ ```bash
131
+ # Append markdown and attach a file
132
+ notion append "$PAGE_ID" -m "See attached screenshot:" --file screenshot.png
133
+
134
+ # Create a page with an attached PDF
135
+ notion create-page --parent "$PAGE_ID" --title "Report" --file report.pdf
136
+
137
+ # Attach multiple files
138
+ notion append "$PAGE_ID" --file image.png --file data.csv
139
+ ```
140
+
114
141
  ### `notion search` / `notion ls` flags
115
142
 
116
143
  | Flag | Example | Description |
@@ -140,6 +167,28 @@ Property syntax: `Name:type[:options]`. Supported types: `title`, `rich_text`, `
140
167
  | `--columns` | `--columns "Title,Status"` | Only show specific columns |
141
168
  | `--json` | `--json` | Force JSON output |
142
169
 
170
+ ### `notion db update` flags
171
+
172
+ | Flag | Example | Description |
173
+ |------|---------|-------------|
174
+ | `--add-prop <definition>` | `--add-prop "Priority:number"` | Add a new property (repeatable) |
175
+ | `--remove-prop <name>` | `--remove-prop "Old Column"` | Remove a property (repeatable) |
176
+ | `--rename-prop <old:new>` | `--rename-prop "Status:Project Status"` | Rename a property (repeatable) |
177
+ | `--set-options <prop:opts>` | `--set-options "Priority:High,Medium,Low"` | Replace all select/multi\_select options |
178
+ | `--title <title>` | `--title "New DB Name"` | Update database title |
179
+ | `--json` | `--json` | Output full JSON response |
180
+
181
+ Property syntax for `--add-prop`: same as `notion db create --prop` — `Name:type[:options]`.
182
+
183
+ ### `notion db update-rows` flags
184
+
185
+ | Flag | Example | Description |
186
+ |------|---------|-------------|
187
+ | `--filter <expr>` | `--filter "Status=Done"` | Filter rows to update (repeatable, same syntax as `db query`) |
188
+ | `--prop <property=value>` | `--prop "Priority=High"` | Property to update (repeatable, required) |
189
+ | `--dry-run` | `--dry-run` | Show matching rows without making changes |
190
+ | `--json` | `--json` | Output JSON array of results |
191
+
143
192
  ---
144
193
 
145
194
  ## Output Modes
@@ -220,6 +269,7 @@ Write commands require additional capabilities — enable in your integration se
220
269
  | Command | Required capabilities |
221
270
  |---------|----------------------|
222
271
  | `notion append` | Read content, Insert content |
272
+ | `notion attach` | Read content, Insert content |
223
273
  | `notion create-page` | Read content, Insert content |
224
274
  | `notion update` | Read content, Update content |
225
275
  | `notion comment` | Read content, Insert content, Read comments, Insert comments |