# setSiteAccessRule

Source: <https://telegafirst.com/docs/api-op-setsiteaccessrule>
Locale: ru
releaseGitSha: fc570c76ffc9cb87e2462d45b14f5c1b52fbaf0d
sourceContentDigest: c052d0102726adf4f92ea2ff8f074d9f6034b8946990bd1ff8441ff011228fbc
Version: 4

# setSiteAccessRule

`PUT /api/v1/tools/site/access-rules`

Open a page or a block of a page only to part of the audience

## Авторизация и права

Scopes: ALL. Auth alternatives: OR; scopes внутри альтернативы: ALL.

| Поле | Значение |
| - | - |
| security.0.hubApiKey | \[] |
| security.1.hubBearer | \[] |
| securitySchemes.hubApiKey.in | "header" |
| securitySchemes.hubApiKey.name | "X-Api-Key" |
| securitySchemes.hubApiKey.type | "apiKey" |
| securitySchemes.hubBearer.scheme | "bearer" |
| securitySchemes.hubBearer.type | "http" |
| x-required-scopes | \["site:write"] |

## Параметры запроса

| Поле | Значение |
| - | - |
| 0.description | "Tenant, credential and handler-bound byte-shape replay key" |
| 0.in | "header" |
| 0.name | "Idempotency-Key" |
| 0.required | false |
| 0.schema | [0.schema](https://telegafirst.com/docs/schema-9ac136edb99a2063b3091602181c8d2022fdccb5b514991319d58544c2e57e95) |

## Тело запроса

| Поле | Значение |
| - | - |
| content.application/json.schema | [SiteAccessRuleRequest](https://telegafirst.com/docs/schema-8e1c110edb7423be8ff331310e7de5d403690dc54bc5a60784e5feed42e3c814) |
| required | true |

## Ответы

| Поле | Значение |
| - | - |
| 200.content.application/json.schema | [SiteAccessRuleSetResult](https://telegafirst.com/docs/schema-f19fd1666921ca4a89a6bc1e5645e78c9667c53f6ec47776fb1f65656b7dff8c) |
| 200.description | "Tenant site control-plane result" |
| 200.headers.X-Bot-Username.description | "Active bot username, when resolved" |
| 200.headers.X-Bot-Username.schema | [200.headers.X-Bot-Username.schema](https://telegafirst.com/docs/schema-00404e686415370f1711c4d7acfa2905444d3cf23cef2e10c47d445ebe690f96) |
| 200.headers.X-Client-Slug.description | "Active tenant slug, when resolved" |
| 200.headers.X-Client-Slug.schema | [200.headers.X-Client-Slug.schema](https://telegafirst.com/docs/schema-00404e686415370f1711c4d7acfa2905444d3cf23cef2e10c47d445ebe690f96) |
| 200.headers.X-RateLimit-Limit.description | "Effective request budget" |
| 200.headers.X-RateLimit-Limit.schema | [200.headers.X-RateLimit-Limit.schema](https://telegafirst.com/docs/schema-00404e686415370f1711c4d7acfa2905444d3cf23cef2e10c47d445ebe690f96) |
| 200.headers.X-RateLimit-Remaining.description | "Remaining request budget" |
| 200.headers.X-RateLimit-Remaining.schema | [200.headers.X-RateLimit-Remaining.schema](https://telegafirst.com/docs/schema-00404e686415370f1711c4d7acfa2905444d3cf23cef2e10c47d445ebe690f96) |
| 200.headers.X-RateLimit-Reset.description | "Unix window reset in seconds" |
| 200.headers.X-RateLimit-Reset.schema | [200.headers.X-RateLimit-Reset.schema](https://telegafirst.com/docs/schema-00404e686415370f1711c4d7acfa2905444d3cf23cef2e10c47d445ebe690f96) |

## Ошибки

| Поле | Значение |
| - | - |
| 400.content.application/problem+json.schema | [ProblemDetails](https://telegafirst.com/docs/schema-cb940dbba4894d830b2ff33a2fbf4d6382de295156cd5a9ab88564d4c14aa2ab) |
| 400.description | "Invalid strict body" |
| 400.x-error-codes | \["VALIDATION\_ERROR"] |
| 401.content.application/problem+json.schema | [ProblemDetails](https://telegafirst.com/docs/schema-cb940dbba4894d830b2ff33a2fbf4d6382de295156cd5a9ab88564d4c14aa2ab) |
| 401.description | "Missing, invalid, revoked or conflicting credential; surface JWT is refused" |
| 401.x-error-codes | \["INVALID\_API\_KEY"] |
| 403.content.application/problem+json.schema | [ProblemDetails](https://telegafirst.com/docs/schema-cb940dbba4894d830b2ff33a2fbf4d6382de295156cd5a9ab88564d4c14aa2ab) |
| 403.description | "Missing scope, prohibited publishable credential or absent active bot" |
| 403.x-error-codes | \["INSUFFICIENT\_SCOPE","PUBLISHABLE\_KEY\_NOT\_ALLOWED","NO\_ACTIVE\_BOT"] |
| 409.content.application/problem+json.schema | [ProblemDetails](https://telegafirst.com/docs/schema-cb940dbba4894d830b2ff33a2fbf4d6382de295156cd5a9ab88564d4c14aa2ab) |
| 409.description | "Typed domain conflict or request in flight" |
| 409.x-error-codes | \["CONFLICT"] |
| 413.content.application/problem+json.schema | [ProblemDetails](https://telegafirst.com/docs/schema-cb940dbba4894d830b2ff33a2fbf4d6382de295156cd5a9ab88564d4c14aa2ab) |
| 413.description | "Resource policy size or item-count limit exceeded" |
| 413.x-error-codes | \["PAYLOAD\_TOO\_LARGE","ITEM\_COUNT\_EXCEEDED"] |
| 422.content.application/problem+json.schema | [ProblemDetails](https://telegafirst.com/docs/schema-cb940dbba4894d830b2ff33a2fbf4d6382de295156cd5a9ab88564d4c14aa2ab) |
| 422.description | "Replay key reused for different input; the rule is malformed; no such catalog item, saved segment or password, or the item is not sold as a subscription; the business has no connected public channel; the segment filter is invalid; the sign-in page is itself closed or there is no password to sign in with; the business is at its limit of rules" |
| 422.x-error-codes | \["IDEMPOTENCY\_KEY\_MISMATCH","SITE\_ACCESS\_RULE\_INVALID","SITE\_ACCESS\_CATALOG\_NOT\_FOUND","SITE\_ACCESS\_CATALOG\_NOT\_SUBSCRIPTION","SITE\_ACCESS\_CHANNEL\_NOT\_CONNECTED","SITE\_ACCESS\_SAVED\_SEGMENT\_NOT\_FOUND","SITE\_ACCESS\_SEGMENT\_INVALID","SITE\_ACCESS\_RULE\_LIMIT","SITE\_PASSWORD\_NOT\_FOUND","SITE\_ACCESS\_LOGIN\_PATH\_GATED","SITE\_ACCESS\_LOGIN\_PATH\_WITHOUT\_PASSWORD"] |
| 429.content.application/problem+json.schema | [ProblemDetails](https://telegafirst.com/docs/schema-cb940dbba4894d830b2ff33a2fbf4d6382de295156cd5a9ab88564d4c14aa2ab) |
| 429.description | "Resource rate budget exceeded or unavailable" |
| 429.headers.Retry-After.description | "Retry delay in seconds, when supplied by the limiter" |
| 429.headers.Retry-After.schema | [429.headers.Retry-After.schema](https://telegafirst.com/docs/schema-00404e686415370f1711c4d7acfa2905444d3cf23cef2e10c47d445ebe690f96) |
| 429.x-error-codes | \["RATE\_LIMIT\_EXCEEDED","RATE\_LIMIT\_UNAVAILABLE"] |
| 500.content.application/problem+json.schema | [ProblemDetails](https://telegafirst.com/docs/schema-cb940dbba4894d830b2ff33a2fbf4d6382de295156cd5a9ab88564d4c14aa2ab) |
| 500.description | "Unexpected internal failure" |
| 500.x-error-codes | \["INTERNAL\_ERROR"] |

## Дополнительные условия

| Поле | Значение |
| - | - |
| description | "Owner-only site:write. One rule per target: path (a mask of the path the page is served at, such as /pricing.html, /lessons/ or /lessons/\*, \* only last; /pricing does not match pricing.html) plus an optional block (a name of letters, digits and hyphens; the block is the bundle file \_\_telegafirst/blocks/{block}.html and the page holds only a data-tgf-block placeholder). Setting a target again updates its rule. any\_of (1 to 10 conditions) is who gets in, and one of the conditions is enough: a product (catalog\_id, a 0-price product counts), a live subscription ({\\"kind\\":\\"subscription\\"}: any paid one, a trial and a 0-price subscription do not count; with catalog\_id: to that subscription item, a trial and a 0-price one count, and a cancelled one counts until its paid period ends), the business public channel, any signed-in customer of this business ({\\"kind\\":\\"signed\_in\\"}), a saved segment (saved\_segment\_id), an inline segment filter, or a password by its name ({\\"kind\\":\\"password\\",\\"password\\":\\"acme\\"}, made with PUT /api/v1/tools/site/passwords). Where several masks match a path, the most specific mask decides and overrides the general one (/kp/acme/\* over /kp/\*); a block follows the most specific mask of its page. The platform keeps passwords. Never put a password in HTML or JS. The default sign-in page is ready; an own page is login\_path (open: outside every closed mask) plus /widget/gate.v1.js. Data for the admitted is a JSON file under the closed mask; a third-party API key is a site secret. mode is hide (default, the block is absent) or lock (a stub with the condition); without a block the whole page is closed and a visitor who fails goes to sign-in. is\_active false pauses the rule. Effective at once, no republish, and a republish keeps it; unprojected\_hosts above 0 counts hosts whose edge catches up on the next reconciliation. At most 200 rules per business, paused ones included. Idempotency-Key is optional for PUT." |
| operationId | "setSiteAccessRule" |
| summary | "Open a page or a block of a page only to part of the audience" |
| tags | \["site"] |
| x-idempotency.conflictStatus | 422 |
| x-idempotency.implementation | "global-cache" |
| x-idempotency.replayStatus | 200 |
| x-idempotency.required | false |
| x-idempotency.scope | \["client","credential","controller-handler","key"] |
| x-idempotency.ttlSeconds | 86400 |
| x-pagination.queryParameters | \[] |
| x-pagination.supported | false |
| x-scope-semantics | "ALL" |
