Skip to main content
The Buildmarkets developer CLI (bm) is a thin, scriptable command-line interface to the Buildmarkets brokerage API. It is designed for developers at terminals, CI/CD pipelines, and autonomous agent workflows.
The bm CLI is distributed as a single static binary for macOS, Linux, and Windows. This repository hosts the published binaries and installation tooling. The source code is maintained privately.

Install & Setup

Set up the CLI in under two minutes by following these steps:
1

Install the CLI

Install the CLI on your machine using one of the following methods:macOS / Linux (curl)
macOS (Homebrew)
Windows / Manual Download the latest binary for your operating system and architecture directly from the GitHub Releases page.
2

Verify installation

Ensure the binary is installed correctly and is accessible in your system path:
3

Configure your environment

Set the environment (sandbox, qa, or live) and authenticate using your partner API credentials:
4

Verify connection

Verify your current authenticated identity and environment:

Authentication

The CLI supports two modes of authentication. Credentials are resolved in the following priority order (first match wins):

Partner / M2M Auth (API Key)

Configure M2M credentials:
These credentials are sent as X-API-Key and X-API-Secret headers on every API request.

Trader Auth (OAuth Device Flow)

For individual account/trader authentication:
This starts the OAuth device flow, printing a code and URL to approve in your web browser. Once approved, the JWT token is stored locally and sent as an Authorization: Bearer <token> header. The token refreshes automatically.
Credentials are safely stored in your operating system’s native keychain (macOS Keychain, Windows Credential Manager, or libsecret). If no keychain is available, they fallback to a secure file at ~/.buildmarkets/config.yaml with 0600 permissions.

Configuration & Environments

View and modify your CLI settings: Set environment:
Get effective base URL:
List all configurations (secrets masked):

Environment Mappings

Environment Variables

You can override any config setting at runtime using environment variables. This is the preferred method for CI/CD and automation pipelines:

Global Options & Conventions

The following global flags can be supplied to any CLI command:

Argument Conventions

  • Target resource ID: Always passed as a positional argument:
  • Parent account scope: Specified using the --account flag:
  • Creation data: Supplied via specific flags or as a JSON string/file:

Output Formats & Exit Codes

  • Interactive TTY: Outputs styled tables.
  • Piped/Redirected Output: Automatically switches to JSON.
  • Stream Monitoring: Running a command with --watch piped to a script outputs NDJSON (Newlined-delimited JSON) for streaming parse compatibility.
For example, to extract a specific JSON field:

Process Exit Codes

The bm CLI returns structured exit codes on failure so you can script control flows around them:

Command Reference Summary

Below are the most common CLI commands by resource category. For the complete, auto-generated list of all subcommands, options, and flags, see the exhaustive CLI Command Reference.

System Status

Unauthenticated readiness and health checks. Check API Health:
Check readiness:

Brokerage Accounts

Open, view, and manage customer accounts. List accounts (filterable):
Get account details:
Get account balances (cash, buying power, equity):
Open a brokerage account interactively:
Open an account using preconfigured JSON:
Sandbox KYC Testing: When opening accounts in the sandbox environment, using a tax_id ending in 0001 results in auto-approval, 0002 results in rejection, and 0003 puts the account in manual review.

Orders & Execution

Place and manage equity and ETF orders. Place a market buy order:
Place a limit buy order (GTC):
Place a dollar-based order (fractional shares):
List open/working orders:
Cancel a working order:

Positions & Portfolio

View cash and security holdings. List all open positions:
Get position details for a specific symbol:
Liquidate all holdings (destructive market sell):

Money Movement (ACH)

Link bank accounts and initiate funds transfers. Link a bank account:
Initiate an ACH deposit:
Initiate an ACH withdrawal:

Market Data

Pull market quotes, corporate profiles, fundamentals, and historical charts. Get real-time bid/ask/last price:
Get historical EOD bars:
List options chain by expiration:

Webhook Management

Manage real-time event webhooks. Create a webhook registration:
Test a webhook registration (sends simulated event):

Developer Utility Commands

Live Webhook Tunneling (bm webhooks tail)

Allows you to capture webhook events sent from your Buildmarkets tenant and stream them directly to your terminal or forward them to a local server without setting up an external proxy tunnel (like ngrok). Stream events to terminal:
Forward events to a local endpoint:

Live Request Logging (bm logs tail)

Streams live API request and response diagnostics for your tenant in real-time. Useful for debugging errors during development. Filter logs by POST method, error status, and path:

Sandbox Resetting (bm dev sandbox reset)

Resets and reseeds your sandbox tenant back to fresh fixtures. Wipe and load full fixture set (refuses to run on live environments):

Broker Migration Tool (bm migrate from-alpaca)

Automates migrating accounts, ACH links, and configurations from the Alpaca Broker API to Buildmarkets in a two-phase (plan -> apply) journaled operation. Phase 1: Generate dry-run migration plan:
Phase 2: Execute and apply migration plan:

Scripting & Automation Recipes

The CLI is optimized for shell scripts, backend automation, and cron jobs.

Run in non-interactive JSON mode

Capture an order ID from creation response

Loop and process streaming order updates