Git
Connected Git servers and linked repositories.
Every path is under /api/v1; see the API for authenticating, errors and rate
limits, and the schemas for the bodies.
The organization's connected Git installations (git:manage)
GET /api/v1/orgs/{org}/git/installations
| Parameter | In | Description |
|---|---|---|
org |
path | ID |
Answers:
200: OK, object with the fields below
| Field | Type | Description |
|---|---|---|
bitbucket_enabled |
boolean, required | This server connects Bitbucket Cloud workspaces. |
generic_enabled |
boolean, required | This server connects generic Git servers. |
gitea_enabled |
boolean, required | This server connects Gitea and Forgejo instances. |
github_enabled |
boolean, required | A GitHub App is configured on this server. |
gitlab_enabled |
boolean, required | This server connects to GitLab instances. |
installations |
array of GitInstallation, required |
Errors: 403, 404 (how errors look).
Connect a GitLab instance with an access token (git:manage)
POST /api/v1/orgs/{org}/git/gitlab
The token needs the api scope; linking a project needs Maintainer access to it, since Forge adds the project's webhook. The token is sealed with the organization's key and never returned. Connecting the same token user again replaces the token. The URL must be https and reachable on a public address unless the server allows otherwise.
| Parameter | In | Description |
|---|---|---|
org |
path | ID |
Body (application/json): object.
| Field | Type | Description |
|---|---|---|
token |
string, required | |
url |
string, required | The instance, like https://gitlab.com. |
Answers:
200: Connected, GitInstallation
Errors: 400, 403, 404, 409, 422, 502 (how errors look).
Connect a Gitea or Forgejo instance with an access token (git:manage)
POST /api/v1/orgs/{org}/git/gitea
Use a bot user's token: Gitea's tokens reach everything their user can. It needs the write:repository and read:user scopes; linking a repository needs admin access to it, since Forge adds its webhook. The token is sealed with the organization's key and never returned. Connecting the same token user again replaces the token.
| Parameter | In | Description |
|---|---|---|
org |
path | ID |
Body (application/json): object.
| Field | Type | Description |
|---|---|---|
token |
string, required | |
url |
string, required | The instance, like https://codeberg.org. |
Answers:
200: Connected, GitInstallation
Errors: 400, 403, 404, 409, 422, 502 (how errors look).
Connect a Bitbucket Cloud workspace with an access token (git:manage)
POST /api/v1/orgs/{org}/git/bitbucket
Use a workspace access token with the repository, pullrequest and webhook scopes and admin access to the repositories to link (Forge adds their webhooks, sets build statuses and asks for fork authors' permissions). The token is sealed with the organization's key and never returned. Connecting the same workspace again replaces the token.
| Parameter | In | Description |
|---|---|---|
org |
path | ID |
Body (application/json): object.
| Field | Type | Description |
|---|---|---|
token |
string, required | |
workspace |
string, required | The workspace's ID, as in bitbucket.org/acme. |
Answers:
200: Connected, GitInstallation
Errors: 400, 403, 404, 409, 422, 502 (how errors look).
Connect a generic Git server (git:manage)
POST /api/v1/orgs/{org}/git/generic
Any Git server that can send a signed webhook. Forge can't call it: its repositories are linked by path, and it gets no commit statuses, deployments or run files. The URL is the base its repositories are cloned from (https unless the server allows otherwise).
| Parameter | In | Description |
|---|---|---|
org |
path | ID |
Body (application/json): object.
| Field | Type | Description |
|---|---|---|
name |
string, required | What the server is called in Forge (1 to 100 characters). |
url |
string, required | The base clone URL, like https://git.example.com. |
Answers:
200: Connected, GitInstallation
Errors: 400, 403, 404, 422 (how errors look).
Start connecting a GitHub App installation (git:manage, users only)
POST /api/v1/orgs/{org}/git/github/connect
Returns where to send the browser: install_url to install the app on an account, authorize_url to pick an installation that exists already. Both come back to /git/github/callback with a state that is valid for 30 minutes.
| Parameter | In | Description |
|---|---|---|
org |
path | ID |
Answers:
200: OK, object with the fields below
| Field | Type | Description |
|---|---|---|
authorize_url |
string, required | |
install_url |
string, required |
Errors: 403, 404 (how errors look).
Finish the GitHub redirect
POST /api/v1/git/github/callback
Exchanges the code for the installations the GitHub user can see. When GitHub named an installation that may be connected, it is connected right away; otherwise pick one of the choices with /git/github/installations.
Body (application/json): object.
| Field | Type | Description |
|---|---|---|
code |
string, required | |
installation_id |
integer | GitHub's, from the callback URL. |
state |
string, required |
Answers:
200: OK, object with the fields below
| Field | Type | Description |
|---|---|---|
choices |
array of GitChoice, required | |
connected |
GitInstallation | A Git connection of an organization: a GitHub App installation, a GitLab instance's access token, a generic Git server or a Gitea or Forgejo instance's access token. |
organization_id |
ID, required |
Errors: 400, 403, 404, 409 (how errors look).
Connect one of the callback's choices (git:manage)
POST /api/v1/git/github/installations
Body (application/json): object.
| Field | Type | Description |
|---|---|---|
installation_id |
integer, required | |
state |
string, required |
Answers:
200: OK, GitInstallation
Errors: 400, 403, 404, 409 (how errors look).
Disconnect an installation, unlinking its repositories everywhere (git:manage)
DELETE /api/v1/git/installations/{installation}
The app stays installed on GitHub until it is uninstalled there.
| Parameter | In | Description |
|---|---|---|
installation |
path | ID |
Answers:
204: Disconnected
Errors: 403, 404 (how errors look).
The project's linked repositories (project:read)
GET /api/v1/projects/{project}/repositories
| Parameter | In | Description |
|---|---|---|
project |
path | ID |
Answers:
200: OK, object with the fields below
| Field | Type | Description |
|---|---|---|
bitbucket_enabled |
boolean, required | |
generic_enabled |
boolean, required | |
gitea_enabled |
boolean, required | |
github_enabled |
boolean, required | |
gitlab_enabled |
boolean, required | |
repositories |
array of Repository, required |
Errors: 403, 404 (how errors look).
Link a repository of the organization's installations (project:manage)
POST /api/v1/projects/{project}/repositories
A project links at most 100 repositories.
| Parameter | In | Description |
|---|---|---|
project |
path | ID |
Body (application/json): object.
| Field | Type | Description |
|---|---|---|
external_id |
integer, required | |
installation_id |
ID, required |
Answers:
201: Linked, Repository
Errors: 400, 403, 404, 409, 422, 502 (how errors look).
Link a generic Git server's repository by its path (project:manage)
POST /api/v1/projects/{project}/repositories/generic
The answer has the link's webhook URL and signing secret, shown only now: the server signs each delivery with it (see). checkout_secret names a project secret, not restricted to templates, stored flows or runner labels, whose value is the HTTPS password for cloning; without one the repository is cloned without credentials.
| Parameter | In | Description |
|---|---|---|
project |
path | ID |
Body (application/json): object.
| Field | Type | Description |
|---|---|---|
checkout_secret |
string | |
checkout_username |
string | Defaults to git. |
default_branch |
string | Defaults to main. |
installation_id |
ID, required | |
path |
string, required | Like group/app.git: appended to the server's URL to clone it. |
private |
boolean |
Answers:
201: Linked, GenericLink
Errors: 400, 403, 404, 409, 422 (how errors look).
Give a generic Git server's link a new signing secret (project:manage)
POST /api/v1/repositories/{repository}/signing-secret
The old secret stops working at once.
| Parameter | In | Description |
|---|---|---|
repository |
path | ID |
Answers:
200: Rotated, object with the fields below
| Field | Type | Description |
|---|---|---|
hook_url |
string, required | |
signing_secret |
string, required |
Errors: 403, 404, 422 (how errors look).
Set the project secret a generic or Gitea link is cloned with (project:manage)
PUT /api/v1/repositories/{repository}/checkout
The secret's current value is the HTTPS password, with the username ("git" when empty). An empty secret clones without credentials (a public repository). GitHub and GitLab links get minted tokens instead (422).
| Parameter | In | Description |
|---|---|---|
repository |
path | ID |
Body (application/json): object.
| Field | Type | Description |
|---|---|---|
checkout_secret |
string | |
checkout_username |
string |
Answers:
200: Set, Repository
Errors: 403, 404, 422 (how errors look).
Repositories the organization's installations can reach (project:manage)
GET /api/v1/projects/{project}/repositories/available
| Parameter | In | Description |
|---|---|---|
project |
path | ID |
Answers:
200: OK, object with the fields below
| Field | Type | Description |
|---|---|---|
repositories |
array of AvailableRepository, required | |
servers |
array of GitInstallation, required | The organization's generic Git servers, whose repositories are linked by path. |
Errors: 403, 404, 502 (how errors look).
Unlink a repository from its project (project:manage)
DELETE /api/v1/repositories/{repository}
| Parameter | In | Description |
|---|---|---|
repository |
path | ID |
Answers:
204: Unlinked
Errors: 403, 404 (how errors look).