---
title: CLI deployment and API keys
subtitle: Log in with an organization API key, and biti deploy packs your project, uploads it to the platform, waits for the build, and prints the URL. Works locally and in any CI.
description: Create a ButterIX organization API key, authenticate with biti login or BITI_TOKEN, biti deploy options, packing rules and preview deployments, plus example configs for GitHub Actions and other CI.
---

## Create an API key

<Steps>
  <Step title="Open organization settings">
    In the dashboard, go to "Organization settings → API Keys" (requires the admin role).
  </Step>
  <Step title="Generate a key">
    Enter a recognizable name (for example "GitHub Actions") and click generate. The key starts with `biti_` and is **shown only once** — save it to your password manager or CI secret store right away.
  </Step>
</Steps>

API keys belong to the organization and act with the `editor` role: they can deploy, switch production, and edit content, but can't manage members, domains, or other keys. Deleting a key immediately revokes every CLI and CI that uses it. The list shows each key's prefix and when it was last used.

## Log in

<Tabs>
  <Tab title="Interactive">
    ```bash
    biti login
    ```

    The CLI prompts you to paste the key, verifies it against the platform's `/api/v1/whoami`, and saves the credentials to `~/.config/bitidocs/credentials.json` (under `XDG_CONFIG_HOME` if set, with file mode 600).
  </Tab>
  <Tab title="Non-interactive">
    ```bash
    biti login --token biti_xxxxxxxxxxxxxxxx
    ```

    The CLI connects to the ButterIX hosted platform by default.
  </Tab>
  <Tab title="Environment variables (CI)">
    No login needed — just set environment variables:

    ```bash
    export BITI_TOKEN=biti_xxxxxxxxxxxxxxxx
    ```

    When `BITI_TOKEN` is set, it takes precedence over saved credentials.
  </Tab>
</Tabs>

## Deploy

```bash
biti deploy --site acme-payments --message "Publish v1.2 docs"
```

```text title="Output"
  ButterIX · biti

◆ Packing .…
◆ Uploading 412 KB to https://console.butterix.com…
  queued
  building
✔ Published 94 pages in 6.1s

  https://acme-payments-sites.butterix.com
```

<ParamField path="[dir]" type="string" default=".">Project directory.</ParamField>
<ParamField path="--site" type="string">Site slug. If omitted, infers it from the hostname of `instances[0].url` in `docs.yml` (`acme-payments-sites.butterix.com` → `acme-payments`).</ParamField>
<ParamField path="--preview" type="boolean">Create a preview deployment that doesn't affect the production URL and gets its own `<site>--<short id>` URL.</ParamField>
<ParamField path="--message" type="string" default="Deployed with biti CLI">Deployment message, shown in the dashboard's deployment list.</ParamField>

### What happens

<Steps>
  <Step title="Validate config">
    Reads `docs.yml`; if the config has errors, stops and suggests running `biti check` first.
  </Step>
  <Step title="Pack">
    Packs the project directory into a gzip tarball, skipping `node_modules`, `.git`, `.biti`, `dist`, `.DS_Store`, and files that may hold credentials, such as `.env`, `.npmrc`, and SSH private keys (they are listed). The platform accepts uploads up to 200 MB.
  </Step>
  <Step title="Upload">
    `POST /api/v1/sites/<site>/deployments`, which returns the deployment id.
  </Step>
  <Step title="Wait for the build">
    Polls the deployment status every second and prints status changes; on success prints the URL, if it fails or is canceled, prints the error and exits with a non-zero status.

    Network errors, rate limits, and platform restarts (5xx) while polling are retried automatically. The command gives up only after 2 minutes without a valid response. By then the upload has already succeeded and the build may still be running, so check the deployment list in the dashboard before deploying again.
  </Step>
</Steps>

<Tip>
  Builds run on the platform, so you don't need build output on your machine. Running `biti check --strict` locally before deploying catches problems in seconds instead of waiting for a platform build to fail.
</Tip>

## Sync with the online editor

`biti deploy` checks whether changes were published from the online editor since your last deploy or pull.

| Situation | Result |
| --- | --- |
| No new online changes | Deploys right away |
| None of the files changed online were changed locally | Lists the changes, merges them into your folder, and continues deploying |
| The same file changed on both sides, in different places | Merges line by line into your folder, keeping both sides' changes, and continues deploying |
| The same place changed on both sides | Stops, marks those files with `!`, and leaves your files alone. Run `biti pull` and settle the conflicts |
| No sync record (`.biti/sync.json`, for example in CI) | Stops without merging |

`biti pull --dry-run` only lists what would change. `biti deploy --force` overwrites the online changes with your local content.

### Settle conflicts

`biti pull` marks both versions in files that conflict and merges everything else:

```yaml
<<<<<<< local
  - url: https://api.example.com/v1
=======
  - url: https://api.example.com/v2
>>>>>>> online
```

Edit the text to what you want and remove the marker lines, or take one side:

```bash
biti resolve . --online                    # take the online side everywhere
biti resolve . openapi/api.yml --local     # keep your side of this file
```

Files that can't be merged by line, such as images, and files deleted online but edited locally keep your version; the online version is in `.biti/conflicts/`. Choose a side with `biti resolve`; without an option, the files are kept as they are now.

Until every conflict is settled, `biti deploy` won't publish and `biti pull` won't pull again. `biti deploy --force` publishes your side.

In the editor, the number on the **Files** button counts uncommitted drafts. An orange dot next to it means changes published online haven't been pulled to the command line yet; open the menu to see the files.

## Deploy from CI

### GitHub Actions

Publish to production on pushes to `main`, and create previews for pull requests:

```yaml title=".github/workflows/docs.yml"
name: Docs
on:
  push:
    branches: [main]
  pull_request:

jobs:
  deploy:
    runs-on: ubuntu-latest
    env:
      BITI_TOKEN: ${{ secrets.BITI_TOKEN }}
      BITI_API: https://console.butterix.com
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
      - run: npm install -g bitidocs
      - run: biti check --strict
      - if: github.event_name == 'push'
        run: biti deploy --site acme-payments --message "${{ github.event.head_commit.message }}"
      - if: github.event_name == 'pull_request'
        run: biti deploy --site acme-payments --preview --message "PR #${{ github.event.number }}"
```

### GitLab CI

```yaml title=".gitlab-ci.yml"
docs:
  image: node:22
  variables:
    BITI_API: https://console.butterix.com
  script:
    - npm install -g bitidocs
    - biti check --strict
    - biti deploy --site acme-payments --message "$CI_COMMIT_TITLE"
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
```

Add `BITI_TOKEN` to your CI secrets.

<Note>
  If your repository is on GitHub, you can skip CI entirely and let the platform connect to the repo — pushes and pull requests trigger builds automatically. See [Git deployments](./git.mdx).
</Note>

## Call the API directly

The CLI is just a thin wrapper around the platform API. In environments without Node.js, you can do the same thing with `curl`:

<EndpointRequestSnippet endpoint="POST /sites/{site}/deployments" languages={["curl"]} />

Then poll [Get deployment](/api-reference/deployments/get-deployment) until `status` is `ready`.
