Git
Connect Git repositories to your space for seamless version control.
Manage the linkage between your GitBook space and external Git repositories, enabling commits, merges, and pull requests directly tied to your documentation.
The unique id of the space
URL of the Git repository to import. It can contain basic auth credentials.
Git ref to import in the format "refs/heads/main"
Unique identifier to use to cache the Git repository across multiple operations.
URL to use as a prefix for external file references.
URL to use as a prefix for the commit URL.
Path to a root directory for the project in the repository.
The timestamp of the event that triggered this import. It ensures that Git sync import and export operations are executed in the same order on GitBook and on the remote repository.
If true, the import will generate a revision without updating the space primary content.
POST /v1/spaces/{spaceId}/git/import HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 237
{
"url": "text",
"ref": "text",
"repoCacheID": "text",
"repoTreeURL": "text",
"repoCommitURL": "text",
"repoProjectDirectory": "text",
"timestamp": "2025-06-21T02:26:33.714Z",
"force": true,
"standalone": true,
"gitInfo": {
"provider": "github",
"url": "text"
}
}
Operation to import the repository has been started.
No content
The unique id of the space
URL of the Git repository to export to. It can contain basic auth credentials.
Git ref to push the commit to in the format "refs/heads/main"
Message for the commit generated by the export
Unique identifier to use to cache the Git repository across multiple operations.
URL to use as a prefix for external file references.
URL to use as a prefix for the commit URL.
Path to a root directory for the project in the repository.
The timestamp of the event that triggered this export. It ensures that Git sync import and export operations are executed in the same order on GitBook and on the remote repository.
POST /v1/spaces/{spaceId}/git/export HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 242
{
"url": "text",
"ref": "text",
"commitMessage": "text",
"repoCacheID": "text",
"repoTreeURL": "text",
"repoCommitURL": "text",
"repoProjectDirectory": "text",
"timestamp": "2025-06-21T02:26:33.714Z",
"force": true,
"gitInfo": {
"provider": "github",
"url": "text"
}
}
Operation to export the space has been started.
No content
Get metadata about the Git Sync provider currently set up on the space.
The unique id of the space
GET /v1/spaces/{spaceId}/git/info HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
"repoName": "text",
"installationProvider": "github",
"integration": "text",
"url": "text",
"updatedAt": "2025-06-21T02:26:33.714Z"
}
Was this helpful?