# workers

> The command line for an app's AirHost, AirFeedback, AirPayment, AirRouter, AirTraffic and AirKnowledge: deploy Workers, query databases, manage app users and cron jobs, read logs, feedback, crashes, purchases, AI calls, analytics and knowledge bases.

Source: https://air.build/docs/cli/workers/

`workers` is the command line an Agent uses for the services behind a Project's app. One command covers six products:

| Product | Command groups | What it is |
| --- | --- | --- |
| **AirHost** | `deploy`, `list`, `files`, `cat`, `pull`, `delete`, `logs`, `db`, `users`, `cron` | Hosting: Workers (backends and websites), named databases, app users and scheduled jobs |
| **AirFeedback** | `feedback`, `app-key` | What the app's users send, and the app's crashes, symbolicated with uploaded dSYMs |
| **AirPayment** | `purchases`, `app-key` | Recorded purchases, and keys for a server that reports purchases paid outside the App Store |
| **AirRouter** | `ai` | The app's AI calls: status, usage, request history and test calls |
| **AirTraffic** | `traffic`, `app-key` | Product analytics: visitors, trends, funnels, retention, raw events and SQL |
| **AirKnowledge** | `knowledge` | The app's knowledge bases, read-only |

It is installed for Agents in both cloud Teams and Mac Teams (see [Choose where your Agents run](https://air.build/docs/get-started/where-agents-run/)). Every command writes JSON to standard output and failures to standard error. No command builds application code.

## Synopsis

```text
workers [--project PROJECT_ID] COMMAND [ARGUMENTS] [FLAGS] --environment NAME

  deploy NAME [--dir PATH] [--database NAME]
  list | files NAME | cat NAME FILE | pull NAME [--out DIR]
  delete NAME --confirm | logs NAME
  db SQL [--database NAME] [--param VALUE]...
  db list | db create NAME | db delete NAME --confirm
  users [--limit N] [--offset N] | users ban|unban|delete ID
  users mint-test --worker NAME [--label LABEL] [--grant]
  cron WORKER | cron set WORKER JOB SCHEDULE | cron delete WORKER JOB
  feedback list|show|images|done|summary …
  feedback dsyms list|upload … | feedback crash-settings [--enabled on|off]
  purchases list|show … | purchases keys [list|create NAME|revoke KEY_ID --confirm]
  app-key
  ai status|usage|requests|request|call …
  traffic web|definitions|events|trends|funnel|retention|query|sql|settings …
  knowledge list|files|read|grep …
  keys list|create|revoke                  (refused in a Team; see Management keys)
```

`workers --help` prints the full list; `workers --version` prints the version.

## Before every command

| What | How | Notes |
| --- | --- | --- |
| The environment | `--environment NAME` on every command, or `export WORKERS_ENVIRONMENT=NAME` once | Required on every resource command. An app has one existing environment, normally `production`; there is no command to create another |
| The Project | Run `workers` inside the Project's directory | `--project PROJECT_ID` (or `--project=PROJECT_ID`) picks a Project from anywhere else |
| Sign-in | Nothing to do | An Agent's Team supplies it |

Without an environment, the command stops with `Every resource command requires --environment NAME or WORKERS_ENVIRONMENT.` The examples on this page assume `export WORKERS_ENVIRONMENT=production`.

## AirHost: Workers

A Worker is a named backend or website. Its address is `https://NAME.airhost.site` (Workers made earlier keep `NAME.apps.air.build`).

| Command | What it does |
| --- | --- |
| `deploy NAME [--dir PATH] [--database NAME]` | Uploads the source folder as Worker `NAME`, creating it or replacing its code |
| `list` | Lists the environment's Workers |
| `files NAME` | Lists the files of the Worker's current source |
| `cat NAME FILE` | Prints one file of the current source |
| `pull NAME [--out DIR]` | Downloads the current source into a new folder |
| `delete NAME --confirm` | Deletes the Worker |
| `logs NAME` | Streams the Worker's logs as they happen; press Ctrl-C to stop |

| Flag | Value | Default | Meaning |
| --- | --- | --- | --- |
| `--dir` | Folder path | — | The source folder to upload, as it is. Nothing is compiled or bundled |
| `--database` | Database name | — | The named database the Worker uses |
| `--out` | Folder path | — | The new folder `pull` writes the source into |
| `--confirm` | — | — | Required by `delete` |

Deploy errors:

| Message | What to do |
| --- | --- |
| `compressed source exceeds 10 MiB` / `source archive exceeds 64 MiB unpacked` | Make the folder smaller: leave out what the Worker doesn't serve or run |
| `source must contain regular files only: …` | Remove the symbolic link or special file it names |
| `unsafe path in source archive` / `duplicate source file` | Rename the file it names |
| `deletion requires --confirm` | Add `--confirm` |

## AirHost: databases

Databases belong to the environment, not to a Worker: deleting a Worker doesn't delete its database.

| Command | What it does |
| --- | --- |
| `db SQL [--database NAME] [--param VALUE]...` | Runs one SQL statement and prints the result |
| `db list` | Lists the environment's databases |
| `db create NAME` | Creates a database |
| `db delete NAME --confirm` | Deletes a database and its data |

| Flag | Value | Default | Meaning |
| --- | --- | --- | --- |
| `--database` | Database name | — | Which database the statement runs on |
| `--param` | Text, repeatable | — | A value for each `?` in the statement, in order |
| `--confirm` | — | — | Required by `db delete` |

`db` with no SQL and no `list`, `create` or `delete` stops with `db requires SQL or list/create/delete`.

## AirHost: app users

People who sign in to the app are app users. Like databases, they belong to the environment, not to one Worker.

| Command | What it does |
| --- | --- |
| `users [--limit N] [--offset N]` | Lists app users, one page at a time |
| `users ban ID` | Bans the user |
| `users unban ID` | Lifts the ban |
| `users delete ID` | Deletes the user |
| `users mint-test --worker NAME [--label LABEL] [--grant]` | Makes a test user's sign-in for one Worker |

| Flag | Value | Default | Meaning |
| --- | --- | --- | --- |
| `--limit` | Number | — | Users per page |
| `--offset` | Number | — | How many users to skip |
| `--worker` | Worker name | — | Required by `mint-test` (`mint-test requires --worker`) |
| `--label` | Text | — | A name for the test user |
| `--grant` | — | Off | Return a sign-in grant instead |

## AirHost: cron jobs

A Worker can run on a schedule. Jobs are named per Worker.

| Command | What it does |
| --- | --- |
| `cron WORKER` | Lists the Worker's jobs |
| `cron set WORKER JOB SCHEDULE` | Sets job `JOB` to a cron schedule |
| `cron delete WORKER JOB` | Deletes the job |

Quote the schedule so the shell passes it as one argument.

## AirFeedback: feedback and crashes

Each thing a user sends from the app, and each app crash, is one feedback entry. A crash is an entry with category `crash`, and belongs to a crash issue.

| Command | What it does |
| --- | --- |
| `feedback list [FLAGS]` | Lists entries, a page at a time |
| `feedback show ID` | One entry. For a crash: its issue and the whole report, symbolicated |
| `feedback images ID --out DIR` | Saves the entry's images into a new folder |
| `feedback done ID [--undo]` | Marks the entry done; `--undo` opens it again. On a crash, marks its whole issue fixed, with every crash in it so far |
| `feedback summary [--timezone IANA] [--verified-only]` | A summary of the entries |
| `feedback dsyms list [--limit N] [--before CURSOR]` | Lists the uploaded dSYMs |
| `feedback dsyms upload PATH…` | Uploads dSYMs, which crash reports are symbolicated with |
| `feedback crash-settings [--enabled on]` / `[--enabled off]` | Shows whether crashes are recorded; `--enabled` turns it on or off |

`feedback list` flags, which can be combined:

| Flag | Value | Meaning |
| --- | --- | --- |
| `--limit` | Number | Entries per page |
| `--before` | Cursor | The next-page cursor the previous page returned |
| `--category` | `problem`, `request`, `other`, `uncategorized`, `crash` | Only entries of this category |
| `--kind` | `crash`, `feedback` | Only crashes, or only feedback |
| `--issue` | Crash issue ID (a UUID) | Every crash in one issue |
| `--sender` | `people`, `agents` | What the app's users sent, or what Agents sent |
| `--status` | `open`, `done` | Only open or only done entries |
| `--query` | Text, 1 to 200 characters | Search the entries' text and details |
| `--verified-only` | — | Only verified entries. Also works on `feedback summary` |

`feedback dsyms upload` takes `.dSYM` bundles, folders that hold them (such as an `.xcarchive` or a build folder), a `.zip` of them, or DWARF files. It prints `uploaded`, `present`, `failed` (each with `uuid`, `code` and `reason`), `evicted` and `requeued`, and fails with `N dSYM uploads failed (listed under "failed")` when any did. A TestFlight or App Store build made with [`runbuild --sign`](https://air.build/docs/cli/runbuild/) uploads its dSYMs by itself; upload by hand only for builds made elsewhere.

Feedback errors:

| Message | What to do |
| --- | --- |
| `images requires --out DIR` | Add `--out` with a folder that doesn't exist yet |
| `--issue requires a crash issue id (a UUID)` | Take the issue ID from a crash entry |
| `--query must be 1 to 200 characters` | Shorten the search text |
| `--verified-only only applies to feedback list and feedback summary` | Drop it from other commands |
| `--enabled is on or off` | Use `on` or `off` |
| `feedback dsyms requires list or upload` | Add `list` or `upload` |
| `feedback dsyms upload requires a .dSYM bundle, a folder of .dSYM bundles, a .zip or a DWARF file` | Point it at the dSYMs, not at the app |
| `workers: … has no DWARF folder; skipped` / `… is a Mach-O binary, not a dSYM DWARF file` / `… has no LC_UUID; skipped` | That path is not a usable dSYM. Build with debug symbols in a separate dSYM file and upload that |
| `no dSYM with a UUID found in ….dSYM/Contents/Resources/DWARF/; pass its .dSYM bundle instead` | Pass the `.dSYM` bundle it names |

## AirPayment: purchases

| Command | What it does |
| --- | --- |
| `purchases list [--limit N] [--before CURSOR]` | Lists recorded purchases; `--before` takes the previous page's next cursor |
| `purchases show ID` | One purchase |
| `purchases keys` (or `purchases keys list`) | Lists the keys made with `create` for a server that reports purchases |
| `purchases keys create NAME` | Makes a key for the app's own server to report purchases paid outside the App Store. Prints its secret once |
| `purchases keys revoke KEY_ID --confirm` | Revokes the key at once: reports signed with it stop |

A Worker on AirHost has its own purchase key, managed by AirHost: it isn't listed, can't be revoked, and ends when the Worker is deleted.

| Message | What to do |
| --- | --- |
| `purchases keys create requires one NAME, e.g. purchases keys create stripe-server` | Give the key one name |
| `purchases keys revoke requires a KEY_ID` | Take the ID from `purchases keys` |
| `revoking requires --confirm: reports under this key stop at once` | Add `--confirm` when you mean it |
| `this key belongs to an AirHost Worker and is managed by AirHost: it can't be revoked, and stops when the Worker is deleted (workers delete NAME --confirm)` | Nothing to revoke |

> [!WARNING]
> `purchases keys create` prints the key's secret once. Copy it then; nothing shows it again.

## The app's public key

`workers app-key` prints the environment's public App Key, the key the app reports with, and the addresses it reports to.

## AirRouter: AI calls

| Command | What it does |
| --- | --- |
| `ai status` | Whether paid calls can run now: `payable`, `reason`, `dailyLimitUSD`, `spentTodayUSD` |
| `ai usage [--days N] [--users N]` | Calls and spend |
| `ai requests [FLAGS]` | Recent calls |
| `ai request ID` | One call |
| `ai call PROVIDER PATH [--data FILE] [--user ID] [--method METHOD]` | Sends one real call through AirRouter and prints the result. `--data -` reads stdin |

| Flag | Command | Value | Default | Meaning |
| --- | --- | --- | --- | --- |
| `--days` | `usage` | Number | — | How many days to cover |
| `--users` | `usage` | Number | — | How many app users to show |
| `--limit` | `requests` | Number | — | Calls per page |
| `--before` | `requests` | RFC 3339 time, such as a call's `createdAt` | — | Calls before this time |
| `--user` | `requests`, `call` | App user ID | — | Only this user's calls; on `call`, the user the call is recorded for |
| `--provider` | `requests` | Provider name, as `ai requests` shows it | — | Only this provider's calls |
| `--failed` | `requests` | — | Off | Only failed calls |
| `--data` | `call` | File path, or `-` for standard input | — | The request body, one JSON object |
| `--method` | `call` | `GET`, `POST`, `PUT`, `PATCH`, `DELETE` | — | The HTTP method |

`ai call` prints `{status, requestId, costStatus, costUSD, balanceUSD, error, body}`. Look a call up later with `ai request ID`.

> [!WARNING]
> `ai call` is a real, paid call: its cost comes out of the AirRouter Balance. The CLI has no commands for the balance or the daily limit.

| Message | What to do |
| --- | --- |
| `(AirRouter is off for this app; only the owner can turn it on)` | AirRouter is off for the Project; it has to be turned on in AirBuild |
| `ai call requires PROVIDER PATH` | Give the provider and the path on its API |
| `--data must hold one JSON object` | Fix the body file |
| `--method must be GET, POST, PUT, PATCH or DELETE` | Use one of those |
| `--before must be an RFC 3339 time, such as a request's createdAt` | Pass a time such as `2026-11-18T09:00:00Z` |

## AirTraffic: analytics

Each read prints JSON. All reads take:

| Flag | Value | Meaning |
| --- | --- | --- |
| `--from` | `-7d`, `-24h`, `-3m`, `-1y`, `today`, or an ISO date | Start of the range |
| `--to` | Same forms | End of the range |
| `--timezone` | IANA zone such as `Asia/Shanghai` | Time zone for days and weeks |

| Command | What it does |
| --- | --- |
| `traffic definitions` | What the app has sent: events and properties |
| `traffic web [--from -7d]` | Website overview |
| `traffic events [--event E] [--person ID] [--limit N] [--before CURSOR]` | The raw events |
| `traffic trends --event E[,E…] [FLAGS]` (or `--event all`) | A number per interval for one to ten events |
| `traffic funnel --steps A,B[,…] [FLAGS]` | How many get from each step to the next (two to ten steps) |
| `traffic retention --start E --return E [FLAGS]` (or `--return all`) | How many come back after a first event |
| `traffic query --data FILE` | Any query, as one JSON object; `--data -` reads stdin |
| `traffic sql "SELECT …"` | One SQL statement, 1 to 20,000 characters |
| `traffic settings [--identity MODE]` | Shows or sets the identity mode: `anonymous` or `identified` |

| Flag | Commands | Value | Meaning |
| --- | --- | --- | --- |
| `--event` | `trends`, `events` | Event name, such as `'$pageview'`; `trends` also takes a list or `all` | Which events |
| `--math` | `trends` | `total`, `dau`, `weekly_active`, `monthly_active`, `unique_session`, `unique_group`, `sum`, `avg`, `min`, `max`, `median`, `p90`, `p95`, `p99` | What to count |
| `--property` | `trends` | Property key | The property `sum`, `avg` and the others read |
| `--interval` | `trends` | `hour`, `day`, `week`, `month` | Bucket size |
| `--breakdown` | `trends`, `funnel` | Property key, or `person:KEY` | Split the result by a property |
| `--group-type` | `trends`, `funnel`, `retention` | A `$groups` type such as `team` | Count groups instead of people |
| `--steps` | `funnel` | Comma-separated event names | The funnel's steps |
| `--window` | `funnel` | Duration such as `30m`, `24h`, `14d`, at most `90d` | Time allowed to finish the funnel |
| `--start` | `retention` | Event name | The first event |
| `--return` | `retention` | Event name, or `all` | The event that counts as coming back |
| `--period` | `retention` | `day`, `week`, `month` | Retention period |
| `--periods` | `retention` | Number | How many periods |
| `--person` | `events` | Distinct ID | One person's events |
| `--limit`, `--before` | `events` | Number; cursor | Page size; the previous page's next cursor |
| `--data` | `query` | File path, or `-` | The JSON query |
| `--identity` | `settings` | `anonymous`, `identified` | Set the identity mode; without it, `settings` only shows it |

| Message | What to do |
| --- | --- |
| ``traffic trends requires --event NAME[,NAME…] (1 to 10; `all` for every event)`` | Add `--event` |
| `traffic funnel requires --steps EVENT,EVENT[,…] (2 to 10)` | Give at least two steps |
| ``traffic retention requires --start EVENT and --return EVENT (`all` for any event)`` | Add both |
| `traffic query requires --data FILE\|- holding one JSON query, e.g. …` | Pass the query file or `-` |
| `traffic sql requires one quoted statement` | Quote the whole statement |
| `--event takes one event name` | `traffic events` reads one event at a time |
| `--identity is anonymous or identified` | Use one of those |

## AirKnowledge: knowledge bases

Read-only. Knowledge bases are written and published in AirBuild; these commands read them.

| Command | What it does |
| --- | --- |
| `knowledge list` | `enabled` (AirKnowledge on or off for the app) and each knowledge base: `id`, `name`, `live`, `draft`, `sources`, `bytes`, `publishedAt` |
| `knowledge files ID [--version VERSION]` | The knowledge base's files: `name`, `size`, `sha256` |
| `knowledge read ID FILE [--offset N] [--limit N]` | Prints one file, or part of it |
| `knowledge grep ID PATTERN [--file F]` | Searches the files for a pattern |

`read` and `grep` ask the live version's tools, the same way the app does. `--version draft` or `--version previous` reads another version.

| Flag | Value | Default | Meaning |
| --- | --- | --- | --- |
| `--version` | `live`, `draft`, `previous` | `live` | Which version to read |
| `--offset` | Number | — | Where `read` starts |
| `--limit` | Number | — | How much `read` prints |
| `--file` | File name | All files | Which files `grep` searches |

| Message | What to do |
| --- | --- |
| `nothing is published in this knowledge base; try --version draft` | Read the draft, or publish the knowledge base in AirBuild |
| `this knowledge base has no draft` | Read `live` instead |
| `(AirKnowledge is off for this app; only the owner can turn it on)` | AirKnowledge is off for the Project; it has to be turned on in AirBuild |
| `knowledge read requires a knowledge base id and a file name` | Take the ID from `knowledge list` and a name from `knowledge files` |

## Management keys

`workers keys list`, `workers keys create` and `workers keys revoke` manage the platform's management keys for one app environment: keys for a program outside AirBuild, such as a build's CI, to use the `workers` commands. They need a management credential that a Team's Agents do not have, so in a Team every `keys` command stops with an `unauthorized` error. What an Agent uses instead:

| To | Use |
| --- | --- |
| Upload dSYMs | `workers feedback dsyms upload`, or nothing at all for builds made with [`runbuild --sign`](https://air.build/docs/cli/runbuild/), which upload their own |
| Let the app's own server report purchases | `workers purchases keys create NAME` (see [AirPayment: purchases](https://air.build/docs/cli/workers/#airpayment-purchases)) |
| Anything else on this page | The command itself; the Team supplies the sign-in |

## Errors anywhere

| Message | What to do |
| --- | --- |
| `Every resource command requires --environment NAME or WORKERS_ENVIRONMENT.` | Add `--environment production` or export `WORKERS_ENVIRONMENT` |
| `select an existing application environment; environment creation is not supported` | Use the app's existing environment |
| `selected environment does not match credential scope` | Use the environment the Project's app has |
| `workers credential: Run workers inside a Project directory, …` | `cd` into the Project, or pass `--project PROJECT_ID` |
| `workers credential: Could not reach AirBuild. Try again shortly.` | Try again in a moment |
| `unknown command; run workers --help` (and `unknown … command` for a group) | Check the spelling against `workers --help` |
| `--… needs a value` / `--… takes no value` / `duplicate flag --…` / `unknown flag --…` | Fix the flag as named |
| `--… does not apply to …` / `--… only applies to …` | Remove the flag from that command |
| `--… must be between N and M` | Use a value in that range |
| `--timezone takes an IANA zone such as Asia/Shanghai` | Use a zone name, not an offset |
| `platform returned HTTP …` | The service refused the request; read the JSON error on standard error |

The command exits `0` on success and non-zero on any failure.

## Examples

Deploy the site in `site/` as Worker `shop` on database `shop`, then follow its logs:

```bash
export WORKERS_ENVIRONMENT=production
workers deploy shop --dir site --database shop
workers logs shop
```

Count the rows of a table, with a value bound to `?`:

```bash
workers db 'SELECT count(*) AS n FROM orders WHERE status = ?' --param paid --database shop
```

Find open problem reports that mention checkout, then mark one done:

```bash
workers feedback list --category problem --status open --query checkout --limit 10
workers feedback done FEEDBACK_ID
```

Signups per week over the last quarter:

```bash
workers traffic trends --event signed_up --math total --interval week --from -3m
```
