# GitHub App events

Source: https://docs.coderhelm.com/api/reference/webhooks/receive-github-event

`POST /webhooks/github`

Where GitHub sends every event of the CoderHelm GitHub App. Installing the app sets this up; you only call it yourself when you self-host. Each request is signed with the app's webhook secret in `X-Hub-Signature-256` (`sha256=` and the hex HMAC-SHA256 of the raw body), compared in constant time. The event type comes from `X-GitHub-Event` and the body must name an installation. Events CoderHelm doesn't act on, and events from an installation not linked to a team, are accepted with `200` and ignored.

## Authentication

Verified by its signature header. See [Webhooks](https://docs.coderhelm.com/api/webhooks).

## Parameters

### Headers

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `X-GitHub-Event` | string | yes | The event type, such as `issues`, `pull_request` or `push`. |
| `X-GitHub-Delivery` | string or null | no | GitHub's id for this delivery. |

## Request body

`application/json`: The event payload, as GitHub defines it for each event type. It must include `installation.id`.

## Responses

### 200

Accepted.

### 400

The body is not JSON or names no installation.

### 401

The signature is missing or wrong.

## Example request

cURL:

```bash
curl -X POST 'https://api.coderhelm.com/webhooks/github' \
  -H 'X-GitHub-Event: issues' \
  -H 'Content-Type: application/json' \
  -d '{}'
```

TypeScript:

```ts
const res = await fetch("https://api.coderhelm.com/webhooks/github", {
  method: 'POST',
  headers: {
    "X-GitHub-Event": "issues",
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({}),
});
if (!res.ok) {
  const { error, code } = await res.json();
  throw new Error(`${res.status} ${code}: ${error}`);
}
const data = await res.json();
```

Python:

```python
import requests

headers = {
    "X-GitHub-Event": "issues",
}
body = {}
res = requests.request("POST", "https://api.coderhelm.com/webhooks/github", headers=headers, json=body)
if not res.ok:
    raise RuntimeError(f"{res.status_code}: {res.json().get('error')}")
data = res.json()
```
