CLI (ostra)
ostra is the Ostrakon command-line client. The API remains the product: everything ostra does can also be done with curl. This guide shows both side by side, for the same request.
Full reference of commands and options: docs/cli/ostra.md.
Install
Section titled “Install”curl -fsSL https://ostrakon.dev/install.sh | shThe script installs the latest release of ostrakon-app/ostra into ~/.local/bin (no sudo) after verifying the archive checksum. Linux and macOS, amd64 and arm64. Check the installation:
ostra versionOther ways:
- Manual download: archives
ostra_<version>_<os>_<arch>.tar.gzandSHA256SUMSin the GitHub releases. Verify withsha256sum --ignore-missing -c SHA256SUMS(macOS:shasum -a 256 -c SHA256SUMS).SHA256SUMScomes from the same release as the archives: it detects a corrupted file, not a compromised release. - Go:
go install github.com/ostrakon-app/ostra/cmd/ostra@latest(or@v0.9.0).
Update ostra
Section titled “Update ostra”ostra update # installs the latest release (vOLD -> vNEW)ostra update --check # check only: exit code 10 if an update existsThe command reads the latest release of the ostra repository, verifies the archive checksum, then replaces the binary in place (written alongside, then renamed). If the binary is in a non-writable directory (system path, package manager), nothing is changed: rerun install.sh or use sudo. A dev build (dev, git describe) refuses without --force. No automatic update, OSTRA_BASE_URL changes the download root. Details: docs/cli/ostra.md.
Shell completion
Section titled “Shell completion”source <(ostra completion bash) # bash, current sessionsource <(ostra completion zsh) # zsh, current sessionostra completion fish | source # fish, current sessionostra completion fish > ~/.config/fish/completions/ostra.fish # fish, permanentFor the other permanent cases (bash, zsh), ostra completion <shell> --help gives the instructions.
Authenticate with an API key
Section titled “Authenticate with an API key”For a script, a hook or a server, use an API key (see API Keys). Create it in the web interface (Settings > Developer > API keys) or with ostra after a ostra login:
ostra api-keys create --name my-script --scopes "trigger:hit:*"The key is shown only once. The trigger:hit:<id> scope (or trigger:hit:*) is enough to send events.
Store it in a file readable only by you, then point ostra at it:
mkdir -p ~/.config/ostra(umask 077; printf '%s' "sk_..." > ~/.config/ostra/key)ostra config set api_key_file ~/.config/ostra/keyOr pass it through the environment: export OSTRA_API_KEY=sk_.... Avoid --api-key sk_...: command-line arguments are visible to the other users of the machine.
With curl, the key goes in the X-API-Key header. In the following examples:
BC_URL=https://ostrakon.example.com/api/v1BC_KEY=sk_... # your API keyTRIGGER=<trigger-uuid>Recipe 1: a single event
Section titled “Recipe 1: a single event”# curlcurl -X POST "$BC_URL/triggers/$TRIGGER/events" \ -H "X-API-Key: $BC_KEY" \ -H "Content-Type: application/json" \ -d '{}'
# ostraostra events send "$TRIGGER"Recipe 2: typed metadata
Section titled “Recipe 2: typed metadata”# curlcurl -X POST "$BC_URL/triggers/$TRIGGER/events" \ -H "X-API-Key: $BC_KEY" \ -H "Content-Type: application/json" \ -d '{"metadata": {"source": "deploy", "duration_ms": 1840, "ok": true}}'
# ostraostra events send "$TRIGGER" \ --meta source=deploy --meta duration_ms=1840 --meta ok=trueWith --meta, a value that is valid JSON is sent typed: 1840 is a number, true a boolean, deploy a string. To force a string (a 1.0 version, a numeric identifier), use --meta-str version=1.0. For a full object, --meta-json '{"a": 1}', or --meta-json - to read it from standard input:
echo '{"source": "cron", "n": 3}' | ostra events send "$TRIGGER" --meta-json -Recipe 3: send without ever getting in the way (git hook, shell function)
Section titled “Recipe 3: send without ever getting in the way (git hook, shell function)”A hook must neither slow down your command nor fail if the network is down.
# curl: in the background, capped at 3 s, silent (jq escapes the values)curl -fsS -m 3 -X POST "$BC_URL/triggers/$TRIGGER/events" \ -H "X-API-Key: $BC_KEY" \ -H "Content-Type: application/json" \ -d "$(jq -nc --arg repo "$(basename "$PWD")" --arg branch "$(git branch --show-current)" \ '{metadata: {repo: $repo, branch: $branch}}')" >/dev/null 2>&1 &
# ostra: an alias instead of the UUID, then --hookostra config set alias.commits "$TRIGGER"ostra events send commits --hook \ --meta-str repo="$(basename "$PWD")" --meta-str branch="$(git branch --show-current)"--hook makes the send silent, always with exit code 0, and detaches it into the background (returns in a few milliseconds). It adds host and ts to the metadata. Failures are not lost: they are appended to ~/.local/state/ostra/failed.log (the last 200 lines). With --strict, ostra stays in the foreground and returns the real exit codes.
A git hook, .git/hooks/post-commit:
#!/bin/shostra events send commits --hook \ --meta-str repo="$(basename "$PWD")" --meta-str branch="$(git branch --show-current)"A shell function (bash, zsh):
hit() { ostra events send pc-hit --hook --meta-str cmd="$1" --meta exit="${2:-0}"; }Read your data
Section titled “Read your data”# curlcurl -H "X-API-Key: $BC_KEY" "$BC_URL/triggers/$TRIGGER/stats?from=now-24h&interval=1h"
# ostraostra events stats "$TRIGGER" --from now-24h --interval 1h
# the same with an alias (see recipe 3)ostra events stats commits --from now-24h --interval 1h
# sum a numeric metadata key (BEC-312): the value column holds the sumostra events stats "$TRIGGER" --from now-168h --interval 1d --measure sum:cost_usd--measure takes count (default) or sum:<key>: with a sum the table and the CSV get a Value column and the header shows the total. An invalid measure is reported with the message of the API (400).
Every command that takes a trigger (events send, events stream, events list, events stats and triggers get, update, delete, metadata) accepts an alias or a UUID. An unknown alias fails before any network call. --aliases-file exists on events send only; the other commands read aliases_file and the aliases (alias.<name>) of the config.
Reading requires the trigger:stats:<id> scope. When the output is redirected (pipe), ostra writes JSON; in a terminal, a table. -o json, -o table or -o csv (tabular commands) force the format.
Set your display name
Section titled “Set your display name”Members of your organizations and the people you invite see your account id by default. A display name replaces it. It is optional, up to 20 characters (letters, digits, space, -, _, .), and not unique.
# curl (BC_TOKEN: the access token of your login session)curl -X PATCH -H "Authorization: Bearer $BC_TOKEN" -H "Content-Type: application/json" \ -d '{"display_name": "Alice"}' "$BC_URL/auth/me"
# ostraostra account set-name Aliceostra account set-name --clearostra account meSetting the name is JWT only: with an API key, ostra account set-name fails locally with exit code 3. ostra account me shows the name when there is one.
Follow events live
Section titled “Follow events live”# Every trigger you can read (trigger:stats scope on all triggers)ostra events stream
# One trigger, by alias or UUIDostra events stream commits
# One JSON object per line, for jqostra events stream commits --json | jq -r '.metadata.cmd'
# Each event on its own, with its id and full metadata (debugging a hook)ostra events stream commits --events --jsonA line per event in a terminal: time, trigger name, metadata summary (a batch shows up as one batch of <n> events line). --json (or a redirected output) prints the server messages as they come, one per line. Heartbeats are never printed. After a network drop or a server restart ostra reconnects with a growing delay (1 s to 30 s) and says so on stderr (-q silences it). The server does not number its events, so Last-Event-ID resume is not possible: what happened while disconnected is not replayed. --events follows each event individually (one line per event, --json for the full event with its id and metadata) instead of aggregated batches, like tail -f: the server caps it per connection (100 events per second by default), prints server dropped <n> events on stderr when it drops some, and events sent in the instant you connect can be missed. A local failure (the refreshed token cannot be written to disk) stops with exit code 1 and names the file, with no retry. Ctrl+C stops with exit code 0; a missing scope exits 3, a bad or expired key 2 (run ostra auth login). --timeout does not apply to the stream itself.
Manage organizations
Section titled “Manage organizations”ostra tenants covers organizations, their members and their invitations, with the same routes as the app (see Organizations (Tenants)). It works with a login session or an API key, each route checking its scope or your role in the organization: a refusal prints the API message and exits with code 3.
# Organizations you belong to, then one in detailostra tenants listostra tenants get "$TENANT"
# Create, rename, delete (asks for confirmation, --yes for scripts)ostra tenants create "Acme" --color "#6366f1"ostra tenants update "$TENANT" --name "Acme Corp"ostra tenants delete "$TENANT" --transfer-triggers
# Members: the first column of "members list" is the member idostra tenants members list "$TENANT"ostra tenants members set-role "$TENANT" "$MEMBER" viewerostra tenants members remove "$TENANT" "$MEMBER"ostra tenants leave "$TENANT"
# Invitations: create prints the token and the link, the invitee acceptsostra tenants invitations create "$TENANT" --role member --expires-in 48ostra tenants invitations list "$TENANT"ostra tenants invitations revoke "$TENANT" "$INVITATION"ostra tenants invitations show "$TOKEN"ostra tenants invitations accept "$TOKEN"tenants create takes the name as an argument, --name still works (both with different values is an error). tenants delete asks [y/N] unless you pass --yes; without --transfer-triggers the triggers are deleted with their events. --description "" and --color "" clear the value. The owner cannot leave: delete the organization instead.
Manage panes
Section titled “Manage panes”ostra panes lists, creates, updates and deletes the Explore panes (see Panes). Panes are JWT only: with an API key, every ostra panes command fails locally with panes require a login session (ostra auth login), API keys are not accepted (exit code 3), run ostra login first.
# All your panes, or those of one trigger or groupostra panes listostra panes list --trigger "$TRIGGER"ostra panes list --group "$GROUP"
# Create, change, deleteostra panes create --trigger "$TRIGGER" --name "Hourly activity" \ --viz heatmap --dimension metadata.hour --cross metadata.weekday --interval 1hostra panes update "$PANE" --width full --range 7dostra panes delete "$PANE"panes update keeps the fields of the config you do not pass (it reads the pane first, the API replaces the whole config). Reordering panes is only available in the app.
When to prefer curl
Section titled “When to prefer curl”- A server or container where you cannot install anything:
curlis enough, it is the same API. - Zero dependencies: a one-line script in a cron or a CI, without downloading a binary.
- A language that already has its HTTP client: call the API directly.
Prefer ostra when you send from a workstation or a hook (aliases, typed metadata without hand-escaping JSON, detached sending, failure log) or when you manage triggers, groups and keys from the terminal.
Exit codes
Section titled “Exit codes”| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | General error (400, 5xx, invalid option, network) |
| 2 | Unauthenticated (401) |
| 3 | Forbidden (403) |
| 4 | Not found (404) |
| 5 | Conflict (409) |
| 6 | Rate limited (429) |
| 7 | Timeout (--timeout, 10 s by default) |
| 10 | update --check: an update exists (not an error) |