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.
objectstring · enumrequired
Options: site-redirect
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
List all site redirects
get
organizationIdstringrequired
The unique id of the organization
siteIdstringrequired
The unique id of the site
pagestringoptional
Identifier of the page results to fetch.
limitnumber · max: 1000optional
The number of results per page
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
organizationIdstringrequired
The unique id of the organization
siteIdstringrequired
The unique id of the site
sourcestring · max: 512required
The source path to redirect from.
Pattern: ^/[a-zA-Z0-9-_.\/]+[a-zA-Z0-9-_.]$
destinationone ofrequired
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
organizationIdstringrequired
The unique id of the organization
siteIdstringrequired
The unique id of the site
siteRedirectIdstringrequired
The unique id of the site redirect
curl -L \
--request DELETE \
--url 'https://api.gitbook.com/v1/orgs/{organizationId}/sites/{siteId}/redirects/{siteRedirectId}' \
--header 'Authorization: Bearer YOUR_SECRET_TOKEN'
Update a site redirect
patch
organizationIdstringrequired
The unique id of the organization
siteIdstringrequired
The unique id of the site
siteRedirectIdstringrequired
The unique id of the site redirect
sourcestring · max: 512optional
The source path to redirect from.
Pattern: ^/[a-zA-Z0-9-_.\/]+[a-zA-Z0-9-_.]$
destinationone ofoptional
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
organizationIdstringrequired
The unique id of the organization
siteIdstringrequired
The unique id of the site
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-_.]$
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"
}