Spaces

Create, maintain, and remove content spaces.

Spaces are containers for your documentation or knowledge base content. Use this API to create new spaces, manage existing ones, and delete or archive spaces you no longer need.

The Space object

Attributes
objectstring · enumRequired

Type of Object, always equals to "space"

Possible values:
idstringRequired

Unique identifier for the space

titlestring · max: 50Required

Title of the space

emojistring · emoji · max: 50Required

An emoji for this space. It'll match the emoji shown in the GitBook app.

Example: 🎉
visibilitystring · enumRequired
  • public: Anyone can access the content, and the content is indexed by search engines.
  • unlisted: Anyone can access the content, and the content is not indexed by search engines
  • share-link: Anyone with a secret token in the url can access the content.
  • visitor-auth: Anyone authenticated through a JWT token can access the content.
  • in-collection: Anyone who can access the parent collection can access the content. Only available for spaces in a collection.
  • private: Authorized members can access the content.
Possible values:
createdAtstring · date-timeRequired
updatedAtstring · date-timeRequired
deletedAtstring · date-timeOptional
editModestring · enumOptional

Determines how a Space can be edited.

  • live: Users can directly edit the space
  • locked: All edits are locked for this space.
Possible values:
organizationstringRequired

ID of the organization owning this space

parentstringOptional

ID of the parent collection.

visitorAuthone ofOptional
or
all ofOptional
revisionstringRequired

ID of the active revision in the space.

defaultLevelone ofRequired

Default level for a piece of content

string · enum | nullableOptional

"The role of a member in an organization. "admin": Can administrate the content: create, delete spaces, ... "create": Can create content. "review": Can review content. "edit": Can edit the content (live or change requests). "comment": Can access the content and its discussions. "read": Can access the content, but cannot update it in any way.

Possible values:
commentsnumberRequired

Count of opened comments on the space.

changeRequestsnumberRequired

Total count of change requests on the space.

changeRequestsOpennumberRequired

Count of open change requests on the space.

changeRequestsDraftnumberRequired

Count of draft change requests on the space.

The Space object

{
  "object": "space",
  "id": "text",
  "title": "text",
  "emoji": "🎉",
  "visibility": "public",
  "createdAt": "2025-04-26T12:57:10.116Z",
  "updatedAt": "2025-04-26T12:57:10.116Z",
  "deletedAt": "2025-04-26T12:57:10.116Z",
  "editMode": "live",
  "urls": {
    "location": "https://example.com",
    "app": "https://example.com",
    "published": "https://example.com",
    "public": "https://example.com",
    "icon": "https://example.com"
  },
  "organization": "text",
  "parent": "text",
  "gitSync": {
    "repoName": "text",
    "installationProvider": "github",
    "integration": "text",
    "url": "text",
    "updatedAt": "2025-04-26T12:57:10.116Z"
  },
  "visitorAuth": {
    "backend": "custom"
  },
  "revision": "text",
  "defaultLevel": "admin",
  "comments": 1,
  "changeRequests": 1,
  "changeRequestsOpen": 1,
  "changeRequestsDraft": 1,
  "permissions": {
    "view": true,
    "access": true,
    "admin": true,
    "viewInviteLinks": true,
    "edit": true,
    "triggerGitSync": true,
    "comment": true,
    "merge": true,
    "review": true
  }
}

Get a space by its ID

get
Authorizations
Path parameters
spaceIdstringRequired

The unique id of the space

Query parameters
shareKeystringOptional

For sites published via share-links, the share key is useful to resolve published URLs.

Responses
get
GET /v1/spaces/{spaceId} HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
200

OK

