Import a GitHub repository
POST/api/github/imports
createGithubImport
Creates a new neosource repository in the workspace named by `owner` and enqueues a background import that clones the GitHub repo into it. Watch progress via the repo's `import-progress` SSE / `import-status` endpoints. `owner` omitted (or the caller's own handle) is the caller's personal workspace. Every target, the personal workspace included, must be a workspace where the caller holds `workspace:repo:create`; an unknown owner answers `404` and one without the permission `403`, both **before the repository is created**. The import runs on the caller's own GitHub credential whichever workspace receives it. `visibility` omitted mirrors the GitHub repository: public on GitHub is `public` here; private (and GitHub `internal`) is `private`, as is any import whose GitHub visibility could not be read. An explicit `visibility` always wins. `relationship` says what tie to keep with the GitHub repository (ADR 0115). `neosource_readonly_mirror` imports issues, comments and labels and keeps them in sync, GitHub staying authoritative. `github_managed` is sync at import: the repository is bound to the GitHub App installation covering `source_full_name` and, once the clone completes, attached to it (a clean attach confirms itself; anything that would move or preserve a ref waits as a preview on the repository's GitHub panel). It needs `workspace:integration:manage` on the target workspace (`403`; a token must carry that scope), a session or a token not locked to workspaces or repositories (`403`), a token whose scopes reach `repo:admin` (`403`), and an installation the caller may use that covers the repository and is not already linked to another neosource repository (`409 relationship_conflict`, the detail naming the install page or the conflict); `409 relationship_unavailable` when this deployment does not offer GitHub sync. `move_now` answers `409 relationship_unavailable`. Every one of these refusals lands **before the repository is created** so a refusal never leaves an orphan behind. The deprecated `sync_metadata: true` means exactly `relationship: "neosource_readonly_mirror"`; sending both is `400`. Two further refusals land at that same early point, so neither can orphan a repository either: asking for `neosource_readonly_mirror` without a linked GitHub identity carrying a stored access token answers `400` (connect GitHub in account settings first — it is the credential the metadata backfill and the recurring polls run on), and a token locked to specific repositories or workspaces answers `403`, because every import spends the owner's stored GitHub credential on a repository the token was never scoped to. Sessions and unrestricted tokens are unaffected. The import queue is bounded: `429` when the caller already has the per-user maximum of imports queued or running, `503` when the platform-wide queue is full. Both are retryable and carry `Retry-After`, and both land before any GitHub call and **before the repository is created**.
Requires authentication using a session cookie or a bearer token — see tokens and scopes.
curl
curl -X POST 'https://neosource.dev/api/github/imports' \
-H 'Authorization: Bearer $NEOSOURCE_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"source_full_name":"string"}'fetch
fetch("https://neosource.dev/api/github/imports", {
method: "POST",
headers: {
Authorization: "Bearer $NEOSOURCE_TOKEN",
"Content-Type": "application/json",
},
body: JSON.stringify({"source_full_name":"string"}),
});Request bodyrequired
application/json
Responses
202Repo created and import enqueued
application/json
Standard errors
Bodies documented once for the whole API — see standard errors.
- 400Bad Request — one of: invalid_input
- 401Authentication required
- 403Forbidden — one of: forbidden, github_app_install_required
- 404Not Found — one of: not_found
- 409Conflict — one of: already_exists, conflict, relationship_conflict, relationship_unavailable
- 429Rate limited — retry after the `Retry-After` header
- 500Internal server error
- 503Service temporarily unavailable / at capacity — retry after the `Retry-After` header
- 504Gateway timeout — the request exceeded the server's handling budget