---
title: "Bird CLI"
description: "The bird command-line interface for operating the Bird API from a shell, a script, or an AI agent with JSON output, semantic exit codes, and safe retries."
canonical: "https://bird.com/docs/cli"
---

# Bird CLI

`bird` is the Bird API as a command line: one binary that sends on every channel Bird runs, sets those channels up, and configures the workspace around them. It is built for two callers at once: a human at a terminal, and an agent or script driving it in a loop. Every command emits JSON to stdout by default, writes errors as a structured envelope on stderr, and exits with a semantic code, so a consumer branches on structure rather than parsing prose.

## Install

### macOS and Linux

Homebrew:

```bash
brew install messagebird/tap/bird
```

Or the install script:

```bash
curl -fsSL https://cli.bird.com/install.sh | sh
```

The script detects your platform, verifies the download, and prints where the binary landed. To pin a release or choose the destination, pass the flags through the pipe with `sh -s --`:

```bash
curl -fsSL https://cli.bird.com/install.sh | sh -s -- --version 1.2.3 --install-dir /opt/bird/bin
```

### Windows

```powershell
irm https://cli.bird.com/install.ps1 | iex
```

It installs to `%LOCALAPPDATA%\bird\bin`. To pin a release or pick a directory, download the script first, because piping into `iex` leaves no way to pass parameters:

```powershell
irm https://cli.bird.com/install.ps1 -OutFile install.ps1
.\install.ps1 -Version 1.2.3 -InstallDir C:\tools\bird
```

Verify the install on any platform with `bird version`.

## Authenticate

```bash
bird auth login --scope emails:write
```

