Command line
airfone works with the workspace you sign in to: apps and keys, webhooks, request logs, your balance, and any API endpoint.
Install
Section titled “Install”macOS and Linux:
curl -fsSL https://dl.airfone.app/install.sh | shWindows (PowerShell):
irm https://dl.airfone.app/install.ps1 | iexIt 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.
Sign in
Section titled “Sign in”airfone loginThis 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:
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.
Pick a workspace
Section titled “Pick a workspace”airfone workspaces # the workspaces you belong toairfone switch "My Shop" # name, handle or idEvery command acts on the selected workspace. Pass -w <workspace> to act on another one for a single command.
Commands
Section titled “Commands”| Command | What it does |
|---|---|
airfone apps list | Your 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 list | Your 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 events | Event types you can subscribe to. |
airfone logs | Recent API requests to the workspace. |
airfone balance | Wallet balance and recent transactions. |
airfone api <path> | Call any endpoint, signed in. |
airfone upgrade | Install the newest version. |
airfone completion <shell> | Shell completions. |
# A test-mode secret key (the default)airfone keys create "My Shop"
# A live publishable key for the website widget, allowed on two sitesairfone 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 messagesairfone 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.
Webhooks
Section titled “Webhooks”airfone webhooks create https://shop.com.np/airfone \ --event call.ended --event message.receivedLeave 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.
Request logs
Section titled “Request logs”airfone logs -n 50 # the last 50 requestsairfone logs -f # keep printing new onesairfone logs --errors # only status 400 and upAny endpoint
Section titled “Any endpoint”airfone api /v1/appsairfone api /v1/webhook-endpoints -X POST -f url=https://shop.com.np/airfoneairfone 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).
Scripts and CI
Section titled “Scripts and CI”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:
export AIRFONE_TOKEN=afp_...export AIRFONE_WORKSPACE=my-shopairfone api /v1/usage --jsonAIRFONE_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.
Connectors
Section titled “Connectors”Building a connector uses its own tool, from the @airfone/connector package. See Build a connector.