> This page is for version v1 (default).
> For other versions, use one of these documentation indexes:
> - v1 (default): https://docs.butterix.com/en/llms.txt
> - v0: https://docs.butterix.com/en/v0/llms.txt

> For the MDX source of any page, append .mdx to the page URL.
> For a complete documentation index, see https://docs.butterix.com/en/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.butterix.com/_mcp/server.
> If something on this page is wrong or missing, POST JSON {"page": "<page URL>", "message": "<what is wrong>"} to https://docs.butterix.com/_biti/feedback/agent.

# Create deployment

`POST /sites/{site}/deployments`

Requires the `editor` role. There are two ways to use it:

1. **Upload source** (used by `biti deploy`): the request body is a gzip tarball of the project directory (`Content-Type: application/gzip`, up to 200 MB).
   The `x-biti-preview: 1` header creates a preview deployment, and `x-biti-message` is the URL-encoded deployment message.
2. **Rebuild from the repository**: JSON `{ preview?, branch? }`, building from the hosted repository or the connected Git repository. Not available for sites that have been uploaded with the CLI.

Returns 202 and the deployment id; poll its status with [Get deployment](https://docs.butterix.com/en/api-reference/deployments/get-deployment.md).

Base URL: https://api.butterix.com/v1

Authentication: bearer token in Authorization header or API key in cookie `biti_session`

## Path parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `site` | string | yes | Site slug or id |

## Header parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `x-biti-preview` | enum | no | When uploading source: `1` for a preview deployment Allowed: `0`, `1`. |
| `x-biti-message` | string | no | When uploading source: URL-encoded deployment message |

## Request body

Content type: `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `preview` | boolean | no | Create a preview deployment instead of a production one |
| `branch` | string | no | Branch to build; the site's production branch by default |

## Example request

```bash
tar --exclude=node_modules --exclude=.git --exclude=dist -czf site.tgz .
curl -X POST https://api.butterix.com/v1/sites/acme-payments/deployments \
  -H "Authorization: Bearer $BITI_TOKEN" \
  -H "Content-Type: application/gzip" \
  -H "x-biti-preview: 1" \
  --data-binary @site.tgz
```

## Responses

### 202

Queued

Content type: `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `id` | string | no |  |

### 400

Invalid request parameters

Content type: `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | string | yes | Human-readable error message |
| `code` | string | no | Machine-readable error code (some endpoints) |

### 413

Upload larger than 200 MB

Content type: `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | string | yes | Human-readable error message |
| `code` | string | no | Machine-readable error code (some endpoints) |

### Example response (202)

```json
{
  "id": "dpl_01jd8x2k7q"
}
```