{
  "object": "space",
  "id": "text",
  "title": "text",
  "emoji": "🎉",
  "visibility": "public",
  "createdAt": "2025-04-26T12:57:10.116Z",
  "updatedAt": "2025-04-26T12:57:10.116Z",
  "deletedAt": "2025-04-26T12:57:10.116Z",
  "editMode": "live",
  "urls": {
    "location": "https://example.com",
    "app": "https://example.com",
    "published": "https://example.com",
    "public": "https://example.com",
    "icon": "https://example.com"
  },
  "organization": "text",
  "parent": "text",
  "gitSync": {
    "repoName": "text",
    "installationProvider": "github",
    "integration": "text",
    "url": "text",
    "updatedAt": "2025-04-26T12:57:10.116Z"
  },
  "visitorAuth": {
    "backend": "custom"
  },
  "revision": "text",
  "defaultLevel": "admin",
  "comments": 1,
  "changeRequests": 1,
  "changeRequestsOpen": 1,
  "changeRequestsDraft": 1,
  "permissions": {
    "view": true,
    "access": true,
    "admin": true,
    "viewInviteLinks": true,
    "edit": true,
    "triggerGitSync": true,
    "comment": true,
    "merge": true,
    "review": true
  }
}

Delete a space

delete

Deleted spaces will be permanently removed after 7 days.

Authorizations
Path parameters
spaceIdstringRequired

The unique id of the space

Responses
delete
DELETE /v1/spaces/{spaceId} HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
205

Space has been deleted

No content

Update a space

patch
Authorizations
Path parameters
spaceIdstringRequired

The unique id of the space

Body
all ofOptional
and
one ofOptional
or
or
Responses
patch
PATCH /v1/spaces/{spaceId} HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 72

{
  "editMode": "live",
  "title": "text",
  "defaultLevel": "admin",
  "emoji": "🎉"
}
200

The space has been updated

{
  "object": "space",
  "id": "text",
  "title": "text",
  "emoji": "🎉",
  "visibility": "public",
  "createdAt": "2025-04-26T12:57:10.116Z",
  "updatedAt": "2025-04-26T12:57:10.116Z",
  "deletedAt": "2025-04-26T12:57:10.116Z",
  "editMode": "live",
  "urls": {
    "location": "https://example.com",
    "app": "https://example.com",
    "published": "https://example.com",
    "public": "https://example.com",
    "icon": "https://example.com"
  },
  "organization": "text",
  "parent": "text",
  "gitSync": {
    "repoName": "text",
    "installationProvider": "github",
    "integration": "text",
    "url": "text",
    "updatedAt": "2025-04-26T12:57:10.116Z"
  },
  "visitorAuth": {
    "backend": "custom"
  },
  "revision": "text",
  "defaultLevel": "admin",
  "comments": 1,
  "changeRequests": 1,
  "changeRequestsOpen": 1,
  "changeRequestsDraft": 1,
  "permissions": {
    "view": true,
    "access": true,
    "admin": true,
    "viewInviteLinks": true,
    "edit": true,
    "triggerGitSync": true,
    "comment": true,
    "merge": true,
    "review": true
  }
}

Duplicate a space

post
Authorizations
Path parameters
spaceIdstringRequired

The unique id of the space

Responses
post
POST /v1/spaces/{spaceId}/duplicate HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
201

Space duplicated

{
  "object": "space",
  "id": "text",
  "title": "text",
  "emoji": "🎉",
  "visibility": "public",
  "createdAt": "2025-04-26T12:57:10.116Z",
  "updatedAt": "2025-04-26T12:57:10.116Z",
  "deletedAt": "2025-04-26T12:57:10.116Z",
  "editMode": "live",
  "urls": {
    "location": "https://example.com",
    "app": "https://example.com",
    "published": "https://example.com",
    "public": "https://example.com",
    "icon": "https://example.com"
  },
  "organization": "text",
  "parent": "text",
  "gitSync": {
    "repoName": "text",
    "installationProvider": "github",
    "integration": "text",
    "url": "text",
    "updatedAt": "2025-04-26T12:57:10.116Z"
  },
  "visitorAuth": {
    "backend": "custom"
  },
  "revision": "text",
  "defaultLevel": "admin",
  "comments": 1,
  "changeRequests": 1,
  "changeRequestsOpen": 1,
  "changeRequestsDraft": 1,
  "permissions": {
    "view": true,
    "access": true,
    "admin": true,
    "viewInviteLinks": true,
    "edit": true,
    "triggerGitSync": true,
    "comment": true,
    "merge": true,
    "review": true
  }
}

