Content

Content in GitBook is the entity for content on a page.

GET the primary content in a space

Get the current primary content revision for a space

GEThttps://api.gitbook.com/v1/spaces/{spaceId}/content
Authorization
Path parameters
spaceId*string

The unique id of the space

Query parameters
Response

OK

Body
Revision (one of)
Request
const response = await fetch('https://api.gitbook.com/v1/spaces/{spaceId}/content', {
    method: 'GET',
    headers: {
      "Authorization": "Bearer <token>"
    },
});
const data = await response.json();
Response
{
  "object": "revision",
  "id": "text",
  "parents": [
    "text"
  ],
  "pages": [
    {
      "id": "text",
      "title": "text",
      "emoji": "🎉",
      "icon": "gear",
      "createdAt": "2024-11-21T07:26:46.412Z",
      "updatedAt": "2024-11-21T07:26:46.412Z",
      "markdown": "text",
      "type": "document",
      "urls": {
        "app": "https://example.com"
      },
      "slug": "text",
      "path": "text",
      "description": "text",
      "documentId": "text",
      "pages": [],
      "git": {
        "oid": "text",
        "path": "text"
      },
      "layout": {
        "cover": false,
        "coverSize": "hero",
        "title": false,
        "description": false,
        "tableOfContents": false,
        "outline": false,
        "pagination": false
      },
      "cover": {
        "ref": {
          "kind": "file",
          "file": "text"
        },
        "yPos": 0
      },
      "hidden": false,
      "noIndex": false,
      "noRobotsIndex": false,
      "computed": {
        "integration": "text",
        "source": "text",
        "props": {},
        "dependsOn": [
          {
            "kind": "space",
            "space": "text"
          }
        ]
      }
    }
  ],
  "files": [
    {
      "id": "text",
      "name": "text",
      "contentType": "text",
      "downloadURL": "text",
      "size": 0,
      "dimensions": {
        "width": 0,
        "height": 0
      },
      "git": {
        "oid": "text",
        "path": "text"
      }
    }
  ],
  "reusableContents": [
    {
      "id": "text",
      "title": "text",
      "document": "text",
      "git": {
        "oid": "text",
        "path": "text"
      }
    }
  ],
  "createdAt": "2024-11-21T07:26:46.412Z",
  "git": {
    "oid": "text",
    "message": "text",
    "createdByGitBook": false,
    "url": "text",
    "ref": "text"
  },
  "urls": {
    "app": "https://example.com",
    "published": "https://example.com",
    "public": "https://example.com"
  },
  "type": "edits"
}

GET files for the primary content in a space

List all files for the main revision content of a space

GEThttps://api.gitbook.com/v1/spaces/{spaceId}/content/files
Authorization
Path parameters
spaceId*string

The unique id of the space

Query parameters
Response

OK

Body
nextobject
countnumber

Total count of objects in the list

items*array of RevisionFile (object)
Request
const response = await fetch('https://api.gitbook.com/v1/spaces/{spaceId}/content/files', {
    method: 'GET',
    headers: {
      "Authorization": "Bearer <token>"
    },
});
const data = await response.json();
Response
{
  "next": {
    "page": "text"
  },
  "count": 0,
  "items": [
    {
      "id": "text",
      "name": "text",
      "contentType": "text",
      "downloadURL": "text",
      "size": 0,
      "dimensions": {
        "width": 0,
        "height": 0
      },
      "git": {
        "oid": "text",
        "path": "text"
      }
    }
  ]
}

GET a page from the primary content in a space by ID

Get a page by its ID in the primary content.

GEThttps://api.gitbook.com/v1/spaces/{spaceId}/content/page/{pageId}
Authorization
Path parameters
spaceId*string

The unique id of the space

pageId*string

The unique id of the page

Query parameters
Response

OK

