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-16T23:15:52.121Z",
  "updatedAt": "2025-04-16T23:15:52.121Z",
  "slug": "text",
  "sourceURL": "https://example.com",
  "processingState": "pending",
  "lastVersion": "text",
  "lastProcessedAt": "2025-04-16T23:15:52.121Z",
  "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
curl -L \
  --url 'https://api.gitbook.com/v1/orgs/{organizationId}/openapi' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN'
{
  "next": {
    "page": "text"
  },
  "count": 1,
  "items": [
    {
      "object": "openapi-spec",
      "id": "text",
      "createdAt": "2025-04-16T23:15:52.121Z",
      "updatedAt": "2025-04-16T23:15:52.121Z",
      "slug": "text",
      "sourceURL": "https://example.com",
      "processingState": "pending",
      "lastVersion": "text",
      "lastProcessedAt": "2025-04-16T23:15:52.121Z",
      "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
curl -L \
  --request POST \
  --url 'https://api.gitbook.com/v1/orgs/{organizationId}/openapi' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "slug": "text",
    "source": {
      "url": "https://example.com"
    }
  }'
{
  "object": "openapi-spec",
  "id": "text",
  "createdAt": "2025-04-16T23:15:52.121Z",
  "updatedAt": "2025-04-16T23:15:52.121Z",
  "slug": "text",
  "sourceURL": "https://example.com",
  "processingState": "pending",
  "lastVersion": "text",
  "lastProcessedAt": "2025-04-16T23:15:52.121Z",
  "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
curl -L \
  --url 'https://api.gitbook.com/v1/orgs/{organizationId}/openapi/{specSlug}' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN'
{
  "object": "openapi-spec",
  "id": "text",
  "createdAt": "2025-04-16T23:15:52.121Z",
  "updatedAt": "2025-04-16T23:15:52.121Z",
  "slug": "text",
  "sourceURL": "https://example.com",
  "processingState": "pending",
  "lastVersion": "text",
  "lastProcessedAt": "2025-04-16T23:15:52.121Z",
  "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
curl -L \
  --request PUT \
  --url 'https://api.gitbook.com/v1/orgs/{organizationId}/openapi/{specSlug}' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "source": {
      "url": "https://example.com"
    }
  }'
{
  "object": "openapi-spec",
  "id": "text",
  "createdAt": "2025-04-16T23:15:52.121Z",
  "updatedAt": "2025-04-16T23:15:52.121Z",
  "slug": "text",
  "sourceURL": "https://example.com",
  "processingState": "pending",
  "lastVersion": "text",
  "lastProcessedAt": "2025-04-16T23:15:52.121Z",
  "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
curl -L \
  --request DELETE \
  --url 'https://api.gitbook.com/v1/orgs/{organizationId}/openapi/{specSlug}' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN'

No Content

Was this helpful?