Explore how adaptive content transforms your docs into a dynamic, tailored experience for every user.
Read the docs
LogoLogo
ProductPricingLog inSign up
  • Documentation
  • Developers
  • Guides
  • Changelog
  • Help Center
  • Getting Started
    • Developer Documentation
    • Quickstart
    • Development
    • Publishing
  • Integrations
    • Introduction
    • Using the CLI
    • Configuration
    • ContentKit
      • Component reference
    • Integration runtime
  • Client library
  • Guides
    • Creating a custom unfurl action
    • Creating interactive blocks
    • Referencing your integration in Markdown
    • Working with HTTP requests
    • Using the CLI in CI/CD
  • GitBook API
    • Introduction
    • Authentication
    • API reference
      • Organizations
        • Organization members
        • Organization invites
        • Organization AI ask
      • Docs sites
        • Site share links
        • Site structure
        • Site auth
        • Site preview
        • Site customization
        • Site spaces
        • Site sections
        • Site section groups
        • Site redirects
        • Site MCP servers
        • Site ads
        • Site users
        • Site insights
        • Site AI ask
      • Collections
        • Collection users
        • Collection teams
      • Spaces
        • Space content
        • Space comments
        • Space embeds
        • Space users
        • Space teams
        • Space integrations
        • Git
      • Change requests
        • Change request content
        • Change request contributors
        • Change request reviewers
        • Change request comments
      • Translations
        • Glossary
      • Integrations
      • URLs
      • OpenAPI
        • OpenAPI spec versions
      • Conversations
      • Custom fonts
      • Subdomains
      • Users
      • Teams
        • Team members
      • SSO
      • Storage
      • Custom hostnames
      • System info
    • Rate limiting
    • Pagination
    • Errors
  • Marketplace
    • Overview
    • Submit your app for review
  • Resources
    • Concepts
    • Changelog
    • ContentKit playground
    • GitHub examples
Powered by GitBook
On this page
  1. GitBook API
  2. API reference

OpenAPI

Upload, access, or version-control your OpenAPI specifications directly in GitBook.

Was this helpful?

LogoLogo

Resources

  • Showcase
  • Enterprise
  • Status

Company

  • Careers
  • Blog
  • Community

Policies

  • Subprocessors
  • Terms of Service
CtrlK
  • The OpenAPISpec object
  • GETList all OpenAPI spec
  • POSTCreate an OpenAPI spec
  • GETGet an OpenAPI spec by its slug
  • PUTCreate or update an OpenAPI spec
  • DELETEDelete an OpenAPI spec
  • PATCHUpdate OpenAPI spec visibility

Was this helpful?

The OpenAPI endpoints let you integrate your existing or newly generated OpenAPI definitions into GitBook. This includes uploading, updating, and retrieving specs.

The OpenAPISpec object

Attributes
objectstring · enumRequired

The object type, which is always "openapi-spec"

Possible values:
idstringRequired

Unique identifier

createdAtstring · date-timeRequired

Date of creation

updatedAtstring · date-timeRequired

Date of the last update

slugstring · min: 1 · max: 100Required

Slug used as reference

Pattern: ^[a-z0-9]+(?:-[a-z0-9]+)*$
sourceURLstring · uri · max: 2048Optional
processingStateundefined · enumRequired

Processing state

Possible values:
visibilitystring · enumOptional

The visibility setting of the OpenAPI spec.

  • private: The spec is not publicly available.
  • public: The spec is available to anyone with a public link.
Possible values:
lastVersionstringOptional

ID of the latest version of the OpenAPI specification

lastProcessedAtstring · date-timeOptional

Date of the last processing

lastProcessErrorCodeundefined · enumOptional

OpenAPI processing error code

Possible values:

The OpenAPISpec object

{
  "object": "openapi-spec",
  "id": "text",
  "createdAt": "2025-08-26T23:21:56.168Z",
  "updatedAt": "2025-08-26T23:21:56.168Z",
  "slug": "text",
  "sourceURL": "https://example.com",
  "processingState": "pending",
  "visibility": "private",
  "lastVersion": "text",
  "lastProcessedAt": "2025-08-26T23:21:56.168Z",
  "lastProcessErrorCode": "FETCH_TIMEOUT",
  "permissions": {
    "view": true,
    "edit": true
  },
  "urls": {
    "location": "https://example.com",
    "app": "https://example.com",
    "published": "https://example.com"
  }
}

List all OpenAPI spec

get
Authorizations
Path parameters
organizationIdstringRequired

The unique id of the organization

Query parameters
pagestringOptional

Identifier of the page results to fetch.

limitnumber · max: 1000Optional

The number of results per page

Responses
200

OK

application/json
Responseall of
get
GET /v1/orgs/{organizationId}/openapi HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
200

OK

{
  "next": {
    "page": "text"
  },
  "count": 1,
  "items": [
    {
      "object": "openapi-spec",
      "id": "text",
      "createdAt": "2025-08-26T23:21:56.168Z",
      "updatedAt": "2025-08-26T23:21:56.168Z",
      "slug": "text",
      "sourceURL": "https://example.com",
      "processingState": "pending",
      "visibility": "private",
      "lastVersion": "text",
      "lastProcessedAt": "2025-08-26T23:21:56.168Z",
      "lastProcessErrorCode": "FETCH_TIMEOUT",
      "permissions": {
        "view": true,
        "edit": true
      },
      "urls": {
        "location": "https://example.com",
        "app": "https://example.com",
        "published": "https://example.com"
      }
    }
  ]
}

