# Source: https://gitbook.com/docs/developers/gitbook-api/api-reference/docs-sites/site-auth.md

# Site auth

Configure the credentials or tokens required to publish documentation externally. This helps ensure your site is consistently kept up to date.

## The SitePublishingAuth object

```json
{"openapi":"3.0.3","info":{"title":"GitBook API","version":"0.0.1-beta"},"components":{"schemas":{"SitePublishingAuth":{"allOf":[{"oneOf":[{"$ref":"#/components/schemas/VisitorAuthCustomBackend"},{"$ref":"#/components/schemas/VisitorAuthIntegrationBackend"}]},{"type":"object","properties":{"object":{"type":"string","description":"Type of Object, always equals to \"publishing-auth\"","enum":["publishing-auth"]},"privateKey":{"type":"string","description":"Private key used to sign JWT tokens."},"fallbackURL":{"type":"string","format":"uri","description":"URL to redirect to when the authenticated access secret is invalid."},"integration":{"type":"string","description":"Name of the authenticated access integration installed on the site (if any).\nIt is also the one being used as VA backend when the published auth settings are configured to use \"integration\" as backend.\n"}},"required":["object","privateKey"]}]},"VisitorAuthCustomBackend":{"type":"object","title":"Custom backend for authenticated access","properties":{"backend":{"type":"string","description":"Custom backend for authenticated access","enum":["custom"]}},"required":["backend"]},"VisitorAuthIntegrationBackend":{"type":"object","title":"Integration backend for authenticated access","properties":{"backend":{"type":"string","description":"Integration as backend for authenticated access","enum":["integration"]}},"required":["backend"]}}}}
```

## GET /orgs/{organizationId}/sites/{siteId}/publishing/auth

> Get a site auth config

```json
{"openapi":"3.0.3","info":{"title":"GitBook API","version":"0.0.1-beta"},"tags":[{"name":"site-publishing-auth","description":"Configure the credentials or tokens required to publish documentation externally. This helps ensure your site is consistently kept up to date.\n\n{% openapi-schemas spec=\"gitbook\" schemas=\"SitePublishingAuth\" grouped=\"false\" %}\n    The SitePublishingAuth 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":{"type":"string"}},"siteId":{"name":"siteId","in":"path","required":true,"description":"The unique id of the site","schema":{"type":"string"}}},"schemas":{"SitePublishingAuth":{"allOf":[{"oneOf":[{"$ref":"#/components/schemas/VisitorAuthCustomBackend"},{"$ref":"#/components/schemas/VisitorAuthIntegrationBackend"}]},{"type":"object","properties":{"object":{"type":"string","description":"Type of Object, always equals to \"publishing-auth\"","enum":["publishing-auth"]},"privateKey":{"type":"string","description":"Private key used to sign JWT tokens."},"fallbackURL":{"type":"string","format":"uri","description":"URL to redirect to when the authenticated access secret is invalid."},"integration":{"type":"string","description":"Name of the authenticated access integration installed on the site (if any).\nIt is also the one being used as VA backend when the published auth settings are configured to use \"integration\" as backend.\n"}},"required":["object","privateKey"]}]},"VisitorAuthCustomBackend":{"type":"object","title":"Custom backend for authenticated access","properties":{"backend":{"type":"string","description":"Custom backend for authenticated access","enum":["custom"]}},"required":["backend"]},"VisitorAuthIntegrationBackend":{"type":"object","title":"Integration backend for authenticated access","properties":{"backend":{"type":"string","description":"Integration as backend for authenticated access","enum":["integration"]}},"required":["backend"]}},"responses":{"BadRequestError":{"description":"Bad Request","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","properties":{"code":{"type":"integer","format":"int32","enum":[400]},"message":{"type":"string"}},"required":["code","message"]}}}}}}}},"paths":{"/orgs/{organizationId}/sites/{siteId}/publishing/auth":{"get":{"operationId":"getSitePublishingAuthById","summary":"Get a site auth config","tags":["site-publishing-auth"],"parameters":[{"$ref":"#/components/parameters/organizationId"},{"$ref":"#/components/parameters/siteId"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SitePublishingAuth"}}}},"400":{"$ref":"#/components/responses/BadRequestError"}}}}}}
```

## PATCH /orgs/{organizationId}/sites/{siteId}/publishing/auth

> Update a site auth config