Restore a deleted space

post

Only spaces deleted in the last 7 days can be restored.

Authorizations
Path parameters
spaceIdstringRequired

The unique id of the space

Responses
post
POST /v1/spaces/{spaceId}/restore HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
200

Space restored

{
  "object": "space",
  "id": "text",
  "title": "text",
  "emoji": "🎉",
  "visibility": "public",
  "createdAt": "2025-04-26T12:57:10.116Z",
  "updatedAt": "2025-04-26T12:57:10.116Z",
  "deletedAt": "2025-04-26T12:57:10.116Z",
  "editMode": "live",
  "urls": {
    "location": "https://example.com",
    "app": "https://example.com",
    "published": "https://example.com",
    "public": "https://example.com",
    "icon": "https://example.com"
  },
  "organization": "text",
  "parent": "text",
  "gitSync": {
    "repoName": "text",
    "installationProvider": "github",
    "integration": "text",
    "url": "text",
    "updatedAt": "2025-04-26T12:57:10.116Z"
  },
  "visitorAuth": {
    "backend": "custom"
  },
  "revision": "text",
  "defaultLevel": "admin",
  "comments": 1,
  "changeRequests": 1,
  "changeRequestsOpen": 1,
  "changeRequestsDraft": 1,
  "permissions": {
    "view": true,
    "access": true,
    "admin": true,
    "viewInviteLinks": true,
    "edit": true,
    "triggerGitSync": true,
    "comment": true,
    "merge": true,
    "review": true
  }
}

Move a space to a new position

post
Authorizations
Path parameters
spaceIdstringRequired

The unique id of the space

Body
parentstring | nullableOptional

The unique id of the parent collection

Responses
post
POST /v1/spaces/{spaceId}/move HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 111

{
  "parent": "text",
  "position": {
    "before": {
      "type": "space",
      "space": "text"
    },
    "after": {
      "type": "space",
      "space": "text"
    }
  }
}
{
  "object": "space",
  "id": "text",
  "title": "text",
  "emoji": "🎉",
  "visibility": "public",
  "createdAt": "2025-04-26T12:57:10.116Z",
  "updatedAt": "2025-04-26T12:57:10.116Z",
  "deletedAt": "2025-04-26T12:57:10.116Z",
  "editMode": "live",
  "urls": {
    "location": "https://example.com",
    "app": "https://example.com",
    "published": "https://example.com",
    "public": "https://example.com",
    "icon": "https://example.com"
  },
  "organization": "text",
  "parent": "text",
  "gitSync": {
    "repoName": "text",
    "installationProvider": "github",
    "integration": "text",
    "url": "text",
    "updatedAt": "2025-04-26T12:57:10.116Z"
  },
  "visitorAuth": {
    "backend": "custom"
  },
  "revision": "text",
  "defaultLevel": "admin",
  "comments": 1,
  "changeRequests": 1,
  "changeRequestsOpen": 1,
  "changeRequestsDraft": 1,
  "permissions": {
    "view": true,
    "access": true,
    "admin": true,
    "viewInviteLinks": true,
    "edit": true,
    "triggerGitSync": true,
    "comment": true,
    "merge": true,
    "review": true
  }
}

Transfer a space

post

Transfer a space to another organization, collection or both.

Authorizations
Path parameters
spaceIdstringRequired

The unique id of the space

Body
organizationstringRequired

The unique id of the target organization

Responses
post
POST /v1/spaces/{spaceId}/transfer HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 23

