Search

Configure and manage search settings for your content.

get
Authorizations
Path parameters
spaceIdstringrequired

The unique id of the space

Query parameters
querystring · max: 512required
pagestringoptional

Identifier of the page results to fetch.

limitnumber · max: 1000optional

The number of results per page

Responses
curl -L \
  --url 'https://api.gitbook.com/v1/spaces/{spaceId}/search?query=text' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN'
{
  "next": {
    "page": "text"
  },
  "count": 1,
  "items": [
    {
      "id": "text",
      "title": "text",
      "path": "text",
      "sections": [
        {
          "id": "text",
          "title": "text",
          "path": "text",
          "body": "text",
          "urls": {
            "app": "https://example.com"
          }
        }
      ],
      "urls": {
        "app": "https://example.com"
      }
    }
  ]
}

Ask a question.

post
Authorizations
Path parameters
organizationIdstringrequired

The unique id of the organization

Query parameters
formatstring · enumoptional

Output format for the content.

Available options:
detailsbooleanoptional

Return query details in the result

Body
querystringrequired
previousQueriesstring[] · max: 10optionalDeprecated
Responses
curl -L \
  --request POST \
  --url 'https://api.gitbook.com/v1/orgs/{organizationId}/ask' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "query": "text",
    "previousQueries": [
      "text"
    ]
  }'
{
  "answer": {
    "answer": {
      "markdown": "text"
    },
    "followupQuestions": [
      "text"
    ],
    "sources": [
      {
        "type": "page",
        "reason": "text",
        "page": "text",
        "revision": "text",
        "space": "text",
        "sections": [
          "text"
        ]
      }
    ]
  }
}

Get a list of questions recommended to be asked in an organization.

get
Authorizations
Path parameters
organizationIdstringrequired

The unique id of the organization

Responses
curl -L \
  --url 'https://api.gitbook.com/v1/orgs/{organizationId}/ask/questions' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN'
{
  "questions": [
    "text"
  ]
}

Stream a list of questions recommended to be asked in an organization.

get
Authorizations
Path parameters
organizationIdstringrequired

The unique id of the organization

Responses
curl -L \
  --url 'https://api.gitbook.com/v1/orgs/{organizationId}/ask/questions/stream' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN'
{
  "question": "text"
}

Ask a question to an AI across spaces that is accessible by the currently authenticated target and stream the answer as a Server-Sent Events URL.

get
Authorizations
Path parameters
organizationIdstringrequired

The unique id of the organization

Query parameters
querystringrequired
formatstring · enumoptional

Output format for the content.

Available options:
detailsbooleanoptional

Return query details in the result

Responses
curl -L \
  --url 'https://api.gitbook.com/v1/orgs/{organizationId}/ask/stream?query=text' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN'
{
  "type": "answer",
  "answer": {
    "answer": {
      "markdown": "text"
    },
    "followupQuestions": [
      "text"
    ],
    "sources": [
      {
        "type": "page",
        "reason": "text",
        "page": "text",
        "revision": "text",
        "space": "text",
        "sections": [
          "text"
        ]
      }
    ]
  }
}

Ask a question in a site. The response is streamed.

post
Authorizations
Path parameters
organizationIdstringrequired

The unique id of the organization

siteIdstringrequired

The unique id of the site

Query parameters
formatstring · enumoptional

Output format for the content.

Available options:
Body
questionstring · max: 512required
contextobjectoptional

You may optionally provide additional information about the context of the question. This doesn't affect the scope of the search, but GitBook may use this information to provide a better answer. Generally speaking, you should provide as much context as possible.

scopeone ofrequired

Responses
curl -L \
  --request POST \
  --url 'https://api.gitbook.com/v1/orgs/{organizationId}/sites/{siteId}/ask' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "question": "text",
    "context": {
      "siteSpaceId": "text"
    },
    "scope": {
      "mode": "default",
      "includedSiteSpaces": [
        "text"
      ]
    }
  }'
{
  "type": "answer",
  "answer": {
    "answer": {
      "markdown": "text"
    },
    "followupQuestions": [
      "text"
    ],
    "sources": [
      {
        "type": "page",
        "reason": "text",
        "page": "text",
        "revision": "text",
        "space": "text",
        "sections": [
          "text"
        ]
      }
    ]
  }
}

Stream a list of questions that can be asked in a site.

get
Authorizations
Path parameters
organizationIdstringrequired

The unique id of the organization

siteIdstringrequired

The unique id of the site

Responses
curl -L \
  --url 'https://api.gitbook.com/v1/orgs/{organizationId}/sites/{siteId}/ask/questions' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN'
{
  "question": "text"
}

Was this helpful?