For the complete documentation index, see llms.txt. This page is also available as Markdown.

Pull content into a space from a connected Git repository

Triggers an import from provided Git repository into the space, updating the space's content to match the repository (if not standalone). This is an async operation — it runs in the background after the request returns 204.

Available in MCP
post
Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Path parameters
spaceIdstringRequired

A unique entity identifier

Pattern: ^[a-zA-Z0-9_-]+$
Body
urlstringRequired

URL of the Git repository to import. It can contain basic auth credentials.

refstringRequired

Git ref to import in the format "refs/heads/main"

repoCacheIDstringOptionalDeprecated

Unique identifier to use to cache the Git repository across multiple operations.

repoTreeURLstringOptional

URL to use as a prefix for external file references.

repoCommitURLstringOptional

URL to use as a prefix for the commit URL.

repoProjectDirectorystringOptional

Path to a root directory for the project in the repository.

timestampstring · date-timeOptional

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.

forcebooleanOptional
standalonebooleanOptional

If true, the import will generate a revision without updating the space primary content.

Responses
204

Operation to import the repository has been queued.

No content

post/spaces/{spaceId}/git/import
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: 171

{
  "url": "text",
  "ref": "text",
  "repoTreeURL": "text",
  "repoCommitURL": "text",
  "repoProjectDirectory": "text",
  "timestamp": "2026-01-01T00:00:00.000Z",
  "force": true,
  "standalone": true
}
204

Operation to import the repository has been queued.

No content

Last updated

Was this helpful?

Powered by GitBook