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
application/json
all ofoptional
get
GET /v1/orgs/{organizationId}/sites/{siteId}/redirects HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
200

The list of redirects for the site.

{
  "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
application/json
objectoptional
post
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"
  }
}
201

The redirect was created successfully.

{
  "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
delete
DELETE /v1/orgs/{organizationId}/sites/{siteId}/redirects/{siteRedirectId} HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
205

Site redirect deleted

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
application/json
objectoptional
patch
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"
  }
}
200

OK

{
  "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
application/json
objectoptional
get
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"
}

Was this helpful?