Skip to content

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.

Terminal window
curl -fsSL https://ostrakon.dev/install.sh | sh

The 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:

Terminal window
ostra version

Other ways:

  • Manual download: archives ostra_<version>_<os>_<arch>.tar.gz and SHA256SUMS in the GitHub releases. Verify with sha256sum --ignore-missing -c SHA256SUMS (macOS: shasum -a 256 -c SHA256SUMS). SHA256SUMS comes 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).
Terminal window
ostra update # installs the latest release (vOLD -> vNEW)
ostra update --check # check only: exit code 10 if an update exists

The 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.

Terminal window
source <(ostra completion bash) # bash, current session
source <(ostra completion zsh) # zsh, current session
ostra completion fish | source # fish, current session
ostra completion fish > ~/.config/fish/completions/ostra.fish # fish, permanent

For the other permanent cases (bash, zsh), ostra completion <shell> --help gives the instructions.

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:

Terminal window
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:

Terminal window
mkdir -p ~/.config/ostra
(umask 077; printf '%s' "sk_..." > ~/.config/ostra/key)
ostra config set api_key_file ~/.config/ostra/key

Or 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:

Terminal window
BC_URL=https://ostrakon.example.com/api/v1
BC_KEY=sk_... # your API key
TRIGGER=<trigger-uuid>
Terminal window
# curl
curl -X POST "$BC_URL/triggers/$TRIGGER/events" \
-H "X-API-Key: $BC_KEY" \
-H "Content-Type: application/json" \
-d '{}'
# ostra
ostra events send "$TRIGGER"
Terminal window
# curl
curl -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}}'
# ostra
ostra events send "$TRIGGER" \
--meta source=deploy --meta duration_ms=1840 --meta ok=true

With --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:

Terminal window
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.

Terminal window
# 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 --hook
ostra 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/sh
ostra events send commits --hook \
--meta-str repo="$(basename "$PWD")" --meta-str branch="$(git branch --show-current)"

A shell function (bash, zsh):

Terminal window
hit() { ostra events send pc-hit --hook --meta-str cmd="$1" --meta exit="${2:-0}"; }
Terminal window
# curl
curl -H "X-API-Key: $BC_KEY" "$BC_URL/triggers/$TRIGGER/stats?from=now-24h&interval=1h"
# ostra
ostra 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 sum
ostra 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.

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.

Terminal window
# 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"
# ostra
ostra account set-name Alice
ostra account set-name --clear
ostra account me

Setting 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.

Terminal window
# Every trigger you can read (trigger:stats scope on all triggers)
ostra events stream
# One trigger, by alias or UUID
ostra events stream commits
# One JSON object per line, for jq
ostra 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 --json

A 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.

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.

Terminal window
# Organizations you belong to, then one in detail
ostra tenants list
ostra 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 id
ostra tenants members list "$TENANT"
ostra tenants members set-role "$TENANT" "$MEMBER" viewer
ostra tenants members remove "$TENANT" "$MEMBER"
ostra tenants leave "$TENANT"
# Invitations: create prints the token and the link, the invitee accepts
ostra tenants invitations create "$TENANT" --role member --expires-in 48
ostra 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.

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.

Terminal window
# All your panes, or those of one trigger or group
ostra panes list
ostra panes list --trigger "$TRIGGER"
ostra panes list --group "$GROUP"
# Create, change, delete
ostra panes create --trigger "$TRIGGER" --name "Hourly activity" \
--viz heatmap --dimension metadata.hour --cross metadata.weekday --interval 1h
ostra panes update "$PANE" --width full --range 7d
ostra 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.

  • A server or container where you cannot install anything: curl is 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.

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)