This opens a browser consent page where you approve the requested workspace permissions. A bare `bird auth login` requests read-only access. The `--scope emails:write` option lets the email send in [First commands](#first-commands) succeed. Any command that needs more access prints the exact re-login command. The CLI stores a workspace-bound OAuth token in `~/.config/bird/credentials.json` and refreshes it automatically on use. You do not need to create or copy an API key, and the recorded workspace region removes the need to configure a host. On a headless machine or over SSH, `bird auth login --device` prints a code you approve on another device instead of opening a local browser.

To keep more than one workspace signed in, give each its own profile: `bird auth login --profile staging` signs one in. On any command, `--profile` or `BIRD_PROFILE` chooses which stored login is used. A valid `BIRD_API_KEY` takes precedence over any profile. Commands without either use the default profile, which `bird profile set <name>` changes and `bird profile list` shows.

Check that the credential works:

```bash
bird auth status
```

`auth status` reports whether a token is configured and whether it validates against the API, plus the workspace, region, and granted scopes. It always exits `0`, so branch on the `valid` field in its JSON output. Pass `--offline` to skip the API call, and `bird auth logout` to discard the stored credential.

## First commands

Send an email and read it back by ID:

```bash
bird email send --from onboarding@messagebird.dev --to delivered@messagebird.dev --subject "Hello" --html "<p>Hi from the CLI.</p>"
bird email get em_01ky7ma8y2es1s2akzk53tmjn0
```

The [CLI quickstart](/docs/get-started/quickstarts/cli/email) walks this flow end to end, including Bird's shared onboarding domain and sandbox address, so you can send before verifying a domain of your own.

Mutations take input three ways, and the inline value wins: flags, a JSON body named by `--body-file <path|->` (`-` reads stdin), or both, so one stored template serves many calls (`bird email send --body-file body.json --to x@y.com`). The CLI never reads stdin it wasn't pointed at. Two flags make every write safe to rehearse and retry:

- `--dry-run` prints the resolved request (its `method`, `url`, the `Idempotency-Key` header when set, and the `body`) and exits without sending: the verification gate before anything outbound.
- `--idempotency-key <key>` makes a retry safe: the server replays the original response for any duplicate request with the same key, the same idempotency mechanism the [SDKs](/docs/sdks/typescript) use, so a network timeout never means a double send.

Write commands also support `--example`, which prints a complete, valid request body (generated from the API schema, no credentials needed) and exits. Commands that remove something, such as `delete` and `archive`, require an explicit ID and `--yes`, so a loose retry can't act by accident. You can undo an archive with the matching `unarchive` command.

## Output contract

Data goes to stdout as JSON with no flag needed; diagnostics and errors go to stderr, never mixed with data. Lists return a cursor envelope (`{"data": [...], "next_cursor": ...}`) with a default `--limit`, so output is always bounded. Pipe to `jq` to extract fields (`bird email list | jq -r '.data[].id'`). On single-record reads (`get`, `show`, `status`), `--format text` (`-f text`) opts into a human-readable card instead.

Failures are a JSON envelope on stderr with machine-branchable fields: `code` (stable ID), `type`, `retryable` and `retry_after`, `param` and `details` for the offending input, and `next` listing runnable `bird` commands to recover. API errors pass the server's error code, request ID, and docs link straight through. Every error carries a readable `message`, and most carry a stable `code`. An error from the Bird API also carries a `doc_url` to that code's page, which says what went wrong and what to do. Every code is listed in the [error reference](/docs/api/errors). See [Errors](/docs/guides/errors) for the underlying API error model.

Exit codes are semantic, so a script or agent branches without reading any text:

| Exit code | Meaning                                                            |
| --------- | ------------------------------------------------------------------ |
| `0`       | Success.                                                           |
| `1`       | Unexpected / unrecognized error. Surface and stop.                 |
| `2`       | Invalid flags, arguments, or body.                                 |
| `3`       | Resource not found.                                                |
| `4`       | Authentication or authorization failure.                           |
| `5`       | Conflict or failed precondition.                                   |
| `6`       | Rate limit or server error, retry after `retry_after`.             |
| `7`       | A check found a problem, for example `bird email templates check`. |

Commands report missing input with exit `2` and an actionable hint, without an interactive prompt. `bird auth login` waits for browser or device approval. Commands awaiting browser confirmation print a review link and `confirmation_id` in a JSON notice on stderr. Retain the ID for recovery while the command waits for completion. A completed confirmation returns the recorded execution result. If confirmation expires, is cancelled, or ends without that result, the command exits `5`. A missing result does not prove the operation did not run. Reconcile its outcome before creating another request. If interrupted, repeat the original command and idempotency key with `--confirmation-id <confirmation_id>` to resume.

## Configuration

```bash
bird config show
```

`config show` prints the resolved configuration: the API base URL and where it came from, the config, cache, and state paths, and any [channel defaults](#channel-defaults) in effect. The base URL resolves in order: the `--base-url` global flag, the `BIRD_API_URL` environment variable, then the region recorded with your login (`{region}.platform.bird.com`). After `bird auth login`, the resolved region normally needs no override. The CLI follows XDG paths (`~/.config/bird`, `~/.cache/bird`, `~/.local/state/bird`); set `BIRD_CONFIG_DIR` to collapse all three under one root, useful for isolated CI or agent sandboxes.

Two global flags work on every command:

- `--format` (`-f`): `json` (default) or `text` (single-record reads only).
- `--base-url`: override the API endpoint for one invocation, equivalent to `BIRD_API_URL`.

### Channel defaults

Run `bird config show` and use the file reported as `paths.config_file` for values you would otherwise repeat on every send. This path follows `BIRD_CONFIG_DIR` and XDG configuration locations. A configured default fills the matching field of a send that leaves it unset, and a value passed to the call always wins:

```json
{
  "email": {
    "from": "hello@acme.com",
    "reply_to": ["support@acme.com"],
    "tags": { "team": "growth" },
    "ip_pool_id": "ipp_01krdgeqcxet5s7t44vh8rt9mg"
  }
}
```

The `email` object takes `from`, `reply_to`, `category`, `track_opens`, `track_clicks`, `headers`, `tags`, `metadata`, and `ip_pool_id`, and applies to `bird email send`, `bird email send-batch`, and `bird email mailboxes compose`. Each value is written the way the matching flag is: an address is a plain or `Name <addr>` string, and `headers` and `tags` are `name: value` objects. A compose reads only `reply_to`, `category`, `tags`, and `metadata`, because it sends as the mailbox. These are the same defaults the SDKs accept at client construction, so a script and its SDK equivalent send from the same address. A key the file doesn't recognize is refused by name rather than parsing into a default that never applies. Only the commands that read defaults fail on it; `bird config show` reports the same error instead, so you can find the typo.

## Discover the surface

```bash
bird commands
```

This prints the entire command tree as JSON, including each command's purpose, flags, required positionals, and error contract. An agent can enumerate the full surface in one call instead of scraping `--help`. Use `--example` or `--help` to inspect a command, then `--dry-run` to preview it. For safe retries, run the command with `--idempotency-key`. To complete commands with Tab, see [Shell completion](#shell-completion).

## Shell completion

`bird completion <shell>` prints a completion script. Install it once for your shell, then start a new shell.

Bash needs version 4 or later with the bash-completion v2 package (on macOS, `brew install bash bash-completion@2`):

```bash
mkdir -p ~/.local/share/bash-completion/completions
bird completion bash > ~/.local/share/bash-completion/completions/bird
```

Zsh loads completions from a directory on its `fpath` once `compinit` runs:

```bash
mkdir -p ~/.zfunc
bird completion zsh > ~/.zfunc/_bird
```

Then add these lines to `~/.zshrc`, above any `compinit` line already there:

```bash
fpath=(~/.zfunc $fpath)
autoload -Uz compinit && compinit
```

Fish:

```bash
mkdir -p ~/.config/fish/completions
bird completion fish > ~/.config/fish/completions/bird.fish
```

```powershell
# PowerShell: add this line to your $PROFILE
bird completion powershell | Out-String | Invoke-Expression
```

The script asks the installed `bird` for its suggestions each time you press Tab, so it stays current when you upgrade `bird` (with `bird update` or Homebrew) without reinstalling. Tab completes command and subcommand names, flag names, and the values of flags that take a fixed set, such as `--category` on `bird email send`. Flags that take a path, such as `--body-file` and `--attach`, complete file names. Run `bird completion <shell> --help` for the other install locations.

## Common command groups

The groups you'll use first. The CLI covers far more (SMS, WhatsApp, Verify, contacts, audiences, billing, support tickets, and others); run `bird commands` for the full tree.

- [`bird auth`](/docs/cli#authenticate): `login`, `status`, `logout`: manage the OAuth credential.
- [`bird email`](/docs/get-started/quickstarts/cli/email): `send`, `get`, `list`: send messages and track their delivery status.
- [`bird email templates`](/docs/guides/email/templates): `create`, `get`, `list`, `update`, `delete`, `duplicate`, `preview`: author reusable templates. `versions submit` freezes a draft and makes it the version sends serve; `versions languages set` edits its per-language content.
- [`bird email blocks`](/docs/guides/email/reusable-blocks): `create`, `get`, `list`, `update`, `duplicate`, `validate`, `publish`: author reusable sections, such as a legal footer, that templates link. `languages set` edits a block's per-language drafts.
- [`bird email domains`](/docs/guides/email/sending-domains): `create`, `get`, `list`, `verify`: register sending domains and check DNS verification.
- [`bird email mailboxes`](/docs/guides/email/mailboxes): `create`, `get`, `list`, `update`, `delete`, `compose`: claim and manage agent mailboxes and receive rules.
- [`bird email threads`](/docs/guides/email/mailboxes): `list`, `get`, `messages list`, `messages reply`: read mailbox conversation threads and reply to inbound messages.
- [`bird email inbound-addresses`](/docs/guides/email/receiving-email): `create`, `get`, `list`, `update`, `delete`: mint and manage the forwarding addresses Bird receives mail at.
- [`bird email inbound-messages`](/docs/guides/email/receiving-email): `list`, `get`, `body`, `attachments`: read the mail Bird received.
- [`bird webhooks`](/docs/guides/webhooks): `create`, `get`, `list`, `test`, `delete`: manage webhook endpoints and fire test deliveries.

## Next steps

- [CLI quickstart](/docs/get-started/quickstarts/cli/email): install, log in, and send your first email in two minutes.
- [The CLI for agents](/docs/ai/cli-for-agents): the full agent contract: JSON output, exit codes, `--dry-run`, error envelope, and discovery.
- [SDKs](/docs/sdks): the same API surface as typed libraries for TypeScript, Python, Go, and PHP.

## Related resources

- [Should I use a Bird SDK or call the API directly?](/explained/platform/should-i-use-an-sdk-or-call-the-api-directly) (answer)
- [Build your first integration](/learn/paths/integration) (course)
- [Send your first email](/docs/get-started/send-your-first-email) (docs)

[Get an implementation brief](/learn/workspace?topic=api-basics)
