CLI

Track parcels, manage webhooks and check signatures from your terminal.

Embed
Preview of the card
<a href="https://trackified.net/docs/cli"><img src="https://trackified.net/docs/_api/public/orgs/e2a7773e-db9e-41cb-bd59-bd248745cac3/spaces/9d63a5d4-feb0-4803-84a5-dc68639362a6/pages/eec689f9-73ea-48fd-b6ce-91e7d363bddd/social-card.svg?v=3e7ae33eec8b" alt="CLI" width="600" height="315"></a>

trackified is the command-line client for the API, built on the Go library. Source: trackified/trackified-cli.

Install

brew install trackified/tap/trackified

Each release archive has a signed build-provenance attestation. gh attestation verify checks that the file was built from the trackified-cli repo.

Check it works:

trackified version

Sign in

The CLI reads your key from TRACKIFIED_API_KEY first:

export TRACKIFIED_API_KEY=live_...

Or save the key once with trackified login. It asks for the key without echoing it, checks it against the API, and saves it with file mode 0600 to trackified/config.json in your OS config directory (~/Library/Application Support on macOS, ~/.config on Linux, %AppData% on Windows).

trackified login

login rejects current keys

trackified login in versions 0.1.0 and 0.2.0 only accepts keys that start with tk_, so it rejects live_… and test_… keys. Use TRACKIFIED_API_KEY until a fixed release is out.

TRACKIFIED_BASE_URL points the CLI at another API host. It may end in /v1.

Commands

Command

What it does

login

Check an API key and save it.

track <number> [--carrier c] [--custom-id id]

Start tracking a parcel and print it.

get <id>

Show a tracking with its events.

list [--status s] [--carrier c] [--limit n] [--all]

List trackings. --all fetches every page.

watch <id> [--interval 60s]

Print new events until the parcel is delivered or returned.

retrack <id>

Check the carrier again now.

stop <id>

Stop tracking a parcel.

carriers [search]

List the carriers we track, or search the full catalog.

detect <number>

Guess the carrier of a tracking number.

resolve <name>

Map a carrier or service name to our carrier id.

webhooks list

List webhook endpoints.

webhooks add <url> [--events a,b]

Add an endpoint and print its signing secret.

webhooks update <id> [--url u] [--events a,b] [--enable | --disable]

Change an endpoint, or pause it.

webhooks rotate-secret <id> [--expires-in 24h]

Issue a new signing secret.

webhooks rm <id>

Remove an endpoint.

webhooks test <id>

Print a signed sample event, without sending it.

usage

This month's usage and limits.

health

Check that the API is up. Needs no key.

verify-webhook --secret s --header h --body-file f

Check a webhook signature locally.

version

Print the CLI and Go library versions.

Flags can go before or after the arguments.

track

trackified track 1Z999AA10123456784 --custom-id order_1042
trackified track 9434650110837017316201 --carrier usps

Leave out --carrier and we detect it from the number. If we can't, run trackified detect and pass the carrier.

get

trackified get trk_...

Prints the status, the estimated delivery or delivery time, any exception, then every event, newest first.

list

trackified list                         # the 50 newest trackings
trackified list --status in_transit --limit 100
trackified list --carrier usps --all    # every page

--limit is the page size, 1 to 100. Without --all, the CLI tells you when there are more.

watch

trackified watch trk_... --interval 5m

Polls the tracking and prints each new event, oldest first. It stops when the parcel is delivered or returned, or when you press Ctrl-C. --interval is at least 5s; the default is 60s. Trackified itself checks the carrier on a schedule (every 30 minutes once out for delivery), so polling faster than that rarely shows anything new.

retrack and stop

trackified retrack trk_...   # queue a fresh carrier check, within a minute
trackified stop trk_...      # stop tracking

carriers and detect

trackified carriers           # every carrier we track
trackified carriers "royal"   # search the full catalog, including carriers we don't track yet
trackified detect 1Z999AA10123456784

detect prints each candidate carrier with its confidence and the reason, best first.

trackified resolve USPS Priority Mail   # usps  USPS  (confidence 0.97, matched alias)
trackified resolve dhl_express

resolve maps a carrier name, a service name or another provider's slug to the id you pass as --carrier. Quotes are optional. It exits with status 1 when no carrier we serve matches. track --carrier takes these names directly too.

webhooks

trackified webhooks add https://example.com/webhooks/trackified \
  --events tracking.status_changed,tracking.delivered
trackified webhooks list
trackified webhooks test wh_...
trackified webhooks rm wh_...

add prints the signing secret once: store it. Leave out --events and the endpoint gets tracking.updated and tracking.delivered.

trackified webhooks update wh_... --events tracking.status_changed
trackified webhooks update wh_... --disable      # pause it; --enable turns it back on
trackified webhooks rotate-secret wh_... --expires-in 48h

update needs at least one of --url, --events, --enable or --disable; the secret doesn't change. rotate-secret prints the new secret once. The old one keeps working for --expires-in, in whole hours from 0h to 168h (default 24h); 0h drops it at once. See Rotate the secret.

usage

trackified usage

Prints your plan, this month's period, trackings used and left, your rate limit, webhook deliveries and trackings per carrier.

verify-webhook

trackified verify-webhook \
  --secret "$TRACKIFIED_WEBHOOK_SECRET" \
  --header "t=1792560000,v1=5f2c..." \
  --body-file body.json

--secret defaults to TRACKIFIED_WEBHOOK_SECRET. --body-file - reads the body from stdin. --tolerance changes the allowed clock difference (default 5m0s). A header with several v1= signatures is valid if any matches. When the signature is invalid, the command prints why (missing, malformed, timestamp or mismatch; reason with --json) and exits with status 1.

health

trackified health   # API status: ok

JSON output

Every command takes --json and prints JSON instead of a table, with the same field names as the API. Pipe it into jq:

# Tracking numbers of everything in exception
trackified list --status exception --all --json | jq -r '.[].tracking_number'

# The latest event of one parcel
trackified get trk_... --json | jq '.events[0]'

# Trackings left this month
trackified usage --json | jq '.trackings_remaining'

# Fail a script on a bad signature
trackified verify-webhook --body-file body.json --header "$SIG" --json   # {"valid": false, "reason": "timestamp"}

list --json prints an array of trackings. watch --json prints each new event as its own JSON object.

Exit status

Code

Meaning

0

Success.

1

The API returned an error, verify-webhook found an invalid signature, or resolve found no match.

2

Wrong usage: an unknown command, a missing argument or a bad flag.

Updated