paubox-cli
v2.1.1
Published
Official CLI for the Paubox encrypted email API
Readme
paubox-cli
Official CLI for the Paubox encrypted email API. Send HIPAA-compliant email, check delivery status, and manage your credentials from the terminal.
Installation
npm (all platforms)
npm install -g paubox-cliHomebrew (macOS)
brew tap paubox/paubox
brew install paubox-cliWindows
winget install Paubox.CLIOr via npm:
npm install -g paubox-cliKeytar (optional): The CLI uses the Windows Credential Vault for secure credential storage via the
keytarnative module. Ifkeytarfails to build during install, credentials fall back to a config file automatically — no action required. To enable native keychain support, install Visual C++ Build Tools before runningnpm install -g paubox-cli.
Requirements
- Node.js ≥ 20.12.0
- On Linux:
libsecret-1-devis required for OS keychain support
Without it, credentials fall back to a local config file automatically (sudo apt-get install libsecret-1-dev~/.config/paubox/config.jsonon Linux/macOS,%APPDATA%\paubox\config.jsonon Windows).
Quick Start
# Authenticate with your Paubox API credentials
paubox auth login
# Send an email
paubox send --to [email protected] --from [email protected] --subject "Hello" --text "Hi there!"
# Check delivery status
paubox status <trackingId>Commands
paubox auth
Manage Paubox API credentials.
paubox auth login # Prompt for API key; validate and store
paubox auth set-forms-key # Prompt for a Forms API key (scoped key with the "forms" scope)
paubox auth logout # Remove stored credentials (including the Forms API key)
paubox auth status # Show current authentication stateCredentials are stored in the OS keychain (macOS Keychain, Windows Credential Vault, Linux Secret Service) when available. If the keychain is unavailable, they fall back to a local config file (~/.config/paubox/config.json on Linux/macOS, %APPDATA%\paubox\config.json on Windows).
Forms API key
The authenticated paubox forms subcommands (list, stats, submissions, export-csv, export-pdf, archive, unarchive, copy, create, update) require a scoped API key with the forms scope. Store it with:
paubox auth set-forms-keyThis works standalone — you do not need to run paubox auth login first. paubox auth status shows the (masked) Forms API key alongside your email API credentials. The key is not validated at save time; an invalid key or one missing the forms scope surfaces as a 401 error on first use.
paubox send
Send a secure email.
paubox send \
--to [email protected] \
--from [email protected] \
--subject "Your subject" \
--text "Plain text body" \
--html "<p>HTML body</p>" \
--attachment /path/to/file.pdf| Flag | Required | Description |
|------|----------|-------------|
| --to <email...> | Yes | Recipient(s). Repeat for multiple: --to [email protected] --to [email protected] |
| --from <email> | No* | Sender address. Defaults to defaultFrom config value |
| --subject <text> | Yes | Email subject |
| --text <body> | No† | Plain text body |
| --html <body> | No† | HTML body |
| --attachment <file...> | No | File path(s) to attach |
† At least one of --text or --html is required.
On success, prints the source tracking ID:
✓ Email sent. Tracking ID: abc123-def456paubox status
Check the delivery status of a sent email.
paubox status <trackingId>Outputs a table of recipients with delivery status and timestamps:
recipient status delivered at opened opened at
--------------------- --------- ------------------------ ------ ---------
[email protected] delivered 2026-01-01T12:00:00Z opened 2026-01-01T13:00:00Zpaubox forms
Work with Paubox forms. Two commands are public and require no authentication (forms get, forms submit). All other subcommands are authenticated and require a Forms API key — a scoped API key with the forms scope, stored via paubox auth set-forms-key.
forms get <formId>
paubox forms get <formId>
paubox --json forms get <formId>Prints the form's title, description, active status, submission count, and timestamps. With --json, returns the raw API response object.
forms submit <formId>
# Inline key=value pairs (repeatable)
paubox forms submit <formId> \
--data "first_name=Jane" \
--data "last_name=Doe" \
--data "[email protected]"
# Read form fields from a JSON file
paubox forms submit <formId> --data-file ./fields.json
# Mix file and inline overrides (--data wins on matching keys)
paubox forms submit <formId> \
--data-file ./base.json \
--data "field=override"
# Attach a file with the submission
paubox forms submit <formId> \
--data "name=Jane" \
--attach /path/to/signed-consent.pdf| Flag | Description |
|------|-------------|
| --data <key=value> | Form field as a key=value pair. Repeatable. Values may contain =. |
| --data-file <path> | Path to a JSON file whose top-level string values are used as form_data. Merged with --data; --data takes precedence on matching keys. |
| --attach <file> | File to include as an attachment. Repeatable. Total request size must not exceed 250 MB. |
On success:
✓ Form submitted successfully.With --json:
{ "status": "ok", "formId": "<formId>" }Authenticated subcommands
The following subcommands require a Forms API key (see Forms API key). All of them respect the global --json flag; with --json, list/stats/copy commands print the raw API response.
forms list
List forms for a customer.
paubox forms list --customer-id 42 --search intake --active true --order-by updated_at --order desc| Flag | Required | Description |
|------|----------|-------------|
| --customer-id <id> | Yes | Customer ID to list forms for (integer) |
| --page <n> | No | Page number (default 1) |
| --items <n> | No | Items per page (default 50, max 100) |
| --search <text> | No | Search text (matches title/description) |
| --form-id <id> | No | Filter to a single form ID |
| --active <true\|false> | No | Filter by active state |
| --archived <true\|false> | No | Filter by archived state |
| --order-by <col> | No | Sort column: title, updated_at, submission_count, created_at |
| --order <asc\|desc> | No | Sort direction |
Human output is one line per form (<id> <title> active=<bool> archived=<bool> submissions=<n>) followed by Page X of Y (N forms total).
forms stats
Show form statistics: active form count, total submissions, and submissions in the last 7 days.
paubox forms stats # defaults to the API key's customer
paubox forms stats --customer-id 42forms submissions <formId>
List submissions for a form.
paubox forms submissions <formId> --page 1 --items 25 --order-by created_at --order desc| Flag | Description |
|------|-------------|
| --page <n> | Page number (default 1) |
| --items <n> | Items per page (default 50, max 100) |
| --order-by <col> | Sort column: created_at, submitter_email |
| --order <asc\|desc> | Sort direction |
| --submission-id <id> | Filter to a single submission ID |
Human output is one line per submission (<id> <created_at> <submitter_email>) plus a totals line.
forms export-csv <formId> [submissionId]
Export a form's submissions (or a single submission) as CSV.
paubox forms export-csv <formId> # → form-<formId>-submissions.csv
paubox forms export-csv <formId> <submissionId> # → submission-<submissionId>.csv
paubox forms export-csv <formId> --output ./export.csv # custom pathforms export-pdf <formId> <submissionId>
Export a single submission as PDF.
paubox forms export-pdf <formId> <submissionId> --output ./submission.pdfDefaults to submission-<submissionId>.pdf when --output is omitted.
forms archive <formId> / forms unarchive <formId>
Archive or unarchive a form.
paubox forms archive <formId>
paubox forms unarchive <formId>forms copy <formId>
Copy an existing form under a new title. Prints the new form's ID and title.
paubox forms copy <formId> --title "Copy of intake form"--title is required.
forms create
Create a new form from a JSON definition file. Prints the created form's ID.
paubox forms create \
--title "Patient intake" \
--customer-id 42 \
--form-json-file ./form.json \
--description "New patient intake form" \
--recipient [email protected] \
--active| Flag | Required | Description |
|------|----------|-------------|
| --title <t> | Yes | Form title |
| --customer-id <id> | Yes | Customer ID that owns the form (integer) |
| --form-json-file <path> | Yes | Path to a JSON file with the form definition |
| --description <text> | No | Form description |
| --recipient <email> | No | Recipient email address |
| --active | No | Mark the form active (default: inactive) |
| --signable | No | Mark the form signable |
| --signature-confirmation-label <label> | No | Signature confirmation label |
| --subscription-list-id <id> | No | Subscription list ID |
| --type <type> | No | Form type |
| --version <n> | No | Form version (default 1) |
| --form-html-file <path> | No | Path to a file with the form HTML |
| --form-css-file <path> | No | Path to a file with the form CSS |
forms update <formId>
Update a form. Only the fields you pass are sent (PATCH-style); at least one option is required.
paubox forms update <formId> --title "Renamed form" --active false| Flag | Description |
|------|-------------|
| --title <t> | New title |
| --description <text> | New description |
| --recipient <email> | New recipient email address |
| --active <true\|false> | Set active state |
| --vanity-url <url> | New vanity URL |
| --subscription-list-id <id> | New subscription list ID |
| --form-json-file <path> | Path to a JSON file with the new form definition |
paubox webhooks
Subscribe a URL of yours to Paubox events, so Paubox posts to it when something happens instead of you polling.
Which events your key may subscribe to follows from its scopes. A Forms-scoped key manages forms.submission.created; an Email API key manages the four delivery events. Asking for an event your key is not scoped for returns a 403 naming it, and an unrecognised name returns a 422 — the catalog lives in the service, not in this CLI.
| Event | Fires when |
|-------|------------|
| forms.submission.created | A form submission is received |
| api_mail_log_delivered | An Email API message is delivered |
| api_mail_log_opened | A delivered message is opened |
| api_mail_log_temporary_failure | Delivery fails temporarily |
| api_mail_log_permanent_failure | Delivery fails permanently |
| email.inbound.received | Inbound mail is received |
The four Email API events keep their legacy api_mail_log_ names so receivers written against the old Email API webhooks keep working. These are the names on the wire: delivered or failed on their own are rejected as unknown.
Deliveries are signed with a secret returned once, at creation. --url must be an https URL that resolves to a publicly routable address.
paubox webhooks create --url https://hooks.yourdomain.com/paubox \
--events forms.submission.created
# Email API delivery events, with an Email API key
paubox webhooks create --url https://hooks.yourdomain.com/mail \
--events api_mail_log_delivered api_mail_log_permanent_failure
paubox webhooks list
paubox webhooks get <subscriptionId>
paubox webhooks update <subscriptionId> --status disabled
paubox webhooks delete <subscriptionId>create prints the signing secret:
✓ Subscribed https://hooks.yourdomain.com/paubox to forms.submission.created.
ID: 6f1c...
...
Signing secret: whsec_...
Store it now — it is not shown again.Use --json on create if you need to capture the secret programmatically; there is no way to retrieve it afterward, and losing it means replacing the subscription.
| Command | Flag | Description |
|---------|------|-------------|
| list | --page <n> | Page number (default 1) |
| list | --items <n> | Items per page (default 50, max 200) |
| create | --url <url> | Required. Delivery target; must be an https URL |
| create | --events <events...> | Required. Events to subscribe to |
| update | --url <url> | New delivery target |
| update | --events <events...> | Replace the subscribed events |
| update | --status <active\|disabled> | Pause or resume deliveries |
Subscription IDs are UUIDs, as printed by list.
The command uses your stored Forms API key when there is one, falling back to the Email API key.
Moved in 2.0.0. This was
paubox forms webhooks, nested there because an API key could only manage Forms subscriptions. Since the Email API webhook cutover, one key type reaches every event it is scoped for, so the nesting implied a limit that no longer exists.paubox forms webhooksstill works and prints a deprecation notice.
paubox config
Manage CLI configuration stored in ~/.config/paubox/config.json (Linux/macOS) or %APPDATA%\paubox\config.json (Windows).
paubox config set defaultFrom [email protected]
paubox config get defaultFrom
paubox config list
paubox config reset| Key | Description |
|-----|-------------|
| defaultFrom | Default sender address used when --from is omitted |
Global Options
These flags work with any command:
| Flag | Description |
|------|-------------|
| --json | Output result as JSON (useful for scripting). Errors are written to stderr as JSON too. |
| -q, --quiet | Suppress non-essential output |
| --timeout <seconds> | Per-request timeout. Defaults to 30 seconds, plus upload time for large sends (budgeted at 256 KB/s, so a 250 MB send gets about 17 minutes). An explicit value, or PAUBOX_TIMEOUT, is used exactly. |
| -v, --version | Print version |
| --help | Show help |
JSON output example
paubox --json send --to [email protected] --from [email protected] --subject Hi --text Hello
# {"sourceTrackingId":"abc123-def456"}Errors
Exit codes
Every failure exits with a code naming its kind, so a script can branch on why a command failed without parsing stderr.
| Code | Meaning | Typical cause |
|------|---------|---------------|
| 0 | Success | |
| 1 | Unexpected error | A bug in the CLI — please report it |
| 2 | Authentication | No key stored, key rejected, or key not scoped for the operation |
| 3 | Validation | The arguments were rejected locally; nothing was sent |
| 4 | API error | Paubox accepted the request and refused or failed it |
| 5 | Network | DNS, TLS, connection or timeout — the request never arrived |
| 6 | Configuration | This machine is not set up (no default sender, bad base URL override) |
paubox send --to bad@ --from [email protected] --subject Hi --text Hello
echo $? # 3 — nothing was sentMachine-readable errors
Under --json, errors are written to stderr as JSON while stdout stays
clean for results:
paubox --json send --to bad@ --from [email protected] --subject Hi --text Hello{
"error": {
"type": "validation",
"message": "Invalid message: --to: \"bad@\" is not a valid email address",
"suggestion": "Fix the arguments listed above. Nothing was sent.",
"problems": ["--to: \"bad@\" is not a valid email address"]
}
}Request IDs
Every request carries an X-Request-Id of the form pbcli-<uuid>, and any
failure that reached Paubox prints it:
✗ Send email failed (422 Unprocessable Entity): Invalid Recipient: nope@ is not a valid address
Hint: The API rejected the request as malformed. Fix the field named above and retry.
Request ID: pbcli-9f1c2d3e-4b5a-6789-abcd-ef0123456789Quote that ID in a support ticket — it identifies the request in Paubox's logs.
paubox doctor
Checks the things that usually turn out to be wrong: runtime version, where credentials are stored and whether each key is set, whether a base-URL override is in effect, and whether each API is reachable from this machine.
paubox doctorRetries
Idempotent requests (GETs) are retried up to twice with backoff on 429, 502,
503, 504 and on transient connection failures, honouring Retry-After where
the API sends one. Sends are never replayed — a POST that may have been
accepted is reported rather than repeated.
Environment Variables
| Variable | Description |
|----------|-------------|
| PAUBOX_API_KEY | Email API key. Takes precedence over anything stored, and needs no keychain — this is how to authenticate on a headless machine. |
| PAUBOX_FORMS_API_KEY | Scoped API key used by paubox forms and paubox webhooks. Same precedence. |
| PAUBOX_FORMS_URL | Override the Forms API base URL. Defaults to https://apx.paubox.com/forms. Must be an http or https URL. |
| PAUBOX_WEBHOOKS_URL | Override the webhooks API base URL used by paubox webhooks. Defaults to https://api.paubox.com/v1/webhooks. Must be an http or https URL. |
| PAUBOX_TIMEOUT | Per-request timeout in seconds. Defaults to 30. --timeout takes precedence. |
| PAUBOX_DEBUG | Set to 1 to log each request's method, URL, status, timing and request ID to stderr. Credentials are never logged. |
Running without a keychain
By default the CLI stores credentials in the OS keychain, falling back to
~/.config/paubox/config.json when that is unavailable. On a machine with no
desktop session — a Linux container, CI, SSH, WSL — the keychain cannot be
reached and keytar reports:
Cannot autolaunch D-Bus without X11 $DISPLAYThe CLI falls back to the config file on its own when that happens, and
paubox doctor reports it as a warning rather than a failure. For an
environment with no writable config either, or where you would rather not
write a key to disk at all, set the keys directly:
export PAUBOX_API_KEY=your-email-api-key
export PAUBOX_FORMS_API_KEY=your-scoped-api-key
paubox send --to [email protected] --subject Hi --text "..."
paubox webhooks listEnvironment keys outrank stored ones and are read per key, so one can come from
the environment while the other stays in the keychain. paubox auth status
shows where each one came from.
These point the paubox forms commands at a non-production environment without
patching and rebuilding:
PAUBOX_FORMS_URL=https://api.staging.paubox.net/forms paubox forms list
PAUBOX_WEBHOOKS_URL=https://api.staging.paubox.net/v1/webhooks paubox webhooks listYour Forms API key is sent to whatever host these resolve to, so only point them at Paubox-operated environments.
Versioning and stability
paubox-cli follows Semantic Versioning 2.0.0. Published versions are plain MAJOR.MINOR.PATCH numbers; the v in the paubox-cli-v<version> git tags is a naming convention, not part of the version.
Versions 0.1.0 through 0.4.0 were initial development releases and carried no stability guarantee. Starting with 1.0.0, the following is the public API, and a backward-incompatible change to any of it requires a major release:
| Covered | Notes |
|---------|-------|
| Command and subcommand names | paubox send, paubox forms list, and every other command documented above |
| Documented flags | Long and short forms, argument arity, and defaults, as listed in this README |
| --json output | Field names and types. New fields may appear in a minor release; existing fields are not renamed, retyped, or removed outside a major release |
| Exit status | 0 on success, non-zero on failure |
| Environment variables | The names and meanings of the variables documented above |
| engines.node floor | Raising the minimum Node.js version is a breaking change |
Everything else may change in any release, including a patch:
- Human-readable output. The wording, colour, ordering, and layout of non-
--jsontext on stdout and stderr, including error messages and the suggestion lines printed after a failure. Scripts should read--jsonand branch on zero versus non-zero exit status rather than matching on text or on a specific non-zero code. - The library entry point.
package.jsondeclaresmainandtypes, which makescreateProgram()andrun()importable as a byproduct of how the CLI is packaged. They are internal and unsupported — depend on thepauboxexecutable, not on the module. - Internal modules. Everything under
src/lib/(API clients, credential storage, config store, output helpers) and the TypeScript types it exports, includingPauboxCredentials. - On-disk layout. The credential and config file format at
~/.config/paubox/config.json, its Windows equivalent, and the OS keychain entries are implementation details. Read them throughpaubox auth statusandpaubox config. - Pre-releases. Anything published under a dist-tag other than
latest.
Homebrew Tap Setup
After publishing to npm, create the Homebrew tap in a separate repository named homebrew-paubox:
homebrew-paubox/
└── Formula/
└── paubox-cli.rbclass PauboxCli < Formula
desc "Official CLI for the Paubox encrypted email API"
homepage "https://github.com/Paubox/paubox-cli"
url "https://registry.npmjs.org/paubox-cli/-/paubox-cli-0.1.0.tgz"
sha256 "<sha256 of the npm tarball>"
license "Apache-2.0"
depends_on "node"
def install
system "npm", "install", *std_npm_args
bin.install_symlink libexec/"bin/paubox"
end
test do
assert_match "paubox", shell_output("#{bin}/paubox --version")
end
endTo get the SHA256: curl -s https://registry.npmjs.org/paubox-cli/0.1.0 | jq -r .dist.shasum
Development
git clone https://github.com/Paubox/paubox-cli.git
cd paubox-cli
npm install
npm test # Run tests
npm run lint # Lint
npm run build # Compile TypeScript
npm run dev -- auth status # Run without buildingProject structure
src/
commands/ auth, send, status, config, forms, forms-admin command handlers
lib/ api client, forms API client, credential storage, config store, output helpers
index.ts Library entry — exports createProgram() and run()
cli.ts Runtime entry — invokes run() (used by bin/ and `npm run dev`)
bin/
paubox.js Shebang wrapper (ships in npm package)
test/ Jest unit tests mirroring src/ structureReleasing
Releases are fully automated through Release Please and npm Trusted Publishers. No local commands, no tokens, no manual tagging.
Flow
- Land changes on
masterusing Conventional Commits:fix: ...→ patch bump (e.g. 1.0.0 → 1.0.1)feat: ...→ minor bump (e.g. 1.0.0 → 1.1.0)feat!: ...orBREAKING CHANGE:in the body → major bump (e.g. 1.0.0 → 2.0.0)chore: ...,docs: ...,refactor: ...,test: ...→ no version bump
- The release-please workflow opens (or updates) a PR titled
chore(master): release <next-version>with a generatedCHANGELOG.mdentry and the version bump inpackage.jsonand.release-please-manifest.json. - When that PR is merged, the same workflow creates the
paubox-cli-v<version>git tag + GitHub Release, then immediately runs a dependentpublishjob that validates the build and publishes to npm with provenance via OIDC.
Release-please and the publish job live in the same workflow file (release-please.yml) on purpose: a separate workflow listening for tag pushes would never fire, because tags created by GITHUB_TOKEN deliberately don't trigger downstream workflows. Chaining the jobs via needs: keeps the entire release in one run, no PAT required.
If the publish job ever fails for a transient reason (registry hiccup, OIDC rotation, etc.), recover by re-running just the failed job from the Actions UI — the release-please job already created the tag and Release, so re-running the publish job picks them up unchanged.
Setup requirements (one-time)
- Repository setting: Settings → Actions → General → Workflow permissions → Allow GitHub Actions to create and approve pull requests (so release-please can open the release PR).
- npm package setting: a trusted publisher must be configured at
npmjs.com/package/paubox-cli/access, pointing at this repo andrelease-please.yml.
License
Apache 2.0 — see LICENSE
💬 Community & support
Questions, ideas, or want to share what you built? Join the Paubox Community — the single home for discussions across every Paubox SDK and API.
🔐 Found a security issue? Email [email protected] — please don't post it publicly.
