Batch operations for working with multiple Notion resources at once. All batch commands run requests in parallel and accept Notion URLs, database names, or raw IDs.
notion-cli batch retrieve [IDS]— Fetch multiple pages, blocks, or databasesnotion-cli batch delete [IDS]— Delete multiple blocks
Fetch multiple pages, blocks, or data sources in a single command. Each ID is resolved through the standard pipeline (URL extraction, cache lookup, API search) before calling the Notion API. All requests run in parallel.
Alias: batch:r
notion-cli batch retrieve [IDS] [FLAGS]
| Argument | Required | Description |
|---|---|---|
IDS |
No | Comma-separated list of IDs, URLs, or names |
If no positional argument is given, the command checks --ids flag, then stdin.
| Flag | Short | Default | Description |
|---|---|---|---|
--ids |
Comma-separated list of IDs to retrieve | ||
--type |
page |
Resource type: page, block, or database |
|
--json |
-j |
Output as JSON with metadata (total, succeeded, failed) | |
--compact-json |
-c |
Output as single-line JSON (ideal for piping) | |
--raw |
-r |
Output full API response for each resource | |
--markdown |
-m |
Output as GitHub-flavored markdown table | |
--pretty |
-P |
Output as table with borders | |
--verbose |
-v |
Show resolver and cache debug info on stderr | |
--minimal |
Strip metadata fields (~40% smaller responses) | ||
--no-cache |
Bypass cache, force fresh API calls | ||
--retry |
Auto-retry on rate limit (respects Retry-After) | ||
--timeout |
30000 |
Request timeout in milliseconds |
There are three ways to pass IDs to batch retrieve:
1. Positional argument — comma-separated on the command line:
notion-cli batch retrieve "ID1,ID2,ID3"2. --ids flag — same format, explicit flag:
notion-cli batch retrieve --ids "ID1,ID2,ID3"3. stdin — one ID per line, piped from a file or another command:
cat page_ids.txt | notion-cli batch retrieve --jsonAll three methods accept any input format the resolver understands: raw hex IDs, dashed UUIDs, full Notion URLs (including title-slug URLs), and cached database names.
Every ID passes through resolveNotionId() before the API call. This means batch retrieve accepts:
- Raw IDs:
2fc3826d337780419021c0097da10f33 - Dashed UUIDs:
2fc3826d-3377-8041-9021-c0097da10f33 - Title-slug URLs:
https://notion.so/My-Page-2fc3826d337780419021c0097da10f33 - URLs with query params:
https://notion.so/Page-abc123?source=copy_link - Database names (from cache):
"Tasks Database"
You can mix formats in the same command:
notion-cli batch retrieve --ids "https://notion.so/Page-abc123,2fc3826d337780419021c0097da10f33"Table (default) — shows id, status, type, and title:
┌──────────────────────────────────────┬─────────┬──────┬─────────────────────────┐
│ id │ status │ type │ title │
├──────────────────────────────────────┼─────────┼──────┼─────────────────────────┤
│ 2fc3826d337780419021c0097da10f33 │ success │ page │ agentic engineering 101 │
├──────────────────────────────────────┼─────────┼──────┼─────────────────────────┤
│ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa │ failed │ page │ Page not found │
└──────────────────────────────────────┴─────────┴──────┴─────────────────────────┘
Total: 2 | Succeeded: 1 | Failed: 1
JSON (--json) — structured envelope with metadata:
{
"success": true,
"total": 2,
"succeeded": 1,
"failed": 1,
"results": [
{ "id": "...", "success": true, "data": { ... } },
{ "id": "...", "success": false, "error": "OBJECT_NOT_FOUND", "message": "Page not found" }
],
"timestamp": "2026-02-20T20:15:00.000Z"
}| Code | Meaning |
|---|---|
0 |
All resources retrieved successfully |
1 |
One or more resources failed (partial or total failure) |
Each resource is fetched independently. If one ID fails (wrong ID, no access, deleted), the others still succeed. The results array shows the status of each individual request. Failed items include the error code and a human-readable message.
# Retrieve 3 pages, output as JSON
notion-cli batch retrieve --ids "ID1,ID2,ID3" --json
# Retrieve blocks
notion-cli batch retrieve --ids "BLOCK1,BLOCK2" --type block
# Retrieve databases by name
notion-cli batch retrieve --ids "Tasks,Projects" --type database
# Pipe IDs from a file
cat page_ids.txt | notion-cli batch retrieve --compact-json
# Mix URLs and raw IDs
notion-cli batch retrieve --ids "https://notion.so/Page-abc123,def456789012345678901234567890ab"
# Raw output for AI assistants
notion-cli batch retrieve --ids "ID1,ID2" -rDelete multiple blocks in a single command. Each ID is resolved through the standard pipeline before calling the Notion API. All deletions run in parallel. Deleted blocks are moved to Notion's trash (soft delete — recoverable from Notion's UI).
Alias: batch:d
notion-cli batch delete [IDS] [FLAGS]
| Argument | Required | Description |
|---|---|---|
IDS |
No | Comma-separated list of block IDs, URLs, or names |
If no positional argument is given, the command checks --ids flag, then stdin.
| Flag | Short | Default | Description |
|---|---|---|---|
--ids |
Comma-separated list of block IDs to delete | ||
--json |
-j |
Output as JSON with metadata (total, deleted, failed) | |
--compact-json |
-c |
Output as single-line JSON | |
--raw |
-r |
Output full API response for each deletion | |
--markdown |
-m |
Output as GitHub-flavored markdown table | |
--pretty |
-P |
Output as table with borders | |
--verbose |
-v |
Show resolver and cache debug info on stderr | |
--minimal |
Strip metadata fields | ||
--no-cache |
Bypass cache, force fresh API calls | ||
--retry |
Auto-retry on rate limit | ||
--timeout |
30000 |
Request timeout in milliseconds |
Same three methods as batch retrieve:
# Positional argument
notion-cli batch delete "BLOCK_ID_1,BLOCK_ID_2"
# --ids flag
notion-cli batch delete --ids "BLOCK_ID_1,BLOCK_ID_2"
# stdin
cat block_ids.txt | notion-cli batch delete --jsonSame as batch retrieve — accepts raw IDs, dashed UUIDs, and full Notion URLs. Database names are not applicable since batch delete only operates on blocks.
Table (default) — shows id, status, and content preview:
┌──────────────────────────────────────┬─────────┬──────────────────────────┐
│ id │ status │ content │
├──────────────────────────────────────┼─────────┼──────────────────────────┤
│ e70675e2b1e242da9cab76bde07fac6b │ deleted │ Standard Operating Proc… │
├──────────────────────────────────────┼─────────┼──────────────────────────┤
│ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa │ failed │ Block not found │
└──────────────────────────────────────┴─────────┴──────────────────────────┘
Total: 2 | Deleted: 1 | Failed: 1
JSON (--json) — same envelope structure as batch retrieve:
{
"success": true,
"total": 2,
"succeeded": 1,
"failed": 1,
"results": [
{ "id": "...", "success": true, "data": { ... } },
{ "id": "...", "success": false, "error": "OBJECT_NOT_FOUND", "message": "Block not found" }
],
"timestamp": "2026-02-20T20:20:00.000Z"
}| Code | Meaning |
|---|---|
0 |
All blocks deleted successfully |
1 |
One or more deletions failed |
Same as batch retrieve: each deletion is independent. If one block fails, the rest still proceed. Common failure causes:
- OBJECT_NOT_FOUND — block doesn't exist or integration lacks access
- VALIDATION_ERROR — invalid ID format
- UNAUTHORIZED — token is missing or invalid
# Delete 3 blocks, output as JSON
notion-cli batch delete --ids "BLOCK1,BLOCK2,BLOCK3" --json
# Delete from a file of block IDs
cat blocks_to_delete.txt | notion-cli batch delete --json
# Delete using Notion URLs
notion-cli batch delete --ids "https://notion.so/Page-abc123"
# Compact output for scripting
notion-cli batch delete --ids "ID1,ID2" --compact-json| File | Purpose |
|---|---|
src/commands/batch/retrieve.ts |
Batch retrieve command |
src/commands/batch/delete.ts |
Batch delete command |
src/utils/notion-resolver.ts |
ID resolution pipeline used by both commands |
- Smart ID Resolution — How URLs and names are resolved to Notion IDs
- Output Formats — All output format options
- Error Handling — Understanding error codes and recovery
- Batch Operations Guide — Practical workflows and recipes