Skip to main content

Nextcloud bulk user creation and update tool with CLI/TUI

Project description

nextcloud-bulk-users-utils (PyPI: ncbulk)

CLI: nextcloud-bulk · Python >= 3.12

Why

  • Bulk create/update Nextcloud users from CSV via the OCS Provisioning API.

Bulk creation and updates of Nextcloud users via the OCS Provisioning API.

Features

  • Create users from CSV.
  • Group list in a single CSV field (groups or group), multiple groups separated by a configurable delimiter.
  • Default quota and language via CLI/TUI or per-row via quota and language columns.
  • Welcome mode (no password) – sends a welcome email (requires user email).
  • Update existing users: email, displayname, quota, and add to groups.
  • Dry-run, verbose logging, timeouts and retries.
  • Flexible input/output CSV paths and delimiters.
  • Step-by-step terminal wizard: delimiter auto-detection and CSV preview.

Environment

Set admin credentials via environment variables (see example.env):

export NEXTCLOUD_URL="https://cloud.example.com"
export NEXTCLOUD_ADMIN_USERNAME="admin"
export NEXTCLOUD_ADMIN_PASSWORD="secret"

You may put them into a local .env file; the tool reads values from the environment. An example file is provided as example.env. Security note: .env may contain plaintext password and is git-ignored. Keep it local and protected.

Tip: Prefer using an App Password

For better security and least-privilege access, create an App Password in Nextcloud for the admin account and use it as NEXTCLOUD_ADMIN_PASSWORD instead of the main account password. If the tool reports 401/403 during the early OCS check, verify the credentials and consider switching to an App Password.

CSV Format

CSV must include a header. Minimal columns: username;email;displayname;group

Optional columns: groups (instead of group), quota, language.

Default delimiter is ; (you can change it). Example:

username;email;displayname;groups;quota;language
alice;alice@example.org;Alice A;Students,Math;10GB;en

If present, address column is ignored.

Install

Requires Python >= 3.12.

Local install:

pip install .

Via pipx (recommended isolation):

pipx install .

From PyPI:

pip install ncbulk

Usage

Run the interactive step-by-step wizard:

# installed entry point (recommended)
nextcloud-bulk

# or run module directly (development)
python -m ncbulk.main

Run the CLI directly:

nextcloud-bulk --input list.csv --quota 10GB --language en --output users_passwds.csv

Key options:

  • --quota 10GB – default quota (overridden by row quota).
  • --language en – default language (overridden by row language).
  • --delimiter ";" – CSV delimiter.
  • --groups-delimiter "," – delimiter inside the groups field.
  • --welcome – do not set password, send welcome email.
  • --password-length 12 – generated password length (when not in welcome mode).
  • --dry-run – simulate without changes.
  • --verbose – verbose HTTP attempts.
  • --timeout 15 – HTTP timeout in seconds.
  • --retries 2 – retry attempts.
  • --update-existing – update existing users.
  • --input, --output – input and report CSV paths.

Output Report

The report file (default users_passwds.csv) has the columns:

Username;Email;Displayname;Groups;Password;Status

Password is empty when --welcome is used. Status is one of Created, Updated, Skipped.

Examples

  1. Basic creation with default quota and language:
nextcloud-bulk --input list.csv --quota 10GB --language en
  1. Multiple groups and per-row quota/language from CSV:
username;email;displayname;groups;quota;language
bob;bob@example.org;Bob B;HR,Onboarding;5GB;en
nextcloud-bulk --input list.csv
  1. Welcome mode and update existing users:
nextcloud-bulk --input list.csv --welcome --update-existing
  1. Dry-run:
nextcloud-bulk --input list.csv --dry-run --verbose

API Notes

  • Create: POST /ocs/v2.php/cloud/users – params: userid, optional password, repeated groups[], optional language.
  • Update fields: PUT /ocs/v2.php/cloud/users/{userid} with key/value for email, displayname, quota, etc.

Docs: Nextcloud User provisioning API

Wizard

  • Clear, step-by-step terminal prompts with validation at each step.
  • Auto-detects CSV delimiter and shows a small preview.
  • You can still run the CLI directly via nextcloud-bulk.

License

Apache-2.0 © 2025 Jaguar Kovalev

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ncbulk-0.1.4.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ncbulk-0.1.4-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file ncbulk-0.1.4.tar.gz.

File metadata

  • Download URL: ncbulk-0.1.4.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ncbulk-0.1.4.tar.gz
Algorithm Hash digest
SHA256 ce95432b039a688f806cd220bca62a91b74a7705e54dbcbddf952a3165ef64d7
MD5 decea0d2463e0ff732fd61ffd0eb0d4e
BLAKE2b-256 850a914c5d280302e53d018602fdcaae680b6590daf6b1509cde061ef24e32da

See more details on using hashes here.

File details

Details for the file ncbulk-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: ncbulk-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ncbulk-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a9d79f3b91ad68afca5c08dbba0893db5cd3df229dc9efb4c2053240cbb1db69
MD5 193f8d308e07fb0fbf436a6c1da83eb2
BLAKE2b-256 fa0f7935c558426cc5243e00ed32e45718fd07b2352fccdd60ca9be30a015f95

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page