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

# Receive GitHub webhook

`POST /webhooks/github/{siteId}`

Called by GitHub (or a compatible Git service). No API authentication, but it must carry a valid `X-Hub-Signature-256` signature (HMAC-SHA256 with the site's webhook secret).

- `push` to the production branch → production deployment.
- `pull_request` with `opened` / `synchronize` / `reopened` → preview deployment of that branch.
- `ping` → `{ ok: true }`; other events → `{ ignored: true }`.

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

## Path parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `siteId` | string | yes | Site id (not the slug) |

## Header parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `X-GitHub-Event` | enum | yes | Allowed: `push`, `pull_request`, `ping`. |
| `X-Hub-Signature-256` | string | yes |  |

## Request body

Content type: `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `ref` | string | no |  |
| `after` | string | no |  |
| `head_commit` | object | no |  |
| `head_commit.message` | string | no |  |
| `action` | string | no |  |
| `pull_request` | object | no |  |
| `pull_request.number` | integer | no |  |
| `pull_request.title` | string | no |  |
| `pull_request.head` | object | no |  |
| `pull_request.head.ref` | string | no |  |
| `pull_request.head.sha` | string | no |  |

## Example request

```bash
curl -X POST https://api.butterix.com/v1/webhooks/github/site_2m4k8p \
     -H "X-GitHub-Event: push" \
     -H "X-Hub-Signature-256: sha256=4f1c…" \
     -H "Content-Type: application/json" \
     -d '{}'
```

## Responses

### 200

A ping, or an ignored event

Content type: `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `ok` | boolean | no |  |
| `ignored` | boolean | no |  |

### 202

Deployment created

Content type: `application/json`

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

### 401

Invalid signature

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
{
  "ok": true,
  "ignored": true
}
```
