Quickstart

The GitBook API allows you to read and write information across the spaces and pages you have access to in GitBook.

You can use the GitBook API to:

  • Create, update, and delete organizations, spaces, collections, and published docs sites

  • Manage users, teams, and access permissions at both the space and organization level

  • Import and export content (pages, files, and reusable content)

  • Create, list, review, merge, and update change requests

  • Post, retrieve, update, and delete comments (and comment replies)

  • Configure custom hostnames, URLs, and search settings

  • Monitor content performance with analytics endpoints

  • Manage integrations and OpenAPI documentation

…and much more, all via simple REST calls.

Getting started

You’ll need a GitBook account to start using the developer platform. If you don’t already have an account, you can sign up for free here.

Create a personal access token

After creating a GitBook account, you'll be able to create a personal access token in your developer settings.

This token represents your user in GitBook, and allows you to make API calls, create integrations, and publish them to any GitBook spaces you're a part of to test them.

Once you have your personal access token, you'll want to understand the differences between the pieces of the GitBook Integrations Platform in order to start developing your first app.

Make your first API call

The example below shows how to make an API call that asks GitBook Assistant a question in a site within your organization.

To query a GitBook site using the Ask API, send a POST request to the /v1/orgs/{organizationId}/sites/{siteId}/ask endpoint. Include your developer token for authentication, provide the question you want answered, and optionally pass context and scope settings.

Make a basic Ask API request

  1. Set your required headers:

    • Authorization: Bearer YOUR_SECRET_TOKEN

    • Content-Type: application/json

  2. Send a POST request with your query details:

POST /v1/orgs/{organizationId}/sites/{siteId}/ask HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*

{
  "question": "How do I get started?",
  "scope": {
    "mode": "default",
  }
}

The API will return an answer generated from your site’s content.

GitBook’s API has many different API calls that allow you to interact with GitBook in different ways. After sending your first request, head to the API reference to explore the different endpoints GitBook offers.

Explore GitBook’s API

Last updated

Was this helpful?