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
  3. Docs sites

Site redirects

Establish redirects for pages that have moved or changed in your docs site.

Was this helpful?

LogoLogo

Resources

  • Showcase
  • Enterprise
  • Status

Company

  • Careers
  • Blog
  • Community

Policies

  • Subprocessors
  • Terms of Service
CtrlK

Was this helpful?

Keep your site's content fresh without breaking old links. This API allows you to create and manage redirection rules.

  • The SiteRedirect object
  • GETList all site redirects
  • POSTCreate a site redirect
  • DELETEDelete a site redirect
  • PATCHUpdate a site redirect
  • GETGet a site redirect by its source

The SiteRedirect object

Attributes
objectstring · enumRequiredPossible values:
idstringRequired

The unique identifier for the redirect.

sourcestring · max: 512Required

The source path to redirect from.

Pattern: ^\/(?:[A-Za-z0-9\-._~]|%[0-9A-Fa-f]{2})+(?:\/(?:[A-Za-z0-9\-._~]|%[0-9A-Fa-f]{2})+)*$
destinationone ofRequired
or
or

The SiteRedirect object

List all site redirects

get
Authorizations
Path parameters
organizationIdstringRequired

The unique id of the organization

siteIdstringRequired

The unique id of the site

Query parameters
pagestringOptional

Identifier of the page results to fetch.

limitnumber · max: 1000Optional

The number of results per page

Responses
200

The list of redirects for the site.

application/json
Responseall of
get
200

The list of redirects for the site.

Create a site redirect

post
Authorizations
Path parameters
organizationIdstringRequired

The unique id of the organization

siteIdstringRequired

The unique id of the site

Body
sourcestring · max: 512Required

The source path to redirect from.

Pattern: ^\/(?:[A-Za-z0-9\-._~]|%[0-9A-Fa-f]{2})+(?:\/(?:[A-Za-z0-9\-._~]|%[0-9A-Fa-f]{2})+)*$
destinationone ofRequired
or
or
Responses
201

The redirect was created successfully.

application/json
post

Delete a site redirect

delete
Authorizations
Path parameters
organizationIdstringRequired

The unique id of the organization

siteIdstringRequired

The unique id of the site

siteRedirectIdstringRequired

The unique id of the site redirect

Responses
204

Site redirect did not exist

205

Site redirect deleted

delete

No content

Update a site redirect

patch
Authorizations
Path parameters
organizationIdstringRequired

The unique id of the organization

siteIdstringRequired

The unique id of the site

siteRedirectIdstringRequired

The unique id of the site redirect

Body
sourcestring · max: 512Optional

The source path to redirect from.

Pattern: ^\/(?:[A-Za-z0-9\-._~]|%[0-9A-Fa-f]{2})+(?:\/(?:[A-Za-z0-9\-._~]|%[0-9A-Fa-f]{2})+)*$
destinationone ofOptional
or
or
Responses
200

OK

application/json
patch

Get a site redirect by its source

get
Authorizations
Path parameters
organizationIdstringRequired

The unique id of the organization

siteIdstringRequired

The unique id of the site

Query parameters
shareKeystringOptional

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

sourcestring · max: 512Required

The source path to redirect from.

Pattern: ^\/(?:[A-Za-z0-9\-._~]|%[0-9A-Fa-f]{2})+(?:\/(?:[A-Za-z0-9\-._~]|%[0-9A-Fa-f]{2})+)*$
Responses
200

The redirect was resolved successfully.

application/json
404

Not Found

application/json
get
201

The redirect was created successfully.

{
  "object": "site-redirect",
  "id": "text",
  "source": "text",
  "destination": {
    "kind": "site-section",
    "siteSectionId": "text"
  }
}
200

OK

{
  "object": "site-redirect",
  "id": "text",
  "source": "text",
  "destination": {
    "kind": "site-section",
    "siteSectionId": "text"
  }
}
{
  "object": "site-redirect",
  "id": "text",
  "source": "text",
  "destination": {
    "kind": "site-section",
    "siteSectionId": "text"
  }
}
GET /v1/orgs/{organizationId}/sites/{siteId}/redirects HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
  "next": {
    "page": "text"
  },
  "count": 1,
  "items": [
    {
      "object": "site-redirect",
      "id": "text",
      "source": "text",
      "destination": {
        "kind": "site-section",
        "siteSectionId": "text"
      }
    }
  ]
}
POST /v1/orgs/{organizationId}/sites/{siteId}/redirects HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 78

{
  "source": "text",
  "destination": {
    "kind": "site-section",
    "siteSectionId": "text"
  }
}
DELETE /v1/orgs/{organizationId}/sites/{siteId}/redirects/{siteRedirectId} HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
PATCH /v1/orgs/{organizationId}/sites/{siteId}/redirects/{siteRedirectId} HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 78

{
  "source": "text",
  "destination": {
    "kind": "site-section",
    "siteSectionId": "text"
  }
}
GET /v1/orgs/{organizationId}/sites/{siteId}/redirect HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
  "redirect": {
    "object": "site-redirect",
    "id": "text",
    "source": "text",
    "destination": {
      "kind": "site-section",
      "siteSectionId": "text"
    }
  },
  "target": "text"
}