OpenAPI

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

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"

Available options:
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

Available options:
lastVersionstringoptional

ID of the latest version of the OpenAPI specification

lastProcessedAtstring · date-timeoptional

Date of the last processing

lastProcessErrorCodeundefined · enumoptional

OpenAPI processing error code

Available options:
permissionsobjectrequired

The set of permissions for the OpenAPI specification.

urlsobjectrequired

URLs associated with the object

The OpenAPISpec object

{
  "object": "openapi-spec",
  "id": "text",
  "createdAt": "2025-04-16T04:38:07.745Z",
  "updatedAt": "2025-04-16T04:38:07.745Z",
  "slug": "text",
  "sourceURL": "https://example.com",
  "processingState": "pending",
  "lastVersion": "text",
  "lastProcessedAt": "2025-04-16T04:38:07.745Z",
  "lastProcessErrorCode": "FETCH_TIMEOUT",
  "permissions": {
    "edit": true
  },
  "urls": {
    "location": "https://example.com",
    "app": "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
application/json
all ofoptional
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-04-16T04:38:07.745Z",
      "updatedAt": "2025-04-16T04:38:07.745Z",
      "slug": "text",
      "sourceURL": "https://example.com",
      "processingState": "pending",
      "lastVersion": "text",
      "lastProcessedAt": "2025-04-16T04:38:07.745Z",
      "lastProcessErrorCode": "FETCH_TIMEOUT",
      "permissions": {
        "edit": true
      },
      "urls": {
        "location": "https://example.com",
        "app": "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

Create a specification from an URL

Create a specification from a text string

Responses
application/json
objectoptional
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-04-16T04:38:07.745Z",
  "updatedAt": "2025-04-16T04:38:07.745Z",
  "slug": "text",
  "sourceURL": "https://example.com",
  "processingState": "pending",
  "lastVersion": "text",
  "lastProcessedAt": "2025-04-16T04:38:07.745Z",
  "lastProcessErrorCode": "FETCH_TIMEOUT",
  "permissions": {
    "edit": true
  },
  "urls": {
    "location": "https://example.com",
    "app": "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
application/json
objectoptional
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-04-16T04:38:07.745Z",
  "updatedAt": "2025-04-16T04:38:07.745Z",
  "slug": "text",
  "sourceURL": "https://example.com",
  "processingState": "pending",
  "lastVersion": "text",
  "lastProcessedAt": "2025-04-16T04:38:07.745Z",
  "lastProcessErrorCode": "FETCH_TIMEOUT",
  "permissions": {
    "edit": true
  },
  "urls": {
    "location": "https://example.com",
    "app": "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

Create a specification from an URL

Create a specification from a text string

Responses
application/json
objectoptional
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-04-16T04:38:07.745Z",
  "updatedAt": "2025-04-16T04:38:07.745Z",
  "slug": "text",
  "sourceURL": "https://example.com",
  "processingState": "pending",
  "lastVersion": "text",
  "lastProcessedAt": "2025-04-16T04:38:07.745Z",
  "lastProcessErrorCode": "FETCH_TIMEOUT",
  "permissions": {
    "edit": true
  },
  "urls": {
    "location": "https://example.com",
    "app": "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
delete
DELETE /v1/orgs/{organizationId}/openapi/{specSlug} HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
205

OpenAPI specification has been deleted

No Content

Was this helpful?