Create an OpenAPI spec

post
Authorizations
Path parameters
organizationIdstringRequired

The unique id of the organization

Body
slugstring · min: 1 · max: 100Required

Slug used as reference

Pattern: ^[a-z0-9]+(?:-[a-z0-9]+)*$
sourceone ofRequired
or
Responses
201

OpenAPI specification has been created

application/json
400

Bad Request

application/json
post
POST /v1/orgs/{organizationId}/openapi HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 54

{
  "slug": "text",
  "source": {
    "url": "https://example.com"
  }
}
{
  "object": "openapi-spec",
  "id": "text",
  "createdAt": "2025-08-26T23:21:56.168Z",
  "updatedAt": "2025-08-26T23:21:56.168Z",
  "slug": "text",
  "sourceURL": "https://example.com",
  "processingState": "pending",
  "visibility": "private",
  "lastVersion": "text",
  "lastProcessedAt": "2025-08-26T23:21:56.168Z",
  "lastProcessErrorCode": "FETCH_TIMEOUT",
  "permissions": {
    "view": true,
    "edit": true
  },
  "urls": {
    "location": "https://example.com",
    "app": "https://example.com",
    "published": "https://example.com"
  }
}

Get an OpenAPI spec by its slug

get
Authorizations
Path parameters
organizationIdstringRequired

The unique id of the organization

specSlugstringRequired

Slug of the OpenAPI specification

Responses
200

OK

application/json
404

No matching OpenAPI specification found

application/json
get
GET /v1/orgs/{organizationId}/openapi/{specSlug} HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
  "object": "openapi-spec",
  "id": "text",
  "createdAt": "2025-08-26T23:21:56.168Z",
  "updatedAt": "2025-08-26T23:21:56.168Z",
  "slug": "text",
  "sourceURL": "https://example.com",
  "processingState": "pending",
  "visibility": "private",
  "lastVersion": "text",
  "lastProcessedAt": "2025-08-26T23:21:56.168Z",
  "lastProcessErrorCode": "FETCH_TIMEOUT",
  "permissions": {
    "view": true,
    "edit": true
  },
  "urls": {
    "location": "https://example.com",
    "app": "https://example.com",
    "published": "https://example.com"
  }
}

Create or update an OpenAPI spec

put
Authorizations
Path parameters
organizationIdstringRequired

The unique id of the organization

specSlugstringRequired

Slug of the OpenAPI specification

Body
sourceone ofRequired
or
Responses
200

OpenAPI specification has been updated

application/json
201

OpenAPI specification has been created

application/json
400

Bad Request

application/json
put
PUT /v1/orgs/{organizationId}/openapi/{specSlug} HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 40

{
  "source": {
    "url": "https://example.com"
  }
}
{
  "object": "openapi-spec",
  "id": "text",
  "createdAt": "2025-08-26T23:21:56.168Z",
  "updatedAt": "2025-08-26T23:21:56.168Z",
  "slug": "text",
  "sourceURL": "https://example.com",
  "processingState": "pending",
  "visibility": "private",
  "lastVersion": "text",
  "lastProcessedAt": "2025-08-26T23:21:56.168Z",
  "lastProcessErrorCode": "FETCH_TIMEOUT",
  "permissions": {
    "view": true,
    "edit": true
  },
  "urls": {
    "location": "https://example.com",
    "app": "https://example.com",
    "published": "https://example.com"
  }
}

Delete an OpenAPI spec

delete
Authorizations
Path parameters
organizationIdstringRequired

The unique id of the organization

specSlugstringRequired

Slug of the OpenAPI specification

Responses
204

Specification did not exist

205

OpenAPI specification has been deleted

delete
DELETE /v1/orgs/{organizationId}/openapi/{specSlug} HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*

No content

Update OpenAPI spec visibility

patch
Authorizations
Path parameters
organizationIdstringRequired

The unique id of the organization

specSlugstringRequired

Slug of the OpenAPI specification

Body
visibilitystring · enumRequired

The visibility setting of the OpenAPI spec.

  • private: The spec is not publicly available.
  • public: The spec is available to anyone with a public link.
Possible values:
Responses
200

OpenAPI specification visibility has been updated

application/json
400

Bad Request

application/json
404

No matching OpenAPI specification found

application/json
patch
PATCH /v1/orgs/{organizationId}/openapi/{specSlug} HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 24

{
  "visibility": "private"
}
{
  "object": "openapi-spec",
  "id": "text",
  "createdAt": "2025-08-26T23:21:56.168Z",
  "updatedAt": "2025-08-26T23:21:56.168Z",
  "slug": "text",
  "sourceURL": "https://example.com",
  "processingState": "pending",
  "visibility": "private",
  "lastVersion": "text",
  "lastProcessedAt": "2025-08-26T23:21:56.168Z",
  "lastProcessErrorCode": "FETCH_TIMEOUT",
  "permissions": {
    "view": true,
    "edit": true
  },
  "urls": {
    "location": "https://example.com",
    "app": "https://example.com",
    "published": "https://example.com"
  }
}