Body
RevisionPage (one of)
Request
const response = await fetch('https://api.gitbook.com/v1/spaces/{spaceId}/content/page/{pageId}', {
    method: 'GET',
    headers: {
      "Authorization": "Bearer <token>"
    },
});
const data = await response.json();
Response
{
  "id": "text",
  "title": "text",
  "emoji": "🎉",
  "icon": "gear",
  "createdAt": "2024-11-21T07:26:46.412Z",
  "updatedAt": "2024-11-21T07:26:46.412Z",
  "markdown": "text",
  "type": "document",
  "urls": {
    "app": "https://example.com"
  },
  "slug": "text",
  "path": "text",
  "description": "text",
  "documentId": "text",
  "pages": [],
  "git": {
    "oid": "text",
    "path": "text"
  },
  "layout": {
    "cover": false,
    "coverSize": "hero",
    "title": false,
    "description": false,
    "tableOfContents": false,
    "outline": false,
    "pagination": false
  },
  "cover": {
    "ref": {
      "kind": "file",
      "file": "text"
    },
    "yPos": 0
  },
  "hidden": false,
  "noIndex": false,
  "noRobotsIndex": false,
  "computed": {
    "integration": "text",
    "source": "text",
    "props": {},
    "dependsOn": [
      {
        "kind": "space",
        "space": "text"
      }
    ]
  }
}

GET a page from the primary content in a space by path

Get a page by its path in the primary content.

GEThttps://api.gitbook.com/v1/spaces/{spaceId}/content/path/{pagePath}
Authorization
Path parameters
spaceId*string

The unique id of the space

pagePath*string

The path of the page in the revision.

Query parameters
Response

OK

Body
one of
Request
const response = await fetch('https://api.gitbook.com/v1/spaces/{spaceId}/content/path/{pagePath}', {
    method: 'GET',
    headers: {
      "Authorization": "Bearer <token>"
    },
});
const data = await response.json();
Response
{
  "id": "text",
  "title": "text",
  "emoji": "🎉",
  "icon": "gear",
  "createdAt": "2024-11-21T07:26:46.412Z",
  "updatedAt": "2024-11-21T07:26:46.412Z",
  "markdown": "text",
  "type": "document",
  "urls": {
    "app": "https://example.com"
  },
  "slug": "text",
  "path": "text",
  "description": "text",
  "documentId": "text",
  "pages": [],
  "git": {
    "oid": "text",
    "path": "text"
  },
  "layout": {
    "cover": false,
    "coverSize": "hero",
    "title": false,
    "description": false,
    "tableOfContents": false,
    "outline": false,
    "pagination": false
  },
  "cover": {
    "ref": {
      "kind": "file",
      "file": "text"
    },
    "yPos": 0
  },
  "hidden": false,
  "noIndex": false,
  "noRobotsIndex": false,
  "computed": {
    "integration": "text",
    "source": "text",
    "props": {},
    "dependsOn": [
      {
        "kind": "space",
        "space": "text"
      }
    ]
  }
}

POST content to a space

Import content in a space.

POSThttps://api.gitbook.com/v1/spaces/{spaceId}/content/import
Authorization
Path parameters
spaceId*string

The unique id of the space

Body
url*string

URL of the content to import.

source*ImportContentSource (enum)
websitedocxmarkdownhtmlzipconfluencegithub-wikidropbox-papernotionquipgoogle-docsopen-api
Response

Content imported in a new revision

Headers
Body
revision*string

ID of the newly created revision.

importedResources*number

How many resources were imported

totalResources*number

How many resources were processed

Request
const response = await fetch('https://api.gitbook.com/v1/spaces/{spaceId}/content/import', {
    method: 'POST',
    headers: {
      "Authorization": "Bearer <token>",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "url": "text",
      "source": "website"
    }),
});
const data = await response.json();
Response
{
  "revision": "text",
  "importedResources": 0,
  "totalResources": 0
}

POSTcontent to a page by ID

Import external content into a page by its ID.

POSThttps://api.gitbook.com/v1/spaces/{spaceId}/content/page/{pageId}/import
Authorization
Path parameters
spaceId*string

The unique id of the space

pageId*string

The unique id of the page

Body
url*string

URL of the content to import.

source*ImportContentSource (enum)
websitedocxmarkdownhtmlzipconfluencegithub-wikidropbox-papernotionquipgoogle-docsopen-api
Response

Content imported in a new revision

Headers
Body
revision*string

ID of the newly created revision.

importedResources*number

How many resources were imported

totalResources*number

How many resources were processed

Request
const response = await fetch('https://api.gitbook.com/v1/spaces/{spaceId}/content/page/{pageId}/import', {
    method: 'POST',
    headers: {
      "Authorization": "Bearer <token>",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "url": "text",
      "source": "website"
    }),
});
const data = await response.json();
Response
{
  "revision": "text",
  "importedResources": 0,
  "totalResources": 0
}

Last updated