{
  "organization": "text"
}
{
  "object": "space",
  "id": "text",
  "title": "text",
  "emoji": "🎉",
  "visibility": "public",
  "createdAt": "2025-04-26T12:57:10.116Z",
  "updatedAt": "2025-04-26T12:57:10.116Z",
  "deletedAt": "2025-04-26T12:57:10.116Z",
  "editMode": "live",
  "urls": {
    "location": "https://example.com",
    "app": "https://example.com",
    "published": "https://example.com",
    "public": "https://example.com",
    "icon": "https://example.com"
  },
  "organization": "text",
  "parent": "text",
  "gitSync": {
    "repoName": "text",
    "installationProvider": "github",
    "integration": "text",
    "url": "text",
    "updatedAt": "2025-04-26T12:57:10.116Z"
  },
  "visitorAuth": {
    "backend": "custom"
  },
  "revision": "text",
  "defaultLevel": "admin",
  "comments": 1,
  "changeRequests": 1,
  "changeRequestsOpen": 1,
  "changeRequestsDraft": 1,
  "permissions": {
    "view": true,
    "access": true,
    "admin": true,
    "viewInviteLinks": true,
    "edit": true,
    "triggerGitSync": true,
    "comment": true,
    "merge": true,
    "review": true
  }
}
get
Authorizations
Path parameters
spaceIdstringRequired

The unique id of the space

Query parameters
pagestringOptional

Identifier of the page results to fetch.

limitnumber · max: 1000Optional

The number of results per page

statusstring · enumOptional

Text to display to represent the reference. Possible values include:

  • ok - No problems detected for this content reference.
  • broken - The target does not exist in the revision.
  • in-app - The target is a URL link pointing to an internal location in the app.
