Site redirects

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

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

The SiteRedirect object

Attributes
objectstring · enumrequiredAvailable options:
idstringrequired

The unique identifier for the redirect.

sourcestring · max: 512required

The source path to redirect from.

Pattern: ^/[a-zA-Z0-9-_.\/]+[a-zA-Z0-9-_.]$
destinationone ofrequired

The SiteRedirect object

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

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
curl -L \
  --url 'https://api.gitbook.com/v1/orgs/{organizationId}/sites/{siteId}/redirects' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN'
{
  "next": {
    "page": "text"
  },
  "count": 1,
  "items": [
    {
      "object": "site-redirect",
      "id": "text",
      "source": "text",
      "destination": {
        "kind": "site-section",
        "siteSectionId": "text"
      }
    }
  ]
}

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-_.\/]+[a-zA-Z0-9-_.]$
destinationone ofrequired

Responses
curl -L \
  --request POST \
  --url 'https://api.gitbook.com/v1/orgs/{organizationId}/sites/{siteId}/redirects' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "source": "text",
    "destination": {
      "kind": "site-section",
      "siteSectionId": "text"
    }
  }'
{
  "object": "site-redirect",
  "id": "text",
  "source": "text",
  "destination": {
    "kind": "site-section",
    "siteSectionId": "text"
  }
}

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
curl -L \
  --request DELETE \
  --url 'https://api.gitbook.com/v1/orgs/{organizationId}/sites/{siteId}/redirects/{siteRedirectId}' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN'

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-_.\/]+[a-zA-Z0-9-_.]$
destinationone ofoptional

Responses
curl -L \
  --request PATCH \
  --url 'https://api.gitbook.com/v1/orgs/{organizationId}/sites/{siteId}/redirects/{siteRedirectId}' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "source": "text",
    "destination": {
      "kind": "site-section",
      "siteSectionId": "text"
    }
  }'
{
  "object": "site-redirect",
  "id": "text",
  "source": "text",
  "destination": {
    "kind": "site-section",
    "siteSectionId": "text"
  }
}

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-_.\/]+[a-zA-Z0-9-_.]$
Responses
curl -L \
  --url 'https://api.gitbook.com/v1/orgs/{organizationId}/sites/{siteId}/redirect?source=text' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN'
{
  "redirect": {
    "object": "site-redirect",
    "id": "text",
    "source": "text",
    "destination": {
      "kind": "site-section",
      "siteSectionId": "text"
    }
  },
  "target": "text"
}

Was this helpful?