# GitHub Sync

When using the [Detection Rules as Code](https://docs.scanner.dev/scanner/using-scanner-complete-feature-reference/detections-and-alerting/detection-rules/detection-rules-as-code) feature, you can use the API to start a sync in Scanner.

Syncs happen automatically every 5 minutes, but you can kickoff a sync via API if you want to sync immediately after an event (e.g. pushing a commit to GitHub).

## Sync GitHub repositories

<mark style="color:green;">**`POST`**</mark> `/v1/sync_github_repositories`

Sync GitHub repositories for the given tenant.

**Body**

<table><thead><tr><th>Name</th><th width="192.8828125">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>tenant_id</code> <mark style="color:red;">required</mark></td><td>string</td><td>Unique identifier for the tenant</td></tr></tbody></table>

**Example**

```bash
curl $API_BASE/v1/sync_github_repositories \
-H "Authorization: Bearer $SCANNER_API_KEY" \
-H "Content-Type: application/json" \
-X POST \
-d '{ "tenant_id": "00000000-0000-0000-0000-000000000000" }'
```

**Response**

Returns the `tenant_id`.

```bash
{ "tenant_id": "00000000-0000-0000-0000-000000000000" }
```
