Integrate your Git providers (like GitHub, GitLab, or Bitbucket) directly into your workspace using our API. By connecting a Git provider, you can programmatically manage installations, sync repositories, and read file contents across your organization.
The Installation Flow
Connecting a Git provider requires a standard OAuth flow. You will request an installation URL, direct the user to authorize the application, and then handle the callback to finalize the setup.
sequenceDiagram
participant Client as Your App
participant API as Our API
participant Provider as Git Provider
Client->>API: GET /install-url
API-->>Client: Returns OAuth Authorization URL
Client->>Provider: Redirects user to authorize
Provider-->>API: POST /callback (with auth code)
API-->>Client: Installation completeSetting up a new provider
- 1
Get the installation URL
First, retrieve the OAuth authorization URL for the Git provider you want to connect. Direct your user to this URL so they can grant access to their repositories.
GET /v1/organizations/{organization_id}/git-provider/install-url - 2
Handle the callback
Once the user authorizes the application, the Git provider will redirect them back with an authorization code. Send this data to the callback endpoint to complete the installation.
POST /v1/organizations/{organization_id}/git-provider/callback - 3
Verify the installation
Confirm the setup was successful by listing the active installations for your organization.
GET /v1/organizations/{organization_id}/git-provider/installations
Store the installation_id returned from the installations list. You will need it to manage the connection or delete it in the future.
Managing Installations
You can view or remove Git provider connections at any time using their unique installation IDs.
Get a specific installation:
GET /v1/organizations/{organization_id}/git-provider/installations/{installation_id}Delete an installation:
DELETE /v1/organizations/{organization_id}/git-provider/installations/{installation_id}
Deleting an installation immediately revokes access to all associated repositories and files. Any automated syncs relying on this connection will fail.
Working with Repositories
Once a Git provider is installed, you can sync and manage the repositories your organization has access to.
Syncing and Listing
To ensure you have the latest list of repositories available from the provider, you should trigger a sync. After syncing, you can retrieve the full list.
Sync repositories:
POST /v1/organizations/{organization_id}/git-provider/repositories/syncList all repositories:
GET /v1/organizations/{organization_id}/git-provider/repositoriesGet a single repository:
GET /v1/organizations/{organization_id}/git-provider/repositories/{repository_id}
Accessing File Content
You can programmatically explore the file system and retrieve the contents of specific files within a repository.
Get repository file tree: Use
GET /v1/organizations/{organization_id}/git-provider/repositories/{repository_id}/treeto retrieve the folder and file structure of the repository.Get file content: Use
GET /v1/organizations/{organization_id}/git-provider/repositories/{repository_id}/contentto read the raw content of a specific file.
File content endpoints typically require you to specify the file path and optionally the branch or commit SHA as query parameters. Check the API reference for exact parameter requirements.
API Endpoint Summary
Here is a quick reference of all Git provider endpoints available for your organization:
| Action | Method | Endpoint Path |
|---|---|---|
| Get Install URL | GET | /git-provider/install-url |
| OAuth Callback | POST | /git-provider/callback |
| List Installations | GET | /git-provider/installations |
| Get Installation | GET | /git-provider/installations/{installation_id} |
| Delete Installation | DELETE | /git-provider/installations/{installation_id} |
| Sync Repositories | POST | /git-provider/repositories/sync |
| List Repositories | GET | /git-provider/repositories |
| Get Repository | GET | /git-provider/repositories/{repository_id} |
| Get File Tree | GET | /git-provider/repositories/{repository_id}/tree |
| Get File Content | GET | /git-provider/repositories/{repository_id}/content |
(Note: All paths above are prefixed with /v1/organizations/{organization_id})