---
title: Platform API
description: Overview of the ButterIX hosted platform's REST API — base URLs, authentication, roles, error format, and common workflows.
---

Everything the ButterIX console and the `biti` CLI can do goes through this REST API: managing organizations and members, creating sites, uploading and switching deployments, configuring domains and Git, setting up Ask AI, reading analytics, and driving the visual editor.

<CardGroup cols={3}>
  <Card title="Download the spec" icon="lucide:download" href="/openapi.yaml">
    OpenAPI 3.1 (YAML)
  </Card>
  <Card title="Create API key" icon="lucide:key-round" href="/api-reference/api-keys/create-api-key">
    Organization keys for the CLI and CI
  </Card>
  <Card title="Create deployment" icon="lucide:rocket" href="/api-reference/deployments/create-deployment">
    Upload source or rebuild from the repository
  </Card>
</CardGroup>

## Base URLs

The platform API's base URL is `https://api.butterix.com/v1`.

Endpoints in the "Docs site runtime" group (Ask AI, MCP, explorer proxy, feedback) go to the **docs site's own domain**, for example `https://acme-payments-sites.butterix.com/_mcp/server`.

## Authentication

<Tabs>
  <Tab title="API key (CLI / CI)">
    Create a key in the console under **Organization settings → API Keys** and pass it in the `Authorization` header:

    ```bash
    curl https://api.butterix.com/v1/whoami \
      -H "Authorization: Bearer $BITI_TOKEN"
    ```

    API keys belong to an organization and act as `editor`: they can deploy, edit content, and read data, but can't do anything that requires `admin` (members, domains, key management, and so on).
  </Tab>
  <Tab title="Session cookie (browser)">
    After `POST /auth/login` succeeds, the platform sets an HttpOnly `biti_session` cookie (30 days), valid only on the host you signed in to. Requests that change data with cookie authentication must be same-origin: the platform checks the `Origin` header and answers cross-origin requests with 403.
  </Tab>
</Tabs>

## Roles

| Role | What it can do |
|---|---|
| `owner` | Everything; an organization needs at least one owner |
| `admin` | Manage members, site settings, domains, Git, access control, Ask AI, and API keys; delete sites |
| `editor` | Deploy, switch the production deployment, edit and publish content, test Ask AI |
| `viewer` | Read only |

## Conventions

- Requests and responses are JSON; deployment uploads use `application/gzip`, and editor uploads use `multipart/form-data`.
- Timestamps are Unix **milliseconds**.
- The `:site` and `:org` parameters can be a slug or an id.
- Errors return a matching HTTP status code and `{ "error": "…" }`.

```json title="Error response"
{ "error": "That subdomain is taken." }
```

## Common workflows

### Deploy from CI

<Steps>
  <Step title="Upload source">
    `POST /sites/{site}/deployments` with the project's tar.gz as the request body. Returns `{ id }`.
  </Step>
  <Step title="Poll the status">
    `GET /deployments/{id}` until `status` is `ready` or `failed`. `biti deploy` polls once per second.
  </Step>
  <Step title="(Optional) Roll back">
    `POST /deployments/{id}/promote` makes any successful deployment the production one, immediately.
  </Step>
</Steps>

<EndpointRequestSnippet endpoint="POST /sites/{site}/deployments" />

### Edit a page with the editor API

<Steps>
  <Step title="Create a draft">`POST /sites/{site}/editor/branches` → `{ name }`</Step>
  <Step title="Read the file">`GET /sites/{site}/editor/file?branch=…&path=…` → `{ content, sha }`</Step>
  <Step title="Save">`PUT /sites/{site}/editor/file` with `baseSha`, so you don't overwrite someone else's changes</Step>
  <Step title="Publish">`POST /sites/{site}/editor/publish` merges into the production branch and deploys</Step>
</Steps>

See the groups below or the navigation on the left for the full list of endpoints.
