> ## Documentation Index
> Fetch the complete documentation index at: https://aeros-c1d071c8.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# GitHub webhooks

> POST /api/webhooks/github/:id: deploy on push, verified with X-Hub-Signature-256.

Each project can receive GitHub `push` events and run its [deploy pipeline](https://aeros-c1d071c8.mintlify.site/deploy-and-rollback.md#deploy). The endpoint does not use a session. It is authenticated by an HMAC-SHA256 signature of the raw request body, made with a per-project secret.

Set it up from the panel as described in [Deploy and rollback](https://aeros-c1d071c8.mintlify.site/deploy-and-rollback.md#github-webhooks), or with [`POST /api/projects/:id/webhook`](https://aeros-c1d071c8.mintlify.site/api/endpoints#webhook-configuration).

## `POST /api/webhooks/github/:id`

**id** `number` *required*

The project ID. Must be a positive integer.

**X-Hub-Signature-256** `string` *required*

`sha256=<hex HMAC-SHA256 of the raw body using the project secret>`. GitHub sets it when the webhook has a secret.

**X-GitHub-Event** `string` *required*

`push` triggers a deploy, `ping` is acknowledged, anything else is ignored.

**Content-Type** `string` *required*

`application/json`. Form-encoded payloads are not parsed.

**ref** `string` *required*

For `push`, must equal `refs/heads/<project branch>`. The branch defaults to `main`.

### Processing order

**1. Find the project**

Invalid ID: `400`. Unknown project or no secret configured: `404`.

**2. Verify the signature**

The panel computes HMAC-SHA256 over the exact bytes it received and compares it with the header using `crypto.timingSafeEqual`. A missing, malformed, or wrong signature returns `401`.

**3. Check the event**

`ping` returns `200`. Events other than `push` return `200` with `ignored: true`.

**4. Check the branch**

A push to another branch returns `200` with `ignored: true`.

**5. Deploy**

If a deploy or rollback is already running for the service: `409`. Otherwise the deploy starts in the background: `202`.

```bash Test with curl theme={null}
SECRET='<project webhook secret>'
BODY='{"ref":"refs/heads/main"}'
SIG="sha256=$(printf '%s' "$BODY" | openssl dgst -sha256 -hmac "$SECRET" | sed 's/^.* //')"

curl -s -X POST https://panel.example.com/api/webhooks/github/3 \
  -H 'Content-Type: application/json' \
  -H 'X-GitHub-Event: push' \
  -H "X-Hub-Signature-256: $SIG" \
  -d "$BODY"
```

```json 202 Deploy started theme={null}
{ "started": true, "service_name": "discord-bot" }
```

```json 200 Ping theme={null}
{ "ok": true, "event": "ping" }
```

```json 200 Ignored theme={null}
{ "ignored": true, "reason": "Push branch does not match configured branch" }
```

```json 401 theme={null}
{ "error": "Invalid webhook signature" }
```

```json 404 theme={null}
{ "error": "Webhook not configured for this project" }
```

```json 409 theme={null}
{ "error": "Deployment already in progress for this project" }
```

### Responses

| Status | Body |
| :- | :- |
| `202` | `{"started": true, "service_name": "..."}` |
| `200` | `{"ok": true, "event": "ping"}` |
| `200` | `{"ignored": true, "reason": "Ignored event: <event>"}` |
| `200` | `{"ignored": true, "reason": "Push branch does not match configured branch"}` |
| `400` | `{"error": "Invalid project ID"}` |
| `401` | `{"error": "Invalid webhook signature"}` |
| `404` | `{"error": "Webhook not configured for this project"}` |
| `409` | `{"error": "Deployment already in progress for this project"}` |

The response is sent before the deploy finishes. GitHub's delivery log shows `202` even if the deploy later fails. Deploy output is only streamed to open project terminals and is not written to the journal. To check a webhook deploy, keep the project terminal open, or compare `last_deploy_at` and `current_commit` in `GET /api/projects` afterwards.

## Secret handling

* Secrets are 32 random bytes, hex-encoded (64 characters).
* The secret is returned once, when you generate it, with `Cache-Control: no-store`. `GET /api/projects` only shows `has_webhook`.
* Generating a new secret replaces the old one immediately. Update the GitHub webhook afterwards.
* [`DELETE /api/projects/:id/webhook`](https://aeros-c1d071c8.mintlify.site/api/endpoints#webhook-configuration) removes the secret. Further deliveries get `404`.

> [!NOTE]
>
> The webhook route sits under `/api` like everything else, so it also passes the same-origin check. GitHub sends no `Origin` header, so the check lets it through.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.