> 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.

# Connect Git repository

`PUT /sites/{site}/git`

Requires the `admin` role. Replaces the hosted repository with a remote one, pulls it right away, and starts a production deployment.
Private repositories need an access token with read permission (stored encrypted); publishing from the visual editor also needs write permission.
After connecting, configure a webhook in the repository (its URL and secret are in `git` in the response).

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 |

## Request body

Content type: `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `url` | string | yes | https URL |
| `branch` | string | no |  |
| `token` | string | no | Access token; leave empty to keep the current one |

## Example request

```bash
curl -X PUT https://api.butterix.com/v1/sites/acme-payments/git \
     -H "Authorization: Bearer <token>" \
     -H "Content-Type: application/json" \
     -d '{
         "url": "https://github.com/acme/docs.git"
       }'
```

## Responses

### 200

Site details

Content type: `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `id` | string | no |  |
| `slug` | string | no |  |
| `name` | string | no |  |
| `url` | URL | no |  |
| `sourceType` | enum | no | Content source: hosted repository, external Git repository, or CLI upload Allowed: `hosted`, `git`, `upload`. |
| `status` | enum | no | Status of the latest deployment; `none` when there isn't one Allowed: `queued`, `building`, `ready`, `failed`, `canceled`, `none`. |
| `updatedAt` | integer | no |  |
| `pageCount` | integer | no | Number of pages in the production deployment |
| `orgSlug` | string | no |  |
| `git` | object | no | Present when a Git repository is connected |
| `git.url` | string | no |  |
| `git.branch` | string | no |  |
| `git.hasToken` | boolean | no |  |
| `git.webhookUrl` | string | no |  |
| `git.webhookSecret` | string | no |  |
| `production` | object | no |  |
| `production.id` | string | no |  |
| `production.siteId` | string | no |  |
| `production.kind` | enum | no | Allowed: `production`, `preview`. |
| `production.status` | enum | no | Allowed: `queued`, `building`, `ready`, `failed`, `canceled`. |
| `production.source` | string | no | `cli` (upload), `hosted` (hosted repository), or `git` |
| `production.branch` | string | no |  |
| `production.commitSha` | string | no |  |
| `production.message` | string | no |  |
| `production.createdBy` | object | no | Who triggered it; with an API key, the person who created the key |
| `production.createdBy.id` | string | no |  |
| `production.createdBy.name` | string | no |  |
| `production.apiKey` | object | no | The name, start and end of the key, when triggered with an API key (CLI / CI) |
| `production.apiKey.name` | string | no |  |
| `production.apiKey.prefix` | string | no | First 10 characters of the key |
| `production.apiKey.suffix` | string | no | Last 10 characters of the key |
| `production.error` | string | no | Reason for failure |
| `production.pageCount` | integer | no |  |
| `production.sizeBytes` | integer | no |  |
| `production.durationMs` | integer | no |  |
| `production.url` | URL | no | Present after success. Production deployments have the site's URL; previews use a `<site>--<last 8 characters of the id>` subdomain |
| `production.isCurrent` | boolean | no | Whether this is the current production deployment |
| `production.createdAt` | integer | no |  |
| `production.finishedAt` | integer | no |  |
| `domains` | list of objects | no |  |
| `domains[].domain` | string | no |  |
| `domains[].verified` | boolean | no |  |
| `domains[].primary` | boolean | no | Whether this is the primary domain |
| `domains[].verifyRecord` | object | no | TXT record to add |
| `domains[].verifyRecord.type` | "TXT" | no | Allowed: `TXT`. |
| `domains[].verifyRecord.name` | string | no |  |
| `domains[].verifyRecord.value` | string | no |  |
| `domains[].cname` | string | no | CNAME target |
| `domains[].createdAt` | integer | no |  |
| `access` | object | no |  |
| `access.mode` | enum | no | Allowed: `public`, `password`. |
| `ai` | object | no |  |
| `ai.enabled` | boolean | no |  |
| `ai.provider` | enum | no | Allowed: `anthropic`, `deepseek`, `openrouter`. |
| `ai.model` | string | no |  |
| `ai.hasKey` | boolean | no | Whether a site key is set |
| `ai.keyMasked` | string | no |  |
| `ai.platformKeyAvailable` | boolean | no | Whether the platform has a default key for the current provider |
| `ai.platformKeys` | map from strings to booleans | no | Whether each provider has a platform key |
| `ai.guidance` | string | no |  |
| `ai.effort` | enum | no | Reasoning effort; `null` uses the model's suggested level May be null. Allowed: `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`. |
| `ai.retentionDays` | integer | no | Days to keep questions; `null` keeps them forever May be null. |
| `ai.dailyLimit` | integer | no | Maximum questions that call the model in a rolling 24 hours; `null` means no limit May be null. |
| `ai.agent` | boolean | no | Whether console AI is on |
| `ai.gaps` | boolean | no | Whether documentation gaps are sorted every day |
| `ai.support` | object | no | Contact when AI has no answer |
| `ai.support.enabled` | boolean | no |  |
| `ai.support.url` | string | no |  |
| `ai.support.email` | string | no |  |
| `primaryUrl` | URL | no | The address on the primary domain; the same as `url` without a custom domain |
| `mcpUrl` | URL | 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) |