Possible values:
Responses
Responseall of
get
GET /v1/spaces/{spaceId}/links HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
  "next": {
    "page": "text"
  },
  "count": 1,
  "stats": {
    "total": 1,
    "broken": {
      "total": 1,
      "changeRequest": 1
    }
  },
  "items": [
    {
      "status": "ok",
      "relation": "reference",
      "targetReference": {
        "kind": "file",
        "organization": {
          "object": "organization",
          "id": "text",
          "title": "text",
          "createdAt": "2025-04-26T12:57:10.116Z",
          "emailDomains": [
            "text"
          ],
          "hostname": "text",
          "type": "business",
          "useCase": "internalDocs",
          "communityType": "nonProfit",
          "defaultRole": "admin",
          "defaultContent": {
            "type": "site",
            "site": "text"
          },
          "sso": true,
          "ai": true,
          "inviteLinks": true,
          "plan": "free_2024",
          "billing": {
            "interval": "monthly",
            "endDate": "2025-04-26T12:57:10.116Z",
            "hasPaymentFailed": true,
            "isScheduledToCancel": true
          },
          "urls": {
            "location": "https://example.com",
            "app": "https://example.com",
            "logo": "https://example.com"
          },
          "trial": {
            "status": "notapplicable",
            "endDate": "2025-04-26T12:57:10.116Z",
            "decision": "downgrade"
          },
          "customHostname": "text",
          "blocked": {
            "reason": "security"
          },
          "internal_billingMigration": {
            "deadline": "2025-04-26T12:57:10.116Z",
            "discountPercent": 1,
            "discountEndDate": "2025-04-26T12:57:10.116Z"
          },
          "permissions": {
            "view": true,
            "admin": true,
            "ownTeam": true,
            "createContent": true,
            "createOpenAPISpec": true,
            "viewBilling": true,
            "listMembers": true,
            "listTeams": true,
            "listIntegrations": true
          }
        },
        "space": {
          "object": "space",
          "id": "text",
          "title": "text",
          "emoji": "🎉",
          "visibility": "public",
          "createdAt": "2025-04-26T12:57:10.116Z",
          "updatedAt": "2025-04-26T12:57:10.116Z",
          "deletedAt": "2025-04-26T12:57:10.116Z",
          "editMode": "live",
          "urls": {
            "location": "https://example.com",
            "app": "https://example.com",
            "published": "https://example.com",
            "public": "https://example.com",
            "icon": "https://example.com"
          },
          "organization": "text",
          "parent": "text",
          "gitSync": {
            "repoName": "text",
            "installationProvider": "github",
            "integration": "text",
            "url": "text",
            "updatedAt": "2025-04-26T12:57:10.116Z"
          },
          "visitorAuth": {
            "backend": "custom"
          },
          "revision": "text",
          "defaultLevel": "admin",
          "comments": 1,
          "changeRequests": 1,
          "changeRequestsOpen": 1,
          "changeRequestsDraft": 1,
          "permissions": {
            "view": true,
            "access": true,
            "admin": true,
            "viewInviteLinks": true,
            "edit": true,
            "triggerGitSync": true,
            "comment": true,
            "merge": true,
            "review": true
          }
        },
        "versionContext": "[Circular Reference]",
        "file": {
          "id": "text",
          "name": "text",
          "contentType": "text",
          "downloadURL": "text",
          "size": 1,
          "dimensions": {
            "width": 1,
            "height": 1
          },
          "git": {
            "oid": "text",
            "path": "text"
          }
        }
      },
      "locationReferences": [
        {
          "kind": "file",
          "organization": {
            "object": "organization",
            "id": "text",
            "title": "text",
            "createdAt": "2025-04-26T12:57:10.116Z",
            "emailDomains": [
              "text"
            ],
            "hostname": "text",
            "type": "business",
            "useCase": "internalDocs",
            "communityType": "nonProfit",
            "defaultRole": "admin",
            "defaultContent": {
              "type": "site",
              "site": "text"
            },
            "sso": true,
            "ai": true,
            "inviteLinks": true,
            "plan": "free_2024",
            "billing": {
              "interval": "monthly",
              "endDate": "2025-04-26T12:57:10.116Z",
              "hasPaymentFailed": true,
              "isScheduledToCancel": true
            },
            "urls": {
              "location": "https://example.com",
              "app": "https://example.com",
              "logo": "https://example.com"
            },
            "trial": {
              "status": "notapplicable",
              "endDate": "2025-04-26T12:57:10.116Z",
              "decision": "downgrade"
            },
            "customHostname": "text",
            "blocked": {
              "reason": "security"
            },
            "internal_billingMigration": {
              "deadline": "2025-04-26T12:57:10.116Z",
              "discountPercent": 1,
              "discountEndDate": "2025-04-26T12:57:10.116Z"
            },
            "permissions": {
              "view": true,
              "admin": true,
              "ownTeam": true,
              "createContent": true,
              "createOpenAPISpec": true,
              "viewBilling": true,
              "listMembers": true,
              "listTeams": true,
              "listIntegrations": true
            }
          },
          "space": {
            "object": "space",
            "id": "text",
            "title": "text",
            "emoji": "🎉",
            "visibility": "public",
            "createdAt": "2025-04-26T12:57:10.116Z",
            "updatedAt": "2025-04-26T12:57:10.116Z",
            "deletedAt": "2025-04-26T12:57:10.116Z",
            "editMode": "live",
            "urls": {
              "location": "https://example.com",
              "app": "https://example.com",
              "published": "https://example.com",
              "public": "https://example.com",
              "icon": "https://example.com"
            },
            "organization": "text",
            "parent": "text",
            "gitSync": {
              "repoName": "text",
              "installationProvider": "github",
              "integration": "text",
              "url": "text",
              "updatedAt": "2025-04-26T12:57:10.116Z"
            },
            "visitorAuth": {
              "backend": "custom"
            },
            "revision": "text",
            "defaultLevel": "admin",
            "comments": 1,
            "changeRequests": 1,
            "changeRequestsOpen": 1,
            "changeRequestsDraft": 1,
            "permissions": {
              "view": true,
              "access": true,
              "admin": true,
              "viewInviteLinks": true,
              "edit": true,
              "triggerGitSync": true,
              "comment": true,
              "merge": true,
              "review": true
            }
          },
          "versionContext": "[Circular Reference]",
          "file": {
            "id": "text",
            "name": "text",
            "contentType": "text",
            "downloadURL": "text",
            "size": 1,
            "dimensions": {
              "width": 1,
              "height": 1
            },
            "git": {
              "oid": "text",
              "path": "text"
            }
          }
        }
      ]
    }
  ]
}

