Skip to content

Command line

airfone works with the workspace you sign in to: apps and keys, webhooks, request logs, your balance, and any API endpoint.

macOS and Linux:

Terminal window
curl -fsSL https://dl.airfone.app/install.sh | sh

Windows (PowerShell):

Terminal window
irm https://dl.airfone.app/install.ps1 | iex

It installs into ~/.airfone/bin, checks the download’s SHA-256 and adds the folder to your PATH. Run it again to upgrade, or run airfone upgrade. Set AIRFONE_VERSION to install a set version and AIRFONE_INSTALL_DIR to install somewhere else.

Terminal window
airfone login

This opens your browser and you approve the sign-in there. Use --no-browser on a machine without one: it prints the address to open instead.

To sign in without a browser at all, create a personal access token in the console under Personal access tokens (it starts with afp_) and pass it:

Terminal window
airfone login --token afp_...

airfone whoami shows who you are signed in as and the workspace in use. airfone logout signs out and revokes this machine’s token.

Terminal window
airfone workspaces # the workspaces you belong to
airfone switch "My Shop" # name, handle or id

Every command acts on the selected workspace. Pass -w <workspace> to act on another one for a single command.

CommandWhat it does
airfone apps listYour apps.
airfone apps create <name>Create an app.
airfone keys list <app>An app’s keys. <app> is its name or id.
airfone keys create <app>Create a key. The secret is shown once.
airfone keys roll <key>A new secret. The old one keeps working for an hour (--grace-seconds).
airfone keys revoke <key>Stop a key at once.
airfone webhooks listYour webhook endpoints.
airfone webhooks create <url>Add an endpoint. Its signing secret is shown once.
airfone webhooks test <id>Send a test event.
airfone webhooks delete <id>Remove an endpoint.
airfone webhooks eventsEvent types you can subscribe to.
airfone logsRecent API requests to the workspace.
airfone balanceWallet balance and recent transactions.
airfone api <path>Call any endpoint, signed in.
airfone upgradeInstall the newest version.
airfone completion <shell>Shell completions.
Terminal window
# A test-mode secret key (the default)
airfone keys create "My Shop"
# A live publishable key for the website widget, allowed on two sites
airfone keys create "My Shop" --type publishable --mode live \
--domain shop.com.np --domain www.shop.com.np
# A restricted key that can only read calls and write messages
airfone keys create "My Shop" --type restricted \
--scope calls:read --scope messages:write

--type is secret, restricted or publishable. --mode is test or live. See Concepts for what each kind of key may do.

Terminal window
airfone webhooks create https://shop.com.np/airfone \
--event call.ended --event message.received

Leave out --event to receive every event. Copy the signing secret it prints: it is not shown again. Receive webhooks shows how to check the signature.

Terminal window
airfone logs -n 50 # the last 50 requests
airfone logs -f # keep printing new ones
airfone logs --errors # only status 400 and up
Terminal window
airfone api /v1/apps
airfone api /v1/webhook-endpoints -X POST -f url=https://shop.com.np/airfone
airfone api /v1/knowledge/sources -X POST -d @source.json

-X sets the method (GET by default). -d sends a JSON body: inline, @file.json, or - for stdin. -f name=value adds a text field and -F name=value a typed one (numbers, true, false and null are sent as JSON).

Add --json to any command to get the API’s JSON instead of a table.

In CI, set the token and workspace as environment variables instead of signing in. Nothing is written to disk:

Terminal window
export AIRFONE_TOKEN=afp_...
export AIRFONE_WORKSPACE=my-shop
airfone api /v1/usage --json

AIRFONE_CONFIG_DIR moves where a signed-in session is kept.

Exit codes: 0 worked, 1 failed, 4 not signed in or the token is no longer valid, 5 not allowed, 6 not found, 130 stopped with Ctrl+C.

Building a connector uses its own tool, from the @airfone/connector package. See Build a connector.