```json
{"openapi":"3.0.3","info":{"title":"GitBook API","version":"0.0.1-beta"},"tags":[{"name":"site-publishing-auth","description":"Configure the credentials or tokens required to publish documentation externally. This helps ensure your site is consistently kept up to date.\n\n{% openapi-schemas spec=\"gitbook\" schemas=\"SitePublishingAuth\" grouped=\"false\" %}\n    The SitePublishingAuth 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":{"type":"string"}},"siteId":{"name":"siteId","in":"path","required":true,"description":"The unique id of the site","schema":{"type":"string"}}},"schemas":{"SitePublishingAuthUpdate":{"allOf":[{"oneOf":[{"$ref":"#/components/schemas/VisitorAuthCustomBackend"},{"$ref":"#/components/schemas/VisitorAuthIntegrationBackend"}]},{"type":"object","properties":{"fallbackURL":{"type":"string","format":"uri","description":"A fallback URL that will be used if authentication fails. If not provided, the fallback URL will not be changed. If set to null, the fallback URL will be unset.","nullable":true}}}]},"VisitorAuthCustomBackend":{"type":"object","title":"Custom backend for authenticated access","properties":{"backend":{"type":"string","description":"Custom backend for authenticated access","enum":["custom"]}},"required":["backend"]},"VisitorAuthIntegrationBackend":{"type":"object","title":"Integration backend for authenticated access","properties":{"backend":{"type":"string","description":"Integration as backend for authenticated access","enum":["integration"]}},"required":["backend"]},"SitePublishingAuth":{"allOf":[{"oneOf":[{"$ref":"#/components/schemas/VisitorAuthCustomBackend"},{"$ref":"#/components/schemas/VisitorAuthIntegrationBackend"}]},{"type":"object","properties":{"object":{"type":"string","description":"Type of Object, always equals to \"publishing-auth\"","enum":["publishing-auth"]},"privateKey":{"type":"string","description":"Private key used to sign JWT tokens."},"fallbackURL":{"type":"string","format":"uri","description":"URL to redirect to when the authenticated access secret is invalid."},"integration":{"type":"string","description":"Name of the authenticated access integration installed on the site (if any).\nIt is also the one being used as VA backend when the published auth settings are configured to use \"integration\" as backend.\n"}},"required":["object","privateKey"]}]}},"responses":{"BadRequestError":{"description":"Bad Request","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","properties":{"code":{"type":"integer","format":"int32","enum":[400]},"message":{"type":"string"}},"required":["code","message"]}}}}}}}},"paths":{"/orgs/{organizationId}/sites/{siteId}/publishing/auth":{"patch":{"operationId":"updateSitePublishingAuthById","summary":"Update a site auth config","tags":["site-publishing-auth"],"parameters":[{"$ref":"#/components/parameters/organizationId"},{"$ref":"#/components/parameters/siteId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SitePublishingAuthUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SitePublishingAuth"}}}},"400":{"$ref":"#/components/responses/BadRequestError"}}}}}}
```

## Regenerate a site auth

> Regenerate the publishing authentication settings for a site. This will re-generate the private key.

```json
{"openapi":"3.0.3","info":{"title":"GitBook API","version":"0.0.1-beta"},"tags":[{"name":"site-publishing-auth","description":"Configure the credentials or tokens required to publish documentation externally. This helps ensure your site is consistently kept up to date.\n\n{% openapi-schemas spec=\"gitbook\" schemas=\"SitePublishingAuth\" grouped=\"false\" %}\n    The SitePublishingAuth 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":{"type":"string"}},"siteId":{"name":"siteId","in":"path","required":true,"description":"The unique id of the site","schema":{"type":"string"}}},"schemas":{"SitePublishingAuth":{"allOf":[{"oneOf":[{"$ref":"#/components/schemas/VisitorAuthCustomBackend"},{"$ref":"#/components/schemas/VisitorAuthIntegrationBackend"}]},{"type":"object","properties":{"object":{"type":"string","description":"Type of Object, always equals to \"publishing-auth\"","enum":["publishing-auth"]},"privateKey":{"type":"string","description":"Private key used to sign JWT tokens."},"fallbackURL":{"type":"string","format":"uri","description":"URL to redirect to when the authenticated access secret is invalid."},"integration":{"type":"string","description":"Name of the authenticated access integration installed on the site (if any).\nIt is also the one being used as VA backend when the published auth settings are configured to use \"integration\" as backend.\n"}},"required":["object","privateKey"]}]},"VisitorAuthCustomBackend":{"type":"object","title":"Custom backend for authenticated access","properties":{"backend":{"type":"string","description":"Custom backend for authenticated access","enum":["custom"]}},"required":["backend"]},"VisitorAuthIntegrationBackend":{"type":"object","title":"Integration backend for authenticated access","properties":{"backend":{"type":"string","description":"Integration as backend for authenticated access","enum":["integration"]}},"required":["backend"]}},"responses":{"BadRequestError":{"description":"Bad Request","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","properties":{"code":{"type":"integer","format":"int32","enum":[400]},"message":{"type":"string"}},"required":["code","message"]}}}}}}}},"paths":{"/orgs/{organizationId}/sites/{siteId}/publishing/auth/regenerate":{"post":{"operationId":"regenerateSitePublishingAuthById","summary":"Regenerate a site auth","description":"Regenerate the publishing authentication settings for a site. This will re-generate the private key.","tags":["site-publishing-auth"],"parameters":[{"$ref":"#/components/parameters/organizationId"},{"$ref":"#/components/parameters/siteId"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SitePublishingAuth"}}}},"400":{"$ref":"#/components/responses/BadRequestError"}}}}}}
```