# Site redirects

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

## The SiteRedirect object

```json
{"openapi":"3.1.0","info":{"title":"GitBook API","version":"0.0.1-beta"},"components":{"schemas":{"SiteRedirect":{"type":"object","properties":{"object":{"type":"string","enum":["site-redirect"]},"id":{"type":"string","description":"The unique identifier for the redirect."},"source":{"$ref":"#/components/schemas/SiteRedirectSourcePath"},"draft":{"type":"boolean","description":"Whether the redirect is draft and not live."},"captureWildcard":{"type":"boolean","description":"Capture and append the wildcard-matched suffix to the destination URL."},"destination":{"$ref":"#/components/schemas/SiteRedirectDestination"}},"required":["object","id","source","draft","captureWildcard","destination"]},"SiteRedirectSourcePath":{"type":"string","description":"The source path to redirect from.","maxLength":512,"pattern":"^\\/(?!\\*)(?!.*\\*.+)(?:[A-Za-z0-9\\-._~]|%[0-9A-Fa-f]{2})+(?:\\/(?:[A-Za-z0-9\\-._~]|%[0-9A-Fa-f]{2})+)*(?:\\/\\*|\\*)?$"},"SiteRedirectDestination":{"oneOf":[{"$ref":"#/components/schemas/SiteRedirectDestinationSiteSection"},{"$ref":"#/components/schemas/SiteRedirectDestinationSiteSpace"},{"$ref":"#/components/schemas/SiteRedirectDestinationPage"},{"$ref":"#/components/schemas/SiteRedirectDestinationExternal"}]},"SiteRedirectDestinationSiteSection":{"type":"object","properties":{"kind":{"type":"string","enum":["site-section"]},"siteSectionId":{"type":"string","description":"Unique identifier for the site section to redirect to"}},"required":["kind","siteSectionId"]},"SiteRedirectDestinationSiteSpace":{"type":"object","properties":{"kind":{"type":"string","enum":["site-space"]},"siteSpaceId":{"type":"string","description":"Unique identifier for the site space to redirect to"}},"required":["kind","siteSpaceId"]},"SiteRedirectDestinationPage":{"type":"object","properties":{"kind":{"type":"string","enum":["site-page"]},"siteSpaceId":{"type":"string","description":"Unique identifier for the site space of the page"},"pageId":{"type":"string","description":"Unique identifier for the page within the site space to redirect to"}},"required":["kind","siteSpaceId","pageId"]},"SiteRedirectDestinationExternal":{"type":"object","properties":{"kind":{"type":"string","enum":["external"]},"url":{"$ref":"#/components/schemas/URL"}},"required":["kind","url"]},"URL":{"type":"string","format":"uri","maxLength":2048}}}}
```

## GET /orgs/{organizationId}/sites/{siteId}/redirects

> List all site redirects