### Example response (200)

```json
{
  "id": "site_2m4k8p",
  "slug": "acme-payments",
  "name": "Acme Docs",
  "url": "https://acme-payments-sites.butterix.com",
  "sourceType": "hosted",
  "status": "queued",
  "updatedAt": 1,
  "pageCount": 94,
  "orgSlug": "acme",
  "git": {
    "url": "https://github.com/acme/docs.git",
    "branch": "main",
    "hasToken": true,
    "webhookUrl": "https://api.butterix.com/v1/webhooks/github/site_2m4k8p",
    "webhookSecret": "string"
  },
  "production": {
    "id": "dpl_01jd8x2k7q",
    "siteId": "site_2m4k8p",
    "kind": "production",
    "status": "queued",
    "source": "git",
    "branch": "main",
    "commitSha": "9fceb02d0ae598e95dc970b74767f19372d61af8",
    "message": "docs: update quickstart",
    "createdBy": {
      "id": "string",
      "name": "string"
    },
    "apiKey": {
      "name": "GitHub Actions",
      "prefix": "biti_a1B2c",
      "suffix": "Kd82mQx0Zt"
    },
    "error": "string",
    "pageCount": 94,
    "sizeBytes": 5832110,
    "durationMs": 6120,
    "url": "https://acme-payments--8x2k7q-sites.butterix.com",
    "isCurrent": true,
    "createdAt": 1,
    "finishedAt": 1
  },
  "domains": [
    {
      "domain": "docs.acme.com",
      "verified": false,
      "primary": false,
      "verifyRecord": {
        "type": "TXT",
        "name": "_butterix.docs.acme.com",
        "value": "butterix-verify=a1b2c3d4e5f6"
      },
      "cname": "sites.butterix.com",
      "createdAt": 1
    }
  ],
  "access": {
    "mode": "public"
  },
  "ai": {
    "enabled": true,
    "provider": "anthropic",
    "model": "claude-opus-5-5",
    "hasKey": true,
    "keyMasked": "sk-a…9f2c",
    "platformKeyAvailable": true,
    "platformKeys": {
      "key": true
    },
    "guidance": "string",
    "effort": "none",
    "retentionDays": 1,
    "dailyLimit": 200,
    "agent": true,
    "gaps": false,
    "support": {
      "enabled": false,
      "url": "",
      "email": ""
    }
  },
  "primaryUrl": "https://docs.acme.com",
  "mcpUrl": "https://docs.acme.com/_mcp/server"
}
```
