Automate
CLI
Manage projects, keys, integrations and sessions from a terminal or a CI job.
The Showbug CLI manages a Showbug account from a terminal or a script. It has a command for each common task, and showbug api calls any other endpoint of the REST API. It prints readable tables for people and JSON for scripts and AI agents, and it signs in with an API token.
Install and run
The package is @showbug/cli and the command is showbug. It needs Bun or Node.js 20 or later. Run it without installing:
bunx @showbug/cli whoaminpx @showbug/cli does the same with Node.js. To install it, so that showbug is on your path:
bun add --global @showbug/cli
# or
npm install --global @showbug/cli
showbug --versionThe examples below use showbug. If you have not installed it, put bunx @showbug/cli in its place.
Signing in and configuration
showbug login
showbug whoamishowbug login opens the dashboard with a short code. Check the code matches the one in your terminal, choose the organisation and approve; the CLI saves the new API token. The code lasts ten minutes and works once. The token is read-only unless you ask for more, and you can revoke it under Settings → API tokens (see API tokens):
showbug login --scopes developer # or full, or scope names
showbug login --paste # paste a token you made in the dashboardwhoami shows who the token acts for:
user: Dana <dana@example.com>
org: Acme (org_…), role admin
token: GitHub Actions deploy (tok_…)
scopes: keys:write, projects:write
expires: 2026-12-28T10:15:00ZIn a script, pipe the token in, or skip login and set the environment variable SHOWBUG_TOKEN, which the CLI reads on every run:
printf '%s\n' "$TOKEN" | showbug loginThe CLI calls production’s API unless you give it another address. To use another environment, add its address when you log in; it is saved with the token. For this environment:
showbug login --api-url https://api.showbugai.comshowbug logout deletes the saved token.
In an app’s folder, showbug init detects Next.js, React or plain HTML, picks or creates the project, allows the dev server’s localhost origin and adds the script (in Next.js, the public key goes in .env.local). showbug doctor checks the config, the token, the API, the project’s keys and origins and, with --url, the page itself, and prints a fix for each problem.
cd my-app
showbug init # asks which project, shows the diff, asks once
showbug init --yes --origin https://shop.example.com
showbug doctor --project prj_… --url http://localhost:3000| Setting | Flag | Environment variable | Default |
|---|---|---|---|
| API token | --token | SHOWBUG_TOKEN | The token saved by login |
| API address | --api-url | SHOWBUG_API_URL | https://api.showbugai.com |
| Organisation id | --org | SHOWBUG_ORG | The token’s own organisation, which the CLI looks up |
A flag beats the environment, the environment beats the saved file, and the saved file beats the default. The file is ~/.config/showbug/config.json, or showbug/config.json under $XDG_CONFIG_HOME if that is set. It holds the token, the API address and the organisation, and is readable only by you. Treat it like a password. In CI, prefer SHOWBUG_TOKEN from your secret store.
Commands
showbug --help lists every command, and showbug <command> --help shows one command’s arguments and flags. <project>, <key>, <integration>, <connection>, <delivery>, <session>, <user> and <invite> are ids, as the matching list command shows them. Scope is what the token needs.
Sign in
| Command | What it does | Scope | Asks first |
|---|---|---|---|
login [--scopes <preset>] [--paste] | Sign in from the browser with a one-time code, or save a token you paste. | Any token | |
logout | Delete the saved token. | None | |
whoami | Show the user, organisation, scopes and expiry of the token. | Any token |
Install and check
| Command | What it does | Scope | Asks first |
|---|---|---|---|
init [--project <project>] [--origin <url>] [--yes] [--dry-run] | Install the widget in the app in this folder: detect the framework, pick or create the project, allow its localhost origin, add the script. Shows a diff first. | projects:write, keys:write | |
doctor [--project <project>] [--url <url>] | Check the config, the API, the token and, with flags, the project’s keys and origins and a page. Prints a fix for each problem; exits 1 if one failed. | Any token | |
snippet <project> [--framework <name>] | Print the script tag, with a live key, to add by hand. | keys:read |
Organisation, members and audit log
| Command | What it does | Scope | Asks first |
|---|---|---|---|
org get | Show the organisation. | org:read | |
org rename <name> | Rename the organisation. | org:write | |
members list | List members. | members:read | |
members role <user> <role> | Change a member’s role: viewer, member or admin. A token cannot make an owner. | members:write | |
members remove <user> | Remove a member. | members:write | Yes |
invites list | List pending invites. | members:read | |
invites create <email> --role <role> | Invite someone. The invite is emailed, and its link is shown once. | members:write | |
invites resend <invite> | Email an invite again. This makes a new link and ends the old one. | members:write | |
invites revoke <invite> | Revoke a pending invite. | members:write | Yes |
audit | Show the audit log, newest first. | audit:read | |
usage [--period YYYY-MM] | Show the plan and a month's usage, per project. Owners and admins. | usage:read |
Projects, origins and keys
| Command | What it does | Scope | Asks first |
|---|---|---|---|
projects list | List projects. | projects:read | |
projects get <project> | Show a project and its keys. | projects:read | |
projects create <name> [--origin <url>] | Create a project. It comes with a Default key. Repeat --origin for more than one. | projects:write | |
projects update <project> [flags] | Change a project. Only the flags you pass change: --name, --status active or suspended (suspended is what the dashboard calls Paused), --limit name=n. | projects:write | |
origins list <project> | List the allowed origins. | projects:read | |
origins add <project> <origin> | Allow an origin. | projects:write | |
origins remove <project> <origin> | Stop allowing an origin. | projects:write | Yes |
keys list <project> | List a project’s SDK keys. | keys:read | |
keys create <project> [--label <label>] | Create an SDK key. | keys:write | |
keys revoke <project> <key> | Revoke an SDK key. | keys:write | Yes |
Integrations, connections and deliveries
| Command | What it does | Scope | Asks first |
|---|---|---|---|
integrations list <project> | List a project’s integrations. | integrations:read | |
integrations add-webhook <project> --url <url> [--events <list>] | Send signed events to a URL. The signing secret is shown once. | integrations:write | |
integrations add-linear <project> --connection <id> [flags] | Send the project’s reports to a Linear team through a connection: --team-id, --team-name, --label-ids, --linear-project-id. Without a team it waits in setup. | integrations:write | |
integrations add-github <project> --connection <id> [flags] | Send the project’s reports to a GitHub repository through a connection: --repo owner/name, --labels. Without a repository it waits in setup. | integrations:write | |
integrations update <project> <integration> [flags] | Change an integration. Only the flags you pass change. | integrations:write | |
integrations test <project> <integration> | Send a test delivery, or check the credentials. | integrations:write | |
integrations rotate-secret <project> <integration> | Make a new webhook signing secret. The old one works for 24 more hours. | integrations:write | Yes |
integrations remove <project> <integration> | Remove an integration and cancel its pending deliveries. | integrations:write | Yes |
connections list | List the organisation’s Linear and GitHub connections. | integrations:read | |
connections connect-linear --api-key <key> | Connect the organisation to Linear with an API key. Do this once; every project can then send through it. | integrations:write | |
connections connect-github --github-token <token> | Connect the organisation to GitHub with a token that can create issues. | integrations:write | |
connections options <connection> [--team <id>] [--repo <owner/name>] | List what a connection can target: Linear teams and labels, or GitHub repositories and labels. | integrations:read | |
connections test <connection> | Check a connection’s credentials with the provider. | integrations:write | |
connections remove <connection> | Disconnect, and remove every integration that sends through the connection. | integrations:write | Yes |
deliveries list <project> [flags] | List deliveries, newest first. | integrations:read | |
deliveries retry <project> <delivery> | Queue a failed delivery again. | integrations:write |
Sessions
| Command | What it does | Scope | Asks first |
|---|---|---|---|
sessions list [flags] | List sessions, newest first. | sessions:read | |
sessions get <session> | Show a session with its transcript and ticket state. | sessions:read | |
sessions retry-tickets <session> | Queue a session’s failed ticket deliveries again. | integrations:write |
Any endpoint
| Command | What it does | Scope | Asks first |
|---|---|---|---|
api <method> <path> [--data <json>] | Call any endpoint of the REST API. | What the endpoint needs | For DELETE |
deliveries listtakes--status(pending, running, succeeded, dead or cancelled),--destination <id>and--session <id>.sessions listtakes--project <id>and--status(active, ended or abandoned).deliveries list,sessions listandauditare paged. Add--limit <n>and--cursor <cursor>to page by hand, or--allto follow every page and get one merged answer.integrations updatetakes--paused true|false,--urland--eventsfor a webhook;--team-id,--team-name,--label-idsand--linear-project-idfor Linear; and--repoand--labelsfor GitHub.- Linear and GitHub are connected once for the organisation, with
connections connect-linearorconnections connect-github, which print the connection’s id. Thenintegrations add-linearorintegrations add-githubsends a project’s reports through it.connections optionslists the teams and repositories to pick from. connections connect-githubtakes the GitHub token as--github-token, so it never gets mixed up with your Showbug token (--token,SHOWBUG_TOKENorlogin).- Commands that create something send an
Idempotency-Key, a new one each time. Pass your own with--idempotency-key.
api calls any endpoint. Paths are under /api/v1, and {org} becomes your organisation’s id. --data takes JSON, @file to read a file, or - to read standard input.
showbug api GET '/orgs/{org}/projects'
showbug api POST '/orgs/{org}/projects' --data '{"name": "Docs site"}'Output and exit codes
- For people. A list prints as a table and one thing prints as
name: valuelines. Any token in the output shows assbp_…and its last four characters, so a token does not end up in a terminal log. --jsonprints the API’s JSON answer on one line to standard output. Errors then go to standard error as JSON. A delete that has no body prints{"ok":true}.- Retries. Reads, deletes and creates are tried again, up to three times, after a network error,
429,502,503or504, waiting as long asRetry-Aftersays. Other changes, such as an update, are not retried, because they could be applied twice.
For example, showbug projects list prints:
ID NAME STATUS ORIGINS
prj_… Marketing site active https://www.example.com
prj_… Docs site active -With --json, a failure looks like this on standard error:
{"error":{"code":"not_found","message":"Not found, or you do not have access to it.","status":404}}The exit code says what kind of failure it was:
| Code | Meaning |
|---|---|
0 | Success. |
1 | The API answered with an error other than 401 or 403, or you answered no to a confirmation. |
2 | Usage error: an unknown command, a missing argument or flag, or a destructive command run without a terminal and without --yes. |
3 | Authentication: there is no token, or the API answered 401 or 403. That includes a token without the scope the command needs. |
4 | Network error: the API could not be reached. |
Scripting
Use --json in scripts and read the answer with jq. The JSON is the same as the REST API’s, so the field names on the REST API page apply.
showbug projects list --json | jq -r '.projects[] | [.id, .name] | @tsv'Retry every failed delivery of a project:
showbug deliveries list "$PROJECT" --status dead --all --json \
| jq -r '.deliveries[].id' \
| while read -r id; do
showbug deliveries retry "$PROJECT" "$id" --json
doneAct on the exit code, and read the error from standard error:
showbug projects get "$PROJECT" --json > project.json 2> error.json
status=$?
if [ "$status" -eq 3 ]; then
echo "The token is missing, expired or not allowed to do this." >&2
elif [ "$status" -ne 0 ]; then
jq -r '.error.code' error.json >&2
fi
exit "$status"A CI job that creates a project for each pull request and prints its key. The token needs only projects:write, and a new project comes with its first key, so no other call is needed. The idempotency key means that re-running the job returns the same project instead of making another.
name: Preview
on: pull_request
jobs:
showbug:
runs-on: ubuntu-latest
steps:
- name: Create a Showbug project for this pull request
env:
SHOWBUG_TOKEN: ${{ secrets.SHOWBUG_TOKEN }}
SHOWBUG_API_URL: https://api.showbugai.com
run: |
npm install --global @showbug/cli
key=$(showbug projects create "PR ${{ github.event.number }}" \
--origin "https://pr-${{ github.event.number }}.preview.example.com" \
--idempotency-key "preview-${{ github.run_id }}" \
--json | jq -r '.keys[0].publicKey')
echo "Showbug key: $key"
echo "SHOWBUG_KEY=$key" >> "$GITHUB_ENV"Destructive commands
A command that deletes or revokes something asks before it runs: keys revoke, origins remove, integrations remove, integrations rotate-secret, connections remove, members remove, invites revoke, and api with DELETE. --help on a command says if it does.
- In a terminal, the command says what it will do and waits for
y. Any other answer cancels it, nothing changes, and the exit code is 1. - Without a terminal, in a script, a CI job or an agent, it refuses to run and exits with code 2 unless you pass
--yes(or-y).
showbug keys revoke "$PROJECT" "$KEY" --yesOnly pass --yes when the ids come from somewhere you trust. Give a token that an agent uses only the write scopes its task needs, so a wrong command is refused by the API as well.