Skip to content

Sources Commands

Manage sources (content) within NotebookLM notebooks.

Available Commands

Command Description
add Add sources to a notebook
upload Upload a file as a source
get Get details of a specific source
delete Delete sources from a notebook

add

Add one or more sources to a notebook.

Usage

nblm sources add --notebook-id <ID> [SOURCE_OPTIONS...]

Options

Option Description Required Can Repeat
--notebook-id <ID> Notebook identifier Yes No
--web-url <URL> Web page URL No Yes
--web-name <NAME> Display name for web source No Yes
--text <CONTENT> Text content No Yes
--text-name <NAME> Display name for text source No Yes
--video-url <URL> YouTube video URL No Yes
--drive-document-id <ID> Google Drive document ID No Yes
--drive-mime-type <TYPE> Google Drive MIME type No Yes
--drive-name <NAME> Display name for Drive doc No Yes

Note: At least one source option must be provided.

Examples

Add a web URL:

nblm sources add \
  --notebook-id abc123 \
  --web-url "https://example.com" \
  --web-name "Example Website"

Add text content:

nblm sources add \
  --notebook-id abc123 \
  --text "My research notes" \
  --text-name "Notes"

Add YouTube video:

nblm sources add \
  --notebook-id abc123 \
  --video-url "https://www.youtube.com/watch?v=dQw4w9WgXcQ"

Add multiple sources at once:

nblm sources add \
  --notebook-id abc123 \
  --web-url "https://docs.python.org" \
  --web-name "Python Docs" \
  --text "Sample notes" \
  --text-name "My Notes" \
  --video-url "https://www.youtube.com/watch?v=VIDEO_ID"

Add Google Drive file:

nblm sources add \
  --notebook-id abc123 \
  --drive-document-id "FILE_ID" \
  --drive-mime-type "application/vnd.google-apps.presentation" \
  --drive-name "Team Update Slides"

Google Drive File ID

FILE_ID can be extracted from the Drive URL at /d/<ID>/ (e.g., https://drive.google.com/file/d/<ID>/xxx). Ensure the authenticated account has view access to the file.

Drive Access Validation

When you add Drive sources, nblm validates that the token includes the https://www.googleapis.com/auth/drive.file (or broader drive) scope and that the authenticated account can open the document. If either check fails, the upload is aborted with an error instead of creating placeholder metadata.

JSON output:

nblm --json sources add \
  --notebook-id abc123 \
  --web-url "https://example.com"

Output:

{
  "sources": [
    {
      "name": "projects/123456789012/locations/global/notebooks/abc123/sources/source-1",
      "title": "Example Website",
      "createTime": "2025-10-25T10:30:00Z"
    }
  ]
}

Source Requirements

  • Web URLs are fetched and indexed automatically
  • Text content must not be empty
  • Video URLs currently only support YouTube (youtubeUrl field)
  • Google Drive sources require gcloud auth login --enable-gdrive-access and the authenticated account must have access to the document
  • The --web-name and --text-name options are optional; if not provided, defaults are used

upload

Upload a local file as a notebook source.

Usage

nblm sources upload --notebook-id <ID> --file <PATH> [OPTIONS]

Options

Option Description Required
--notebook-id <ID> Notebook identifier Yes
--file <PATH> Path to file to upload Yes
--content-type <TYPE> HTTP Content-Type (MIME type) No
--display-name <NAME> Display name for the source No

Examples

Upload a PDF:

nblm sources upload \
  --notebook-id abc123 \
  --file document.pdf

Upload with custom content type:

nblm sources upload \
  --notebook-id abc123 \
  --file report.txt \
  --content-type "text/plain"

Upload with display name:

nblm sources upload \
  --notebook-id abc123 \
  --file research.pdf \
  --display-name "Research Paper 2025"

JSON output:

nblm --json sources upload \
  --notebook-id abc123 \
  --file document.pdf

Output:

{
  "sourceId": "source-abc123"
}

Upload Requirements

  • Content type is auto-detected from file extension if not specified
  • Supported file types include: PDF, TXT, DOCX, and more
  • File must exist and be readable
  • Empty files cannot be uploaded
  • Maximum file size may be limited by the API

get

Get details of a specific source.

Usage

nblm sources get --notebook-id <ID> --source-id <SOURCE_ID>

Options

Option Description Required
--notebook-id <ID> Notebook identifier Yes
--source-id <SOURCE_ID> Source identifier Yes

Examples

Get source details:

nblm sources get \
  --notebook-id abc123 \
  --source-id source-1

JSON output:

nblm --json sources get \
  --notebook-id abc123 \
  --source-id source-1

Output:

{
  "name": "projects/123456789012/locations/global/notebooks/abc123/sources/source-1",
  "title": "Example Website",
  "metadata": {
    "wordCount": 1500,
    "sourceAddedTimestamp": "2025-10-25T10:30:00Z"
  },
  "settings": {
    "status": "ACTIVE"
  }
}

Source Details

  • Use this to verify source details after adding
  • Useful for checking processing status
  • The source-id can be extracted from the full source name

delete

Delete one or more sources from a notebook.

Usage

nblm sources delete --notebook-id <ID> --source-name <NAME> [--source-name <NAME>...]

Options

Option Description Required
--notebook-id <ID> Notebook identifier Yes
--source-name <NAME> Full source resource name (can be repeated) Yes

Examples

Delete a single source:

nblm sources delete \
  --notebook-id abc123 \
  --source-name "projects/123456789012/locations/global/notebooks/abc123/sources/source-1"

Delete multiple sources:

nblm sources delete \
  --notebook-id abc123 \
  --source-name "projects/.../notebooks/abc123/sources/source-1" \
  --source-name "projects/.../notebooks/abc123/sources/source-2"

Get source names from notebook and delete:

# List sources and extract names (requires getting notebook details first)
SOURCE_NAME="projects/123456789012/locations/global/notebooks/abc123/sources/source-1"

nblm sources delete \
  --notebook-id abc123 \
  --source-name "$SOURCE_NAME"

Deletion is Permanent

  • Deletion is permanent and cannot be undone
  • The full source resource name is required (not just the source ID)
  • Multiple sources can be deleted in a single command

Common Patterns

Add and verify source

# Add source
RESULT=$(nblm --json sources add \
  --notebook-id abc123 \
  --web-url "https://example.com")

# Extract source name
SOURCE_NAME=$(echo "$RESULT" | jq -r '.sources[0].name')

# Extract source ID from name
SOURCE_ID=$(echo "$SOURCE_NAME" | awk -F'/' '{print $NF}')

# Get source details
nblm sources get \
  --notebook-id abc123 \
  --source-id "$SOURCE_ID"

Bulk upload files

# Upload all PDFs in a directory
for file in *.pdf; do
  echo "Uploading $file..."
  nblm sources upload \
    --notebook-id abc123 \
    --file "$file"
done

Add sources from a list

# urls.txt contains one URL per line
while IFS= read -r url; do
  echo "Adding $url..."
  nblm sources add \
    --notebook-id abc123 \
    --web-url "$url"
done < urls.txt

Error Handling

Common Errors

Empty text content:

Error: Text content cannot be empty
Cause: The --text option was provided with empty string

File not found:

Error: File not found: /path/to/file
Cause: The specified file does not exist or is not readable

Invalid notebook ID:

Error: Notebook not found
Cause: The specified notebook does not exist or you don't have access

Next Steps