# Sync a spec from GitHub

**Category:** [API Hub](https://help.totalctrl.app/hc/totalctrl/totalctrl-help-center/en-US/categories/apidocs)
**Updated:** 2026-08-19

## Connect a version to GitHub

Instead of pasting a spec by hand, you can have API Hub pull it straight from a repository file. When creating or editing a version, set **Spec source** to **GitHub** and provide:

- **Repository URL** — for example `https://github.com/owner/repo`.
- **Branch** — defaults to `main`.
- **File path** — the path inside the repo, such as `openapi.yaml`.
- **Token** — a personal access token, only needed for private repositories. Leaving the field blank when editing keeps the existing token.

## Test and sync

Use the test action to confirm the repo, branch, and file are reachable before saving. After saving a GitHub-backed version, open the Spec editor and click **Sync from GitHub** (Sync Now) to fetch the file and save it as a new revision. Like any save, this runs the compatibility diff against the previous spec.
## Automatic syncing

Set a **sync frequency** of **hourly**, **daily**, or **weekly** and API Hub re-fetches the spec on that schedule in the background — no manual clicks needed. Choose **manual** to disable automatic syncing. The schedule only runs when enough time has passed since the last successful sync, and the version records its last-synced timestamp.
## If a sync fails

Common causes are an incorrect file path, a private repo without a valid token, or an unreachable branch. Re-run the test action to pinpoint the problem, then sync again.

---

## Related Articles

- [API Hub overview](https://help.totalctrl.app/en-US/articles/api-hub-overview)
- [Create an API project](https://help.totalctrl.app/en-US/articles/create-an-api-project)
- [Generate client SDKs](https://help.totalctrl.app/en-US/articles/generate-client-sdks)
- [Add a version and upload a spec](https://help.totalctrl.app/en-US/articles/add-a-version-and-upload-a-spec)
- [Publish a developer portal](https://help.totalctrl.app/en-US/articles/publish-a-developer-portal)

---
[← Back to TotalCtrl Help Center](https://help.totalctrl.app/en-US/)