GuidesConnect GitHub or GitLab
Connect with the API
A script connects an account with an access token, then lists repositories and branches.
curl -s -X POST http://127.0.0.1:7878/api/v1/git/connections \
-H "Authorization: Bearer $FERRY_TOKEN" -H 'Content-Type: application/json' \
-d '{"provider": "github", "token": "<access token>"}'The dashboard uses the git endpoints of the API. A script uses an access token, because no person is there to click on the page of the provider.
{
"id": "git-4db07471b4a74da2a889",
"provider": "github",
"base_url": "https://github.com",
"auth": "token",
"status": "connected",
"account": "you",
"account_name": "Your Name",
"token_hint": "…a1b2",
"scopes": ["repo"],
"token_expires_at": "2027-01-01T00:00:00Z",
"client_id": null,
"app_slug": null,
"app_url": null,
"manage_url": null,
"repository_selection": null,
"services": [],
"created_at": "2026-10-01T09:45:04.121655Z",
"updated_at": "2026-10-01T09:45:04.121655Z"
}List, then create a service
curl -s -H "Authorization: Bearer $FERRY_TOKEN" \
http://127.0.0.1:7878/api/v1/git/connections/git-4db07471b4a74da2a889/repositories
curl -s -G -H "Authorization: Bearer $FERRY_TOKEN" \
http://127.0.0.1:7878/api/v1/git/branches \
--data-urlencode 'repo_url=https://github.com/you/api.git'
# {"default_branch":"main","branches":["main","develop"],"connection_id":"git-4db07471b4a74da2a889"}
curl -s -X POST http://127.0.0.1:7878/api/v1/services \
-H "Authorization: Bearer $FERRY_TOKEN" -H 'Content-Type: application/json' \
-d '{"name": "api", "repo_url": "https://github.com/you/api.git", "branch": "main"}'The service names no connection. Its repo_url is on github.com. Thus Ferry clones it with the account that you connected there.
ferry create --repo … and blueprints work the same way.
Add "base_url": "https://gitlab.example.com" when you connect.
GET /api/v1/git/branches reads the branches from the repository itself (git ls-remote), the same way a deploy clones it. It works for each URL that a service can deploy from.
- Call
POST /api/v1/git/authorizewith aredirect_uri. The answer has the page to open.method: postmeans: submit a form withfields. - The provider sends the browser back to
redirect_uri. Give its query parameters toPOST /api/v1/git/callback. - Do these steps again while the
statusof the answer isredirect.