Skip to content

Snippet Commands - Manage Bitbucket Snippets

Manage Bitbucket Cloud snippets — workspace-scoped code/text pastes.

Snippet commands operate at workspace scope (no repo context required). Use -w, --workspace <workspace> or set a default with bb config set defaultWorkspace <workspace>.

Global options available on all snippet commands: --json [fields], --jq <expression>, --no-color, -w, --workspace.


List snippets in a workspace.

Terminal window
bb snippet list [options]
OptionDescription
-w, --workspace <workspace>Workspace
--role <role>Filter by authenticated user’s role: owner, contributor, or member
--limit <number>Maximum number of snippets (default: 25)
--jsonOutput as JSON
Terminal window
bb snippet list
bb snippet list --role owner
bb snippet list --limit 50 --json
# Project to specific fields (returns a flat array)
bb snippet list --json id,title,is_private
# Filter with built-in --jq — public snippets only
bb snippet list --json --jq '.snippets[] | select(.is_private == false) | .title'
  • --limit is enforced across paginated responses.

View snippet details. Optionally print file contents.

Terminal window
bb snippet view <id> [options]
ArgumentDescription
idSnippet encoded ID (e.g. kypj)
OptionDescription
-w, --workspace <workspace>Workspace
-f, --file <name>Print contents of a specific file in the snippet
--filesPrint contents of all files in the snippet
--jsonOutput as JSON
Terminal window
bb snippet view kypj
bb snippet view kypj --json
bb snippet view kypj --file config.yml
bb snippet view kypj --files

Create a snippet. The files you pass are uploaded as multipart/form-data to Bitbucket — their contents are the snippet body.

Terminal window
bb snippet create [options]
OptionDescription
-w, --workspace <workspace>Workspace
-t, --title <title>Snippet title (required)
-f, --file <path...>One or more file paths to include (required)
--privateCreate a private snippet (default)
--publicCreate a public snippet
--jsonOutput as JSON
Terminal window
bb snippet create -t "My snippet" -f file.txt
bb snippet create -t "Config files" -f config.yml -f setup.sh --public
  • Snippets are private by default.
  • --private and --public cannot both be set.
  • Each --file must exist on disk; missing files fail the command before any upload.

Update a snippet’s title, visibility, or files.

Terminal window
bb snippet edit <id> [options]
ArgumentDescription
idSnippet encoded ID
OptionDescription
-w, --workspace <workspace>Workspace
-t, --title <title>New title
--privateMake snippet private
--publicMake snippet public
-f, --file <path...>Replace or add file(s); sends a multipart update
--jsonOutput as JSON
Terminal window
bb snippet edit kypj -t "New title"
bb snippet edit kypj --public
bb snippet edit kypj -f updated.txt
  • Metadata-only edits (title, visibility) send a JSON PUT.
  • Passing --file switches to a multipart PUT and uploads the given files.
  • At least one of --title, --private, --public, or --file is required.

Delete a snippet. Permanent.

Terminal window
bb snippet delete <id> [options]
OptionDescription
-w, --workspace <workspace>Workspace
-y, --yesConfirm deletion (required)
--jsonOutput as JSON
Terminal window
bb snippet delete kypj --yes

Subscribe or unsubscribe the authenticated user to/from a snippet.

Terminal window
bb snippet watch <id> [options]
bb snippet unwatch <id> [options]
Terminal window
bb snippet watch kypj
bb snippet unwatch kypj

List comments on a snippet.

Terminal window
bb snippet comments list <id> [options]
OptionDescription
-w, --workspace <workspace>Workspace
--limit <number>Maximum number of comments (default: 25)
--jsonOutput as JSON
Terminal window
bb snippet comments list kypj
bb snippet comments list kypj --limit 50 --json

Add a comment to a snippet.

Terminal window
bb snippet comments add <id> [options]
OptionDescription
-w, --workspace <workspace>Workspace
-m, --message <message>Comment body (required)
--jsonOutput as JSON
Terminal window
bb snippet comments add kypj -m "Great snippet!"

Edit a comment on a snippet.

Terminal window
bb snippet comments edit <snippet-id> <comment-id> <message> [options]
Terminal window
bb snippet comments edit kypj 123 "Updated comment"

Delete a comment on a snippet.

Terminal window
bb snippet comments delete <snippet-id> <comment-id> [options]
OptionDescription
-w, --workspace <workspace>Workspace
-y, --yesConfirm deletion (required)
--jsonOutput as JSON
Terminal window
bb snippet comments delete kypj 123 --yes