```json
{"openapi":"3.1.0","info":{"title":"GitBook API","version":"0.0.1-beta"},"tags":[{"name":"site-redirects","description":"Keep your site's content fresh without breaking old links. This API allows you to create and manage redirection rules.\n\n{% openapi-schemas spec=\"gitbook\" schemas=\"SiteRedirect\" grouped=\"false\" %}\n    The SiteRedirect object\n{% endopenapi-schemas %}\n"}],"servers":[{"url":"{host}/v1","variables":{"host":{"default":"https://api.gitbook.com"}}}],"security":[{"user":[]}],"components":{"securitySchemes":{"user":{"type":"http","scheme":"bearer"}},"parameters":{"organizationId":{"name":"organizationId","in":"path","required":true,"description":"The unique id of the organization","schema":{"$ref":"#/components/schemas/EntityId"}},"siteId":{"name":"siteId","in":"path","required":true,"description":"The unique id of the site","schema":{"type":"string"}},"listPage":{"name":"page","in":"query","description":"Identifier of the page results to fetch.","schema":{"type":"string"}},"listLimit":{"name":"limit","in":"query","description":"The number of results per page","schema":{"type":"number","minimum":0,"maximum":1000}}},"schemas":{"EntityId":{"type":"string","pattern":"^[a-zA-Z0-9_-]+$","description":"A unique entity identifier"},"List":{"type":"object","properties":{"next":{"type":"object","properties":{"page":{"type":"string","description":"Unique identifier to query the next results page"}},"required":["page"]},"count":{"type":"number","description":"Total count of objects in the list"}}},"SiteRedirect":{"type":"object","properties":{"object":{"type":"string","enum":["site-redirect"]},"id":{"type":"string","description":"The unique identifier for the redirect."},"source":{"$ref":"#/components/schemas/SiteRedirectSourcePath"},"draft":{"type":"boolean","description":"Whether the redirect is draft and not live."},"captureWildcard":{"type":"boolean","description":"Capture and append the wildcard-matched suffix to the destination URL."},"destination":{"$ref":"#/components/schemas/SiteRedirectDestination"}},"required":["object","id","source","draft","captureWildcard","destination"]},"SiteRedirectSourcePath":{"type":"string","description":"The source path to redirect from.","maxLength":512,"pattern":"^\\/(?!\\*)(?!.*\\*.+)(?:[A-Za-z0-9\\-._~]|%[0-9A-Fa-f]{2})+(?:\\/(?:[A-Za-z0-9\\-._~]|%[0-9A-Fa-f]{2})+)*(?:\\/\\*|\\*)?$"},"SiteRedirectDestination":{"oneOf":[{"$ref":"#/components/schemas/SiteRedirectDestinationSiteSection"},{"$ref":"#/components/schemas/SiteRedirectDestinationSiteSpace"},{"$ref":"#/components/schemas/SiteRedirectDestinationPage"},{"$ref":"#/components/schemas/SiteRedirectDestinationExternal"}]},"SiteRedirectDestinationSiteSection":{"type":"object","properties":{"kind":{"type":"string","enum":["site-section"]},"siteSectionId":{"type":"string","description":"Unique identifier for the site section to redirect to"}},"required":["kind","siteSectionId"]},"SiteRedirectDestinationSiteSpace":{"type":"object","properties":{"kind":{"type":"string","enum":["site-space"]},"siteSpaceId":{"type":"string","description":"Unique identifier for the site space to redirect to"}},"required":["kind","siteSpaceId"]},"SiteRedirectDestinationPage":{"type":"object","properties":{"kind":{"type":"string","enum":["site-page"]},"siteSpaceId":{"type":"string","description":"Unique identifier for the site space of the page"},"pageId":{"type":"string","description":"Unique identifier for the page within the site space to redirect to"}},"required":["kind","siteSpaceId","pageId"]},"SiteRedirectDestinationExternal":{"type":"object","properties":{"kind":{"type":"string","enum":["external"]},"url":{"$ref":"#/components/schemas/URL"}},"required":["kind","url"]},"URL":{"type":"string","format":"uri","maxLength":2048}}},"paths":{"/orgs/{organizationId}/sites/{siteId}/redirects":{"get":{"operationId":"listSiteRedirects","summary":"List all site redirects","tags":["site-redirects"],"parameters":[{"$ref":"#/components/parameters/organizationId"},{"$ref":"#/components/parameters/siteId"},{"$ref":"#/components/parameters/listPage"},{"$ref":"#/components/parameters/listLimit"},{"name":"search","in":"query","description":"Search for a redirect by path","schema":{"type":"string"}},{"name":"draft","in":"query","description":"Filter redirects by draft mode.","schema":{"type":"boolean","default":false}}],"responses":{"200":{"description":"The list of redirects for the site.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/List"},{"type":"object","required":["items"],"properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/SiteRedirect"}}}}]}}}}}}}}}
```

## POST /orgs/{organizationId}/sites/{siteId}/redirects

> Create a site redirect

```json
{"openapi":"3.1.0","info":{"title":"GitBook API","version":"0.0.1-beta"},"tags":[{"name":"site-redirects","description":"Keep your site's content fresh without breaking old links. This API allows you to create and manage redirection rules.\n\n{% openapi-schemas spec=\"gitbook\" schemas=\"SiteRedirect\" grouped=\"false\" %}\n    The SiteRedirect object\n{% endopenapi-schemas %}\n"}],"servers":[{"url":"{host}/v1","variables":{"host":{"default":"https://api.gitbook.com"}}}],"security":[{"user":[]}],"components":{"securitySchemes":{"user":{"type":"http","scheme":"bearer"}},"parameters":{"organizationId":{"name":"organizationId","in":"path","required":true,"description":"The unique id of the organization","schema":{"$ref":"#/components/schemas/EntityId"}},"siteId":{"name":"siteId","in":"path","required":true,"description":"The unique id of the site","schema":{"type":"string"}}},"schemas":{"EntityId":{"type":"string","pattern":"^[a-zA-Z0-9_-]+$","description":"A unique entity identifier"},"SiteRedirectSourcePath":{"type":"string","description":"The source path to redirect from.","maxLength":512,"pattern":"^\\/(?!\\*)(?!.*\\*.+)(?:[A-Za-z0-9\\-._~]|%[0-9A-Fa-f]{2})+(?:\\/(?:[A-Za-z0-9\\-._~]|%[0-9A-Fa-f]{2})+)*(?:\\/\\*|\\*)?$"},"SiteRedirectInputDestination":{"oneOf":[{"$ref":"#/components/schemas/SiteRedirectDestination"},{"$ref":"#/components/schemas/SiteRedirectInputDestinationPath"}]},"SiteRedirectDestination":{"oneOf":[{"$ref":"#/components/schemas/SiteRedirectDestinationSiteSection"},{"$ref":"#/components/schemas/SiteRedirectDestinationSiteSpace"},{"$ref":"#/components/schemas/SiteRedirectDestinationPage"},{"$ref":"#/components/schemas/SiteRedirectDestinationExternal"}]},"SiteRedirectDestinationSiteSection":{"type":"object","properties":{"kind":{"type":"string","enum":["site-section"]},"siteSectionId":{"type":"string","description":"Unique identifier for the site section to redirect to"}},"required":["kind","siteSectionId"]},"SiteRedirectDestinationSiteSpace":{"type":"object","properties":{"kind":{"type":"string","enum":["site-space"]},"siteSpaceId":{"type":"string","description":"Unique identifier for the site space to redirect to"}},"required":["kind","siteSpaceId"]},"SiteRedirectDestinationPage":{"type":"object","properties":{"kind":{"type":"string","enum":["site-page"]},"siteSpaceId":{"type":"string","description":"Unique identifier for the site space of the page"},"pageId":{"type":"string","description":"Unique identifier for the page within the site space to redirect to"}},"required":["kind","siteSpaceId","pageId"]},"SiteRedirectDestinationExternal":{"type":"object","properties":{"kind":{"type":"string","enum":["external"]},"url":{"$ref":"#/components/schemas/URL"}},"required":["kind","url"]},"URL":{"type":"string","format":"uri","maxLength":2048},"SiteRedirectInputDestinationPath":{"type":"object","properties":{"kind":{"type":"string","enum":["path"]},"spaceId":{"type":"string","description":"Unique identifier for the space containing the page referenced by the path."},"path":{"type":"string","description":"Path to the page within the space revision to resolve."}},"required":["kind","spaceId","path"]},"SiteRedirect":{"type":"object","properties":{"object":{"type":"string","enum":["site-redirect"]},"id":{"type":"string","description":"The unique identifier for the redirect."},"source":{"$ref":"#/components/schemas/SiteRedirectSourcePath"},"draft":{"type":"boolean","description":"Whether the redirect is draft and not live."},"captureWildcard":{"type":"boolean","description":"Capture and append the wildcard-matched suffix to the destination URL."},"destination":{"$ref":"#/components/schemas/SiteRedirectDestination"}},"required":["object","id","source","draft","captureWildcard","destination"]}}},"paths":{"/orgs/{organizationId}/sites/{siteId}/redirects":{"post":{"operationId":"createSiteRedirect","summary":"Create a site redirect","tags":["site-redirects"],"parameters":[{"$ref":"#/components/parameters/organizationId"},{"$ref":"#/components/parameters/siteId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"source":{"$ref":"#/components/schemas/SiteRedirectSourcePath"},"captureWildcard":{"type":"boolean","default":false,"description":"Capture and append the wildcard-matched suffix to the destination URL."},"draft":{"type":"boolean","default":false,"description":"Whether the redirect is draft and not live."},"destination":{"$ref":"#/components/schemas/SiteRedirectInputDestination"}},"required":["source","destination"]}}}},"responses":{"201":{"description":"The redirect was created successfully.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SiteRedirect"}}}}}}}}}
```

## PUT /orgs/{organizationId}/sites/{siteId}/redirects

> Create or update site redirects in bulk

```json
{"openapi":"3.1.0","info":{"title":"GitBook API","version":"0.0.1-beta"},"tags":[{"name":"site-redirects","description":"Keep your site's content fresh without breaking old links. This API allows you to create and manage redirection rules.\n\n{% openapi-schemas spec=\"gitbook\" schemas=\"SiteRedirect\" grouped=\"false\" %}\n    The SiteRedirect object\n{% endopenapi-schemas %}\n"}],"servers":[{"url":"{host}/v1","variables":{"host":{"default":"https://api.gitbook.com"}}}],"security":[{"user":[]}],"components":{"securitySchemes":{"user":{"type":"http","scheme":"bearer"}},"parameters":{"organizationId":{"name":"organizationId","in":"path","required":true,"description":"The unique id of the organization","schema":{"$ref":"#/components/schemas/EntityId"}},"siteId":{"name":"siteId","in":"path","required":true,"description":"The unique id of the site","schema":{"type":"string"}}},"schemas":{"EntityId":{"type":"string","pattern":"^[a-zA-Z0-9_-]+$","description":"A unique entity identifier"},"SiteRedirectSourcePath":{"type":"string","description":"The source path to redirect from.","maxLength":512,"pattern":"^\\/(?!\\*)(?!.*\\*.+)(?:[A-Za-z0-9\\-._~]|%[0-9A-Fa-f]{2})+(?:\\/(?:[A-Za-z0-9\\-._~]|%[0-9A-Fa-f]{2})+)*(?:\\/\\*|\\*)?$"},"SiteRedirectInputDestination":{"oneOf":[{"$ref":"#/components/schemas/SiteRedirectDestination"},{"$ref":"#/components/schemas/SiteRedirectInputDestinationPath"}]},"SiteRedirectDestination":{"oneOf":[{"$ref":"#/components/schemas/SiteRedirectDestinationSiteSection"},{"$ref":"#/components/schemas/SiteRedirectDestinationSiteSpace"},{"$ref":"#/components/schemas/SiteRedirectDestinationPage"},{"$ref":"#/components/schemas/SiteRedirectDestinationExternal"}]},"SiteRedirectDestinationSiteSection":{"type":"object","properties":{"kind":{"type":"string","enum":["site-section"]},"siteSectionId":{"type":"string","description":"Unique identifier for the site section to redirect to"}},"required":["kind","siteSectionId"]},"SiteRedirectDestinationSiteSpace":{"type":"object","properties":{"kind":{"type":"string","enum":["site-space"]},"siteSpaceId":{"type":"string","description":"Unique identifier for the site space to redirect to"}},"required":["kind","siteSpaceId"]},"SiteRedirectDestinationPage":{"type":"object","properties":{"kind":{"type":"string","enum":["site-page"]},"siteSpaceId":{"type":"string","description":"Unique identifier for the site space of the page"},"pageId":{"type":"string","description":"Unique identifier for the page within the site space to redirect to"}},"required":["kind","siteSpaceId","pageId"]},"SiteRedirectDestinationExternal":{"type":"object","properties":{"kind":{"type":"string","enum":["external"]},"url":{"$ref":"#/components/schemas/URL"}},"required":["kind","url"]},"URL":{"type":"string","format":"uri","maxLength":2048},"SiteRedirectInputDestinationPath":{"type":"object","properties":{"kind":{"type":"string","enum":["path"]},"spaceId":{"type":"string","description":"Unique identifier for the space containing the page referenced by the path."},"path":{"type":"string","description":"Path to the page within the space revision to resolve."}},"required":["kind","spaceId","path"]}}},"paths":{"/orgs/{organizationId}/sites/{siteId}/redirects":{"put":{"operationId":"bulkUpsertSiteRedirects","summary":"Create or update site redirects in bulk","tags":["site-redirects"],"parameters":[{"$ref":"#/components/parameters/organizationId"},{"$ref":"#/components/parameters/siteId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"redirects":{"type":"array","minItems":1,"maxItems":500,"items":{"oneOf":[{"type":"object","properties":{"source":{"$ref":"#/components/schemas/SiteRedirectSourcePath"},"intent":{"type":"string","enum":["publish"],"description":"Publish a draft redirect to live and remove the draft redirect.\n"}},"required":["source","intent"]},{"type":"object","properties":{"source":{"$ref":"#/components/schemas/SiteRedirectSourcePath"},"intent":{"type":"string","enum":["live","draft"],"default":"live","description":"Redirect operation intent.\n- live: upsert/delete a live redirect (draft=false)\n- draft: upsert/delete a draft redirect (draft=true)\n"},"captureWildcard":{"type":"boolean","default":false,"description":"Capture and append the wildcard-matched suffix to the destination URL."},"destination":{"description":"If set to null, the redirect matching the source+intent target will be deleted.","oneOf":[{"$ref":"#/components/schemas/SiteRedirectInputDestination"},{"type":"null"}]}},"required":["source","destination"]}]}}},"required":["redirects"]}}}},"responses":{"200":{"description":"List of results for each redirect processed.","content":{"application/json":{"schema":{"type":"object","properties":{"results":{"type":"array","items":{"oneOf":[{"type":"object","properties":{"status":{"type":"string","enum":["created"],"description":"The redirect was created."},"source":{"$ref":"#/components/schemas/SiteRedirectSourcePath"},"draft":{"type":"boolean","description":"Whether the redirect is draft and not live."},"id":{"type":"string","description":"The ID of the created redirect."}},"required":["status","source","draft","id"]},{"type":"object","properties":{"status":{"type":"string","enum":["updated"],"description":"The redirect was updated."},"source":{"$ref":"#/components/schemas/SiteRedirectSourcePath"},"draft":{"type":"boolean","description":"Whether the redirect is draft and not live."},"id":{"type":"string","description":"The ID of the updated redirect."}},"required":["status","source","draft","id"]},{"type":"object","properties":{"status":{"type":"string","enum":["deleted"],"description":"The redirect was deleted."},"source":{"$ref":"#/components/schemas/SiteRedirectSourcePath"},"draft":{"type":"boolean","description":"Whether the deleted redirect was draft."}},"required":["status","source","draft"]},{"type":"object","properties":{"status":{"type":"string","enum":["published"],"description":"The draft redirect was published to live and removed from draft."},"source":{"$ref":"#/components/schemas/SiteRedirectSourcePath"},"draft":{"type":"boolean","description":"Always false for published redirects."},"id":{"type":"string","description":"The ID of the resulting live redirect."}},"required":["status","source","draft","id"]},{"type":"object","properties":{"status":{"type":"string","enum":["error"],"description":"There was an error processing the redirect."},"source":{"$ref":"#/components/schemas/SiteRedirectSourcePath"},"draft":{"type":"boolean","description":"Whether the redirect is draft and not live."},"error":{"type":"string","description":"The error message."}},"required":["status","source","draft","error"]}]}}},"required":["results"]}}}}}}}}}
```

## DELETE /orgs/{organizationId}/sites/{siteId}/redirects/{siteRedirectId}

> Delete a site redirect

```json
{"openapi":"3.1.0","info":{"title":"GitBook API","version":"0.0.1-beta"},"tags":[{"name":"site-redirects","description":"Keep your site's content fresh without breaking old links. This API allows you to create and manage redirection rules.\n\n{% openapi-schemas spec=\"gitbook\" schemas=\"SiteRedirect\" grouped=\"false\" %}\n    The SiteRedirect object\n{% endopenapi-schemas %}\n"}],"servers":[{"url":"{host}/v1","variables":{"host":{"default":"https://api.gitbook.com"}}}],"security":[{"user":[]}],"components":{"securitySchemes":{"user":{"type":"http","scheme":"bearer"}},"parameters":{"organizationId":{"name":"organizationId","in":"path","required":true,"description":"The unique id of the organization","schema":{"$ref":"#/components/schemas/EntityId"}},"siteId":{"name":"siteId","in":"path","required":true,"description":"The unique id of the site","schema":{"type":"string"}},"siteRedirectId":{"name":"siteRedirectId","in":"path","required":true,"description":"The unique id of the site redirect","schema":{"type":"string"}}},"schemas":{"EntityId":{"type":"string","pattern":"^[a-zA-Z0-9_-]+$","description":"A unique entity identifier"}}},"paths":{"/orgs/{organizationId}/sites/{siteId}/redirects/{siteRedirectId}":{"delete":{"operationId":"deleteSiteRedirectById","summary":"Delete a site redirect","tags":["site-redirects"],"parameters":[{"$ref":"#/components/parameters/organizationId"},{"$ref":"#/components/parameters/siteId"},{"$ref":"#/components/parameters/siteRedirectId"}],"responses":{"204":{"description":"Site redirect did not exist"},"205":{"description":"Site redirect deleted"}}}}}}
```

## PATCH /orgs/{organizationId}/sites/{siteId}/redirects/{siteRedirectId}

> Update a site redirect

```json
{"openapi":"3.1.0","info":{"title":"GitBook API","version":"0.0.1-beta"},"tags":[{"name":"site-redirects","description":"Keep your site's content fresh without breaking old links. This API allows you to create and manage redirection rules.\n\n{% openapi-schemas spec=\"gitbook\" schemas=\"SiteRedirect\" grouped=\"false\" %}\n    The SiteRedirect object\n{% endopenapi-schemas %}\n"}],"servers":[{"url":"{host}/v1","variables":{"host":{"default":"https://api.gitbook.com"}}}],"security":[{"user":[]}],"components":{"securitySchemes":{"user":{"type":"http","scheme":"bearer"}},"parameters":{"organizationId":{"name":"organizationId","in":"path","required":true,"description":"The unique id of the organization","schema":{"$ref":"#/components/schemas/EntityId"}},"siteId":{"name":"siteId","in":"path","required":true,"description":"The unique id of the site","schema":{"type":"string"}},"siteRedirectId":{"name":"siteRedirectId","in":"path","required":true,"description":"The unique id of the site redirect","schema":{"type":"string"}}},"schemas":{"EntityId":{"type":"string","pattern":"^[a-zA-Z0-9_-]+$","description":"A unique entity identifier"},"SiteRedirectSourcePath":{"type":"string","description":"The source path to redirect from.","maxLength":512,"pattern":"^\\/(?!\\*)(?!.*\\*.+)(?:[A-Za-z0-9\\-._~]|%[0-9A-Fa-f]{2})+(?:\\/(?:[A-Za-z0-9\\-._~]|%[0-9A-Fa-f]{2})+)*(?:\\/\\*|\\*)?$"},"SiteRedirectDestination":{"oneOf":[{"$ref":"#/components/schemas/SiteRedirectDestinationSiteSection"},{"$ref":"#/components/schemas/SiteRedirectDestinationSiteSpace"},{"$ref":"#/components/schemas/SiteRedirectDestinationPage"},{"$ref":"#/components/schemas/SiteRedirectDestinationExternal"}]},"SiteRedirectDestinationSiteSection":{"type":"object","properties":{"kind":{"type":"string","enum":["site-section"]},"siteSectionId":{"type":"string","description":"Unique identifier for the site section to redirect to"}},"required":["kind","siteSectionId"]},"SiteRedirectDestinationSiteSpace":{"type":"object","properties":{"kind":{"type":"string","enum":["site-space"]},"siteSpaceId":{"type":"string","description":"Unique identifier for the site space to redirect to"}},"required":["kind","siteSpaceId"]},"SiteRedirectDestinationPage":{"type":"object","properties":{"kind":{"type":"string","enum":["site-page"]},"siteSpaceId":{"type":"string","description":"Unique identifier for the site space of the page"},"pageId":{"type":"string","description":"Unique identifier for the page within the site space to redirect to"}},"required":["kind","siteSpaceId","pageId"]},"SiteRedirectDestinationExternal":{"type":"object","properties":{"kind":{"type":"string","enum":["external"]},"url":{"$ref":"#/components/schemas/URL"}},"required":["kind","url"]},"URL":{"type":"string","format":"uri","maxLength":2048},"SiteRedirect":{"type":"object","properties":{"object":{"type":"string","enum":["site-redirect"]},"id":{"type":"string","description":"The unique identifier for the redirect."},"source":{"$ref":"#/components/schemas/SiteRedirectSourcePath"},"draft":{"type":"boolean","description":"Whether the redirect is draft and not live."},"captureWildcard":{"type":"boolean","description":"Capture and append the wildcard-matched suffix to the destination URL."},"destination":{"$ref":"#/components/schemas/SiteRedirectDestination"}},"required":["object","id","source","draft","captureWildcard","destination"]}}},"paths":{"/orgs/{organizationId}/sites/{siteId}/redirects/{siteRedirectId}":{"patch":{"operationId":"updateSiteRedirectById","summary":"Update a site redirect","tags":["site-redirects"],"parameters":[{"$ref":"#/components/parameters/organizationId"},{"$ref":"#/components/parameters/siteId"},{"$ref":"#/components/parameters/siteRedirectId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"source":{"$ref":"#/components/schemas/SiteRedirectSourcePath"},"captureWildcard":{"type":"boolean","description":"Capture and append the wildcard-matched suffix to the destination URL."},"draft":{"type":"boolean","description":"When true, it can be used to promote a draft redirect to live."},"destination":{"$ref":"#/components/schemas/SiteRedirectDestination"}}}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SiteRedirect"}}}}}}}}}
```

## GET /orgs/{organizationId}/sites/{siteId}/redirect

> Get a site redirect by its source

```json
{"openapi":"3.1.0","info":{"title":"GitBook API","version":"0.0.1-beta"},"tags":[{"name":"site-redirects","description":"Keep your site's content fresh without breaking old links. This API allows you to create and manage redirection rules.\n\n{% openapi-schemas spec=\"gitbook\" schemas=\"SiteRedirect\" grouped=\"false\" %}\n    The SiteRedirect object\n{% endopenapi-schemas %}\n"}],"servers":[{"url":"{host}/v1","variables":{"host":{"default":"https://api.gitbook.com"}}}],"security":[{"user":[]}],"components":{"securitySchemes":{"user":{"type":"http","scheme":"bearer"}},"parameters":{"organizationId":{"name":"organizationId","in":"path","required":true,"description":"The unique id of the organization","schema":{"$ref":"#/components/schemas/EntityId"}},"siteId":{"name":"siteId","in":"path","required":true,"description":"The unique id of the site","schema":{"type":"string"}},"siteShareKey":{"name":"shareKey","in":"query","description":"For sites published via share-links, the share key is useful to resolve published URLs.","schema":{"type":"string"}}},"schemas":{"EntityId":{"type":"string","pattern":"^[a-zA-Z0-9_-]+$","description":"A unique entity identifier"},"SiteRedirectSourcePath":{"type":"string","description":"The source path to redirect from.","maxLength":512,"pattern":"^\\/(?!\\*)(?!.*\\*.+)(?:[A-Za-z0-9\\-._~]|%[0-9A-Fa-f]{2})+(?:\\/(?:[A-Za-z0-9\\-._~]|%[0-9A-Fa-f]{2})+)*(?:\\/\\*|\\*)?$"},"SiteRedirect":{"type":"object","properties":{"object":{"type":"string","enum":["site-redirect"]},"id":{"type":"string","description":"The unique identifier for the redirect."},"source":{"$ref":"#/components/schemas/SiteRedirectSourcePath"},"draft":{"type":"boolean","description":"Whether the redirect is draft and not live."},"captureWildcard":{"type":"boolean","description":"Capture and append the wildcard-matched suffix to the destination URL."},"destination":{"$ref":"#/components/schemas/SiteRedirectDestination"}},"required":["object","id","source","draft","captureWildcard","destination"]},"SiteRedirectDestination":{"oneOf":[{"$ref":"#/components/schemas/SiteRedirectDestinationSiteSection"},{"$ref":"#/components/schemas/SiteRedirectDestinationSiteSpace"},{"$ref":"#/components/schemas/SiteRedirectDestinationPage"},{"$ref":"#/components/schemas/SiteRedirectDestinationExternal"}]},"SiteRedirectDestinationSiteSection":{"type":"object","properties":{"kind":{"type":"string","enum":["site-section"]},"siteSectionId":{"type":"string","description":"Unique identifier for the site section to redirect to"}},"required":["kind","siteSectionId"]},"SiteRedirectDestinationSiteSpace":{"type":"object","properties":{"kind":{"type":"string","enum":["site-space"]},"siteSpaceId":{"type":"string","description":"Unique identifier for the site space to redirect to"}},"required":["kind","siteSpaceId"]},"SiteRedirectDestinationPage":{"type":"object","properties":{"kind":{"type":"string","enum":["site-page"]},"siteSpaceId":{"type":"string","description":"Unique identifier for the site space of the page"},"pageId":{"type":"string","description":"Unique identifier for the page within the site space to redirect to"}},"required":["kind","siteSpaceId","pageId"]},"SiteRedirectDestinationExternal":{"type":"object","properties":{"kind":{"type":"string","enum":["external"]},"url":{"$ref":"#/components/schemas/URL"}},"required":["kind","url"]},"URL":{"type":"string","format":"uri","maxLength":2048}},"responses":{"NotFoundError":{"description":"Not Found","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","properties":{"code":{"type":"integer","format":"int32","enum":[404]},"message":{"type":"string"}},"required":["code","message"]}}}}}}}},"paths":{"/orgs/{organizationId}/sites/{siteId}/redirect":{"get":{"operationId":"getSiteRedirectBySource","summary":"Get a site redirect by its source","tags":["site-redirects"],"parameters":[{"$ref":"#/components/parameters/organizationId"},{"$ref":"#/components/parameters/siteId"},{"$ref":"#/components/parameters/siteShareKey"},{"name":"source","in":"query","required":true,"description":"The source path of the redirect.","schema":{"$ref":"#/components/schemas/SiteRedirectSourcePath"}}],"responses":{"200":{"description":"The redirect was resolved successfully.","content":{"application/json":{"schema":{"type":"object","properties":{"redirect":{"$ref":"#/components/schemas/SiteRedirect"},"target":{"type":"string","description":"URL of the destination of the redirect."}},"required":["redirect","target"]}}}},"404":{"$ref":"#/components/responses/NotFoundError"}}}}}}
```