List all spaces

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
Responseall of
get
GET /v1/orgs/{organizationId}/spaces HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
200

OK

{
  "next": {
    "page": "text"
  },
  "count": 1,
  "items": [
    {
      "object": "space",
      "id": "text",
      "title": "text",
      "emoji": "🎉",
      "visibility": "public",
      "createdAt": "2025-04-26T12:57:10.116Z",
      "updatedAt": "2025-04-26T12:57:10.116Z",
      "deletedAt": "2025-04-26T12:57:10.116Z",
      "editMode": "live",
      "urls": {
        "location": "https://example.com",
        "app": "https://example.com",
        "published": "https://example.com",
        "public": "https://example.com",
        "icon": "https://example.com"
      },
      "organization": "text",
      "parent": "text",
      "gitSync": {
        "repoName": "text",
        "installationProvider": "github",
        "integration": "text",
        "url": "text",
        "updatedAt": "2025-04-26T12:57:10.116Z"
      },
      "visitorAuth": {
        "backend": "custom"
      },
      "revision": "text",
      "defaultLevel": "admin",
      "comments": 1,
      "changeRequests": 1,
      "changeRequestsOpen": 1,
      "changeRequestsDraft": 1,
      "permissions": {
        "view": true,
        "access": true,
        "admin": true,
        "viewInviteLinks": true,
        "edit": true,
        "triggerGitSync": true,
        "comment": true,
        "merge": true,
        "review": true
      }
    }
  ]
}

Create a space

post
Authorizations
Path parameters
organizationIdstringRequired

The unique id of the organization

Body
titlestring · max: 50Optional
emojistring · emoji · max: 50Optional

Unicode codepoint or character of the emoji

Example: 🎉
privatebooleanOptionalDeprecated

Private spaces are no longer supported by GitBook.

parentstringOptional

ID of a parent collection

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

{
  "title": "text",
  "emoji": "🎉",
  "parent": "text"
}
201

Space created

{
  "object": "space",
  "id": "text",
  "title": "text",
  "emoji": "🎉",
  "visibility": "public",
  "createdAt": "2025-04-26T12:57:10.116Z",
  "updatedAt": "2025-04-26T12:57:10.116Z",
  "deletedAt": "2025-04-26T12:57:10.116Z",
  "editMode": "live",
  "urls": {
    "location": "https://example.com",
    "app": "https://example.com",
    "published": "https://example.com",
    "public": "https://example.com",
    "icon": "https://example.com"
  },
  "organization": "text",
  "parent": "text",
  "gitSync": {
    "repoName": "text",
    "installationProvider": "github",
    "integration": "text",
    "url": "text",
    "updatedAt": "2025-04-26T12:57:10.116Z"
  },
  "visitorAuth": {
    "backend": "custom"
  },
  "revision": "text",
  "defaultLevel": "admin",
  "comments": 1,
  "changeRequests": 1,
  "changeRequestsOpen": 1,
  "changeRequestsDraft": 1,
  "permissions": {
    "view": true,
    "access": true,
    "admin": true,
    "viewInviteLinks": true,
    "edit": true,
    "triggerGitSync": true,
    "comment": true,
    "merge": true,
    "review": true
  }
}

Was this helpful?