Mirror to GitHub in one click
POST/api/repos/{owner}/{repo}/mirrors/github
createGithubMirror
One-click 'keep GitHub as a backup': creates a GitHub-targeted push mirror with no manual key paste. Requires repo admin. When the neosource GitHub App is installed on the target — on an installation you connected, or your organisation's — with `contents` and `workflows` write, the mirror pushes through that installation (`credential: github_app`; no deploy key is registered). If such an installation reaches the repo but lacks a permission, `403 github_app_permission_missing` (body `GithubAppPermissionMissingError`) names the missing permissions and the installation page to accept them on. Otherwise a linked identity holding a GitHub **App** user-to-server token gets `403 github_app_install_required` (its `message` carries the install URL), and a classic OAuth token falls back to registering the mirror's deploy key (`credential: deploy_key`), which needs the `admin:public_key` scope — `403` `NeedsScopeError` when it is missing. On a deployment with no GitHub App configured, an App identity gets `403 github_mirror_unavailable_for_app_identity`. A target that is the repository's own GitHub upstream is refused with `409 relationship_conflict` while the repository still pulls from it (move it to neosource first: `POST …/github-detach`), and otherwise with `409 conflict` unless `acknowledge_replica_overwrite` is set; a second mirror to the same GitHub repository is `409 conflict`.
Requires authentication using a bearer token or a session cookie — see tokens and scopes.
curl
curl -X POST 'https://neosource.dev/api/repos/OWNER/REPO/mirrors/github' \
-H 'Authorization: Bearer $NEOSOURCE_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"github_full_name":"string"}'fetch
fetch("https://neosource.dev/api/repos/OWNER/REPO/mirrors/github", {
method: "POST",
headers: {
Authorization: "Bearer $NEOSOURCE_TOKEN",
"Content-Type": "application/json",
},
body: JSON.stringify({"github_full_name":"string"}),
});Path parameters
ownerrequiredRepository owner or organization slug.
reporequiredRepository name.
Request bodyrequired
application/json
Responses
201Mirror created — pushing through the GitHub App, or with a deploy key registered on GitHub
application/json
403Forbidden — one of: forbidden, needs_scope, github_app_install_required, github_app_permission_missing, github_mirror_unavailable_for_app_identity
Standard errors
Bodies documented once for the whole API — see standard errors.
- 400Bad Request — one of: invalid_input
- 401Authentication required
- 404Not Found — one of: not_found
- 409Conflict — one of: already_exists, conflict, relationship_conflict
- 423Locked — one of: busy
- 429Rate limited — retry after the `Retry-After` header
- 500Internal server error
- 502Bad Gateway — one of: upstream
- 503Service temporarily unavailable / at capacity — retry after the `Retry-After` header
- 504Gateway timeout — the request exceeded the server's handling budget