# BeatyBook agent integration guide

Scope: customer booking, plus a separately authorized owner catalogue, calendar,
and price, service and manual-window proposals with browser review or separately
consented application from the chat.
Use the live [OpenAPI](https://beatybook.ru/api/agent/v1/openapi.json) and
[MCP server card](https://beatybook.ru/.well-known/mcp/server-card.json) as the
parameter/schema reference. [Human documentation](https://beatybook.ru/developers/)
is available in Russian. Do not infer capabilities from BeatyBook's internal Zoya tools.

## Use current information

Read the documentation and discovery metadata from the deployment you are
connecting to. OpenAPI describes its current REST schemas; OAuth metadata lists
its supported authorization flows and scopes. The public MCP server card lists
server capabilities, not permissions granted to your connection. After
authorization, inspect `get_connection` and `tools/list`; each tool call still
checks the effective grant. A feature described for another deployment or in an
old conversation is not evidence that it is available to this connection.

Fetch the project's current services, prices, availability and known booking
status through the authorized API before advising the person or making a change.
Do not answer from remembered catalogue data, treat a calendar snapshot as a
reservation, or claim that submitting a proposal applied its change.
Unless an absolute URL is shown, REST paths in this guide are relative to
`/api/agent/v1`.

## Connection and authentication

- REST base: `https://beatybook.ru/api/agent/v1`.
- MCP: `POST https://beatybook.ru/mcp`, stateless JSON-RPC 2.0,
  protocol `2025-06-18`, Streamable HTTP with JSON responses.
- Discover OAuth endpoints at `/.well-known/oauth-authorization-server` and the
  exact protected `resource` at `/.well-known/oauth-protected-resource`.
  The default resource identifier is `https://beatybook.ru` for both REST and MCP.
  On another deployment use its advertised identifier; do not substitute the
  REST base, `/mcp`, or an arbitrary host.
- Two access methods are supported: owner-approved Authorization Code + PKCE S256
  with rotating refresh tokens for personal agents, and `client_credentials`
  with `client_secret_post` for server-side integrations.
- Native ChatGPT/Dots account linking has not been verified end to end. A client
  must support the published authorization flow; an MCP URL alone is insufficient.
- Never ask a user to paste credentials, tokens or PKCE verifiers into an ordinary
  assistant conversation. Keep them in the integrating client's protected storage.

### Persistent personal-agent connection

The server supports CIMD and advertises
`client_id_metadata_document_supported: true` in its authorization-server
metadata. Check the target deployment's current metadata before choosing CIMD;
DCR below remains available.

For CIMD, skip `/oauth/register` and use the exact HTTPS metadata-document URL
as `client_id` throughout the flow. The document must contain the same exact
`client_id` and registered `redirect_uris`. An optional `client_name` is
self-declared and limited to 100 characters. `grant_types` must allow
`authorization_code` (the default); add `refresh_token` for persistence.
`response_types` must allow `code` (the default). Public authentication is
`none`; PKCE S256 and owner consent remain mandatory. A plural
`token_endpoint_auth_methods_supported: ["none", "private_key_jwt"]` is accepted
with the legacy singular preference `private_key_jwt`; BeatyBook selects `none`.
It does not support signed client assertions. If both auth-method fields are
omitted, `none` is assumed. Shared client secrets are forbidden.

CIMD URLs must be ASCII HTTPS on port 443, at most 2048 characters, with a
non-root path and no query, fragment, userinfo or dot path segments. The server
requires HTTP 200 JSON, follows no redirects, bounds retrieval to 5 seconds and
64 KiB of decoded content, and connects only to validated public DNS addresses
with TLS verification. It does not fetch referenced logos or JWKS URLs.
Metadata is checked on authorization and before consuming valid code/PKCE or
refresh credentials. Client-ID mismatch revokes that client's grants; transient
retrieval failures return HTTP 503 without consuming credentials or revoking
existing grants. Protected API calls do not retrieve metadata.
See [authentication](https://beatybook.ru/auth.md#client-id-metadata-documents-cimd)
for a complete document example, exact callback rules and failure handling.

1. For DCR, register a public application with `POST /oauth/register` and JSON:

   ```json
   {
     "client_name": "Example appointment assistant",
     "redirect_uris": ["https://agent.example/oauth/callback"],
     "token_endpoint_auth_method": "none",
     "grant_types": ["authorization_code", "refresh_token"],
     "response_types": ["code"]
   }
   ```

   HTTP 201 returns `client_id` and the registered metadata, with no client secret.
   `application_type` is optional and defaults to `web`. Optional registration
   `scope` is a supported-scope hint of at most 512 characters validated against
   the published scope set. Omitted/null metadata is accepted and omitted from
   the response. A supplied string must be nonempty and contain only known
   scopes; empty/unknown scopes return `invalid_scope`, wrong types or excessive
   length return `invalid_request`. Valid scope metadata is echoed as unique
   sorted tokens separated by single spaces. This is informational metadata, not a grant: the
   authorization request still needs `scope`, and the person must separately
   choose permissions. It does not preselect owner permissions. Supply a
   visible name of at most 100 characters and 1–5
   distinct redirect URIs. Web applications use exact public HTTPS callbacks.
   Native applications must explicitly send `"application_type":"native"` to
   register an HTTP loopback callback, for example
   `http://127.0.0.1:45871/callback` or `http://[::1]:45871/callback`.
   Only these literal loopback hosts and an explicit decimal port 1–65535 are
   accepted: no `localhost`, alternative IP notation, leading-zero ports,
   private-network hosts, userinfo or fragments, including an empty `#`.
   Preconfigured `code`, `state`, `error`, `error_description` or `iss` query
   parameters are rejected. For native loopback only, authorization may select
   a different port; scheme, literal IP, path and query must still match.
   The exact callback chosen for that attempt is then bound to consent and
   the code exchange. Other redirect matching is exact, without wildcards.
   Application names are self-declared and unverified. Registration grants no
   project access and does not mean BeatyBook endorses the application.

   Native registration example, including the supported-scope metadata sent
   by clients such as Codex (the port and callback are illustrative):

   ```json
   {
     "client_name": "Codex",
     "application_type": "native",
     "redirect_uris": ["http://127.0.0.1:45871/callback"],
     "token_endpoint_auth_method": "none",
     "grant_types": ["authorization_code", "refresh_token"],
     "response_types": ["code"],
     "scope": "services:read"
   }
   ```
2. Generate a cryptographically random PKCE verifier (43–128 characters from
   `A–Z`, `a–z`, `0–9`, `-._~`) and independent unpredictable `state` for this attempt. Keep both private.
   Derive `code_challenge = BASE64URL(SHA256(ASCII(code_verifier)))` without padding.
   Open `GET /oauth/authorize` in the user's browser with URL-encoded parameters:

   ```text
   response_type=code
   client_id=<registered_client_id_or_exact_CIMD_URL>
   redirect_uri=https://agent.example/oauth/callback
   state=<random_state>
   resource=https://beatybook.ru
   code_challenge=<S256_challenge>
   code_challenge_method=S256
   scope=services:read availability:read bookings:read
   ```

   All parameters above are required. Use one value per parameter. Add
   `bookings:write` only if the person needs changes to bookings.
3. BeatyBook redirects to its private `/connect-agent` page. The person signs in,
   checks the unverified application name and callback origin, chooses a project
   they actually own or administer, and approves a subset of requested scopes.
   The three requested booking read scopes start selected. `bookings:write` and
   every `owner:*` permission require explicit selections, including catalogue
   and calendar reading. Existing connections do not gain new scopes; reconnect
   interactively to request them.
   The request expires after 5 minutes and is bound to the first signed-in browser
   session that opens its consent context. Do not share or embed consent links.
4. The exact callback chosen for this attempt receives `code`, `state`, and `iss` on approval,
   or `error=access_denied`, `state`, and `iss` on denial. Verify the original
   `state` and expected issuer before accepting a code. Codes are single-use and
   expire after 5 minutes. Denial is not a partial success.
5. Exchange the code at `POST /oauth/token` with form-encoded
   `grant_type=authorization_code`, `client_id`, `code`, the same `redirect_uri`,
   `code_verifier`, and the exact same `resource`. Do not send a client secret or
   an Authorization header or signed client assertion: public clients use `none`.
   The response contains `access_token`, `token_type=Bearer`, `expires_in=3600`,
   effective space-separated `scope`, and `refresh_token` when client metadata
   allows refresh. Inspect granted scopes:
   the person may have declined requested write access.
6. Before access expiry, send form-encoded `grant_type=refresh_token`, `client_id`,
   `refresh_token`, and the same `resource` to `/oauth/token`. Optional `scope`
   may narrow the previous token's scope and cannot later restore removed scopes.
   Each success returns a new access token and a new refresh token. Persist the
   new refresh token atomically and discard the previous value.

Serialize refreshes for one connection. Every refresh token is single-use:
reusing a consumed token revokes the entire connection and its refresh family,
including newly issued access tokens on their next authenticated request.
If a refresh response is lost, do not blindly replay the old token. Restart
interactive authorization when the result cannot be recovered safely.
OAuth errors use `{"error":"…","error_description":"…"}`, unlike booking errors.
On `invalid_grant`, stop refreshing and reconnect with the person.

The grant and refresh family expire **30 days after consent**; refresh does not
extend this deadline. Reconnect then. A connection survives ordinary logout, but
current project status, application status, grant status and the consenting
person's actual owner/admin role are checked for each protected request and refresh.
Losing that role or disabling the project stops access. An owner/admin can revoke
connections in project Settings → AI agents («ИИ-агенты»); revocation blocks the next
REST/MCP call, even if its access token has time left. An already admitted operation
may still finish. Only explicitly selected scopes are granted; proposing a change
does not authorize its application or general owner-account control.

Each revoke operation targets one `grant_id` and its refresh families. New
consent creates another grant; older active connections are not silently removed.
Disconnect every active connection for that application/project if all of its
existing access should end.

### Server-side integration keys

A studio owner/admin creates a key in the project's Settings → AI agents («ИИ-агенты»).
Each key belongs to one project and its secret is shown once. Obtain a token with
`POST /oauth/token`, form-encoded `grant_type=client_credentials`, `client_id`,
`client_secret`, optional space-separated `scope`. These keys do not issue refresh
tokens: request a new access token with the key after 3600 seconds.

Omitted `scope` requests the key's grants. An explicit scope must be nonempty,
known, and entirely granted to the key; invalid requests fail with `invalid_scope`.
Revocation blocks subsequent authenticated REST/MCP calls even before token expiry.
Store the secret in your secret manager; never expose it in tool descriptions,
chat, browser storage, URLs or logs.

### Start with read-only operations

New keys default to `services:read availability:read bookings:read`.
`bookings:write` must be enabled explicitly. It grants creation, confirmation,
rescheduling and cancellation for this project; it is not limited to the key's
own bookings and is not required for a connection test.

1. Complete the selected authorization flow, preferably request only
   `services:read availability:read` for a first check.
2. Call `GET /connection` or MCP `get_connection` (no arguments).
3. Verify `project.id`, `project.name`, `project.timezone`, and `scopes`.
4. Read `/services` and `/availability`. Do not create test appointments or send
   test SMS to real people just to check connectivity.

Connection response:

```json
{
  "client_id": "agt_example",
  "project": {"id": 123, "name": "Example studio", "timezone": "Europe/Moscow"},
  "scopes": ["availability:read", "services:read"],
  "writes_enabled": true,
  "authentication": {
    "grant_type": "client_credentials",
    "interactive_login_supported": true
  },
  "documentation_url": "https://beatybook.ru/developers/"
}
```

`writes_enabled` is an operational switch, not a permission grant. Writes require
both an enabled switch and the `bookings:write` scope.

## Methods and permissions

Every REST path below is relative to `/api/agent/v1` and needs Bearer authentication.
The OAuth registration/authorization/token endpoints and published documentation
are public; consent and connection-management endpoints require a signed-in
BeatyBook browser session, not the agent's Bearer token.

| REST method | MCP tool | Required scope | Result / key arguments |
| --- | --- | --- | --- |
| `GET /connection` | `get_connection` | Any valid token | Project identity, effective scopes and operational flags |
| `GET /services` | `search_services` | `services:read` | `services[]`: `id`, `name`, `price_rub`, `duration_hours` |
| `GET /availability` | `get_availability` | `availability:read` | `slots[]`; optional `service_type_id`, `date` |
| `GET /bookings/{booking_id}` | `get_booking` | `bookings:read` | Status of a known booking in this project |
| `POST /bookings` | `create_booking` | `bookings:write` | SMS verification intent; REST 202 |
| `POST /bookings/confirm` | `confirm_booking` | `bookings:write` | `verification_id`, `code` → booking result |
| `POST /bookings/{booking_id}/reschedule` | Not exposed in MCP | `bookings:write` | `{"new_slot_id":456}` → booking result |
| `POST /bookings/{booking_id}/cancel` | `cancel_booking` | `bookings:write` | REST 204 without a response body on success |
| `GET /owner/services` | `get_owner_services` | `owner:services:read` | Delegated OAuth only; paginated owner catalogue and price-edit eligibility |
| `POST /owner/proposals/service-price` | `propose_service_price` | `owner:proposals:write`, `owner:services:read` | Delegated OAuth only; saves one proposal without applying a price |
| `GET /owner/proposals/{proposal_id}` | `get_owner_proposal` | `owner:proposals:write` | Read status of a proposal belonging to this exact connection |
| `POST /owner/proposals/{proposal_id}/apply` | `apply_owner_proposal` | `owner:changes:apply` | Apply this connection's immutable price/service/window proposal; original read/propose scopes are rechecked |
| `GET /owner/calendar` | `get_owner_calendar` | `owner:calendar:read` | Delegated OAuth only; bounded schedule without customer contact data |
| `POST /owner/change-proposals/service` | `propose_service_change` | `owner:changes:propose`, `owner:services:read` | Save one service metadata proposal; REST 202 |
| `POST /owner/change-proposals/slot` | `propose_slot_change` | `owner:calendar:read`, `owner:changes:propose` | Save one manual free-window proposal; REST 202 |
| `GET /owner/change-proposals/{proposal_id}` | `get_owner_change_proposal` | `owner:changes:propose` | Read this connection's service/window proposal and human decision |

The proposal methods never apply a change themselves. A separate, explicit
`owner:changes:apply` permission enables application of the same connection's
immutable proposals without a website confirmation. Staff/roles, payment credentials, automatic
schedule rules, customer database export, SQL and general account settings are
not exposed. `owner:proposals:write` remains price-only: it does not grant the
new `owner:changes:propose` permission. Booking scopes do not grant either.

## MCP-only permission request

MCP additionally provides this helper; it has no REST equivalent:

| MCP-only tool | Access | Arguments / result |
| --- | --- | --- |
| `request_owner_access` | Personal delegated OAuth; no changes to project data | `operation`: `service_price`, `service_details` or `manual_windows`; explicit `mode`: `read`, `propose` or `apply`; `access_context` from `get_connection.authentication.owner_access_context`. Prepares only the selected level of access; `ready` does not mean applied. |

## Clarify and apply in the current chat

MCP `initialize` includes server `instructions`; tool annotations describe reads,
writes and destructive application. Refresh cached tool definitions after a
server update. Clarify missing details in the current chat before proposing any
change. Do not send the person to the website just to collect those details.
For a new window agree date, local time, master and service restrictions. Read
`get_connection` for project/timezone, `get_owner_calendar` for master IDs/names,
and `get_owner_services` for service IDs. Ask one short combined question for
missing choices; do not choose a general window or all services on their behalf.

Before creating a proposal for chat application, prepare access as described
below. `owner:changes:apply` starts unchecked; old grants and issued tokens never
gain it automatically. Show the exact returned summary, including effective
duration/price and local time, then obtain explicit agreement for that proposal. Call `apply_owner_proposal`
with only `proposal_id`, or send `POST /owner/proposals/{proposal_id}/apply`
with the Bearer token and no body. The same method handles price, service and
manual-window proposals. It cannot change the proposal payload or adopt another
connection's proposal, even for the same owner/project.

This permission authorizes application without a separate website decision.
The server cannot prove that a chat message was written by a human; host
confirmation prompts depend on the client's settings. MCP annotations and these
instructions guide that client, while the server independently checks current
grant, actor role, original read/propose/apply scopes, proposal expiry, immutable
target snapshot, native business rules and the global write switch. Do not
describe a model instruction as a server-enforced per-action human approval.

Only `status=applied` means saved. Retrying the same proposal ID is idempotent;
after a lost response read status or retry that ID, never create a replacement
window to recover an unknown result. Terminal proposals are not reapplied.
An expired/stale proposal needs fresh data, a new proposal and renewed agreement.
Without the apply permission, create a proposal using the original read/propose
permissions and give `review_url` for the person's browser session. Do not request
apply permission merely to produce that browser-review proposal. Ask for it only
when the person wants application from the chat. Never collect cookies/CSRF tokens or automate
the browser-only decision endpoints.

### Request additional access before creating a proposal

A compatible MCP host can open its native OAuth linking flow when more permission
is needed. This still requires the owner's interactive consent in BeatyBook;
a chat instruction never silently grants permissions.

1. Read `get_connection`. For a delegated personal connection, retain
   `authentication.owner_access_context` unchanged. It is an opaque signed
   continuation valid for about 10 minutes, not an access token: it grants no
   permissions, does not replace the Bearer token and should not be printed in
   the conversation.
2. Call `request_owner_access` with that context, the intended `operation`
   (`service_price`, `service_details` or `manual_windows`) and an explicit
   `mode`. Use `read` to view the catalogue/calendar, `propose` for a proposal
   the person will review in BeatyBook, and `apply` only when the person wants
   application from chat. If that preference is absent, use `propose` for a
   requested change rather than requesting application rights. The helper
   creates no proposal and applies no change. It includes current effective
   scopes in the request, but the person can deselect them during consent.
3. If additional scopes are needed, the tool returns an OAuth challenge in
   `_meta["mcp/www_authenticate"]`. Let the host handle it. After consent, retry
   the **same helper arguments**, including the original context; this verifies
   the same client, owner and project across the new grant. Do not obtain a
   replacement context merely to bypass a failed continuation check.
4. Only `ready` means the selected level of access is prepared. For `read`,
   retrieve and explain the requested data. For a change, read current data,
   clarify the requested details, create a fresh proposal and show its summary.
   In `propose` mode give `review_url`; in `apply` mode obtain explicit agreement
   for that exact proposal before applying it.

The task-specific scope sets for `mode=apply` are:

| `operation` | Required scopes for application from chat |
| --- | --- |
| `service_price` | `owner:services:read`, `owner:proposals:write`, `owner:changes:apply` |
| `service_details` | `owner:services:read`, `owner:changes:propose`, `owner:changes:apply` |
| `manual_windows` | `owner:calendar:read`, `owner:services:read` (to agree service restrictions), `owner:changes:propose`, `owner:changes:apply` |

For `mode=propose`, remove `owner:changes:apply` from those sets. For `mode=read`,
`service_price` and `service_details` require only `owner:services:read`, while
`manual_windows` requires only `owner:calendar:read`. A catalogue or calendar
read must not request proposal or application rights. Read-only access requests
remain available while project writes are temporarily disabled.

Pass `mode` explicitly. Its omitted value remains `apply` only for compatibility
with the first helper contract; it is not a recommendation to seek broader rights.

Treat `consent_incomplete` (required rights were not all granted),
`connection_changed` (different owner/project/client), `invalid_context`
(expired or invalid continuation) and `access_reduced` (previous rights removed)
as terminal for this attempt. Do not automatically start another OAuth round.
Stop after denial. If the current connection still has the original read/propose
rights and the person chooses browser review, it can create a proposal without
the apply permission. Otherwise explain the missing rights; do not imply a
`review_url` exists before a proposal was created. A fresh access attempt must be
a new deliberate choice, not a retry loop.

A proposal belongs to the exact grant that created it. If reconnection happened
after its creation, do not retry the old ID under the new grant or adopt it into
the new connection. Check the project and current data, create a fresh proposal,
and show a fresh summary for explicit agreement. Consent to more permissions
is not agreement to apply a previously described change.

Delegated connections can discover all owner tool descriptions through
`tools/list` before their scopes are granted; every execution still checks
permissions. Each tool publishes `securitySchemes` and the compatibility mirror
`_meta.securitySchemes`. Existing tools declare their actual required scopes;
`request_owner_access` declares OAuth with `scopes: []` because its challenge
selects the exact operation- and mode-specific set. The error result contains
`_meta["mcp/www_authenticate"]` with a Bearer `insufficient_scope` challenge,
`resource_metadata`, `scope` and `error_description`. A successful HTTP 200 may
therefore still require authorization; inspect `result.isError` and let the host
process the metadata. Unsupported permissions, revoked access, role loss,
machine keys and business errors must not be treated as permission-upgrade loops.
No new REST route or OAuth scope is introduced by this helper.

The server contract follows the [OpenAI tool-level authentication flow](https://developers.openai.com/plugins/build/auth).
Actual native linking, consent and return to the conversation must be verified
in the intended ChatGPT/Dots version; support is not guaranteed for every MCP host.

## Owner catalogue and price proposals

Request both `owner:services:read owner:proposals:write` during interactive
authorization. They are available only to a personal OAuth connection approved
by a real project owner/admin. Machine keys and existing booking-only grants
do not acquire them. Requesting a scope does not select it for the person.

1. Call `GET /owner/services` or `get_owner_services`. Use `limit` (1–100,
   default 50) and the returned `next_cursor` as `after_id` for the next page.
   Confirm the returned project. Inspect `price_editable` and `price_edit_reason`;
   do not guess that every catalogue entry supports a price proposal.
2. For a supported service, call `POST /owner/proposals/service-price` with a
   fresh `Idempotency-Key` and JSON:

   ```json
   {"service_type_id": 123, "new_price_rub": "1700.00"}
   ```

   MCP `propose_service_price` takes these two fields and `idempotency_key`.
   A price is a decimal **string in RUB**, with at most two fractional digits,
   not a float or an amount in kopecks. Currency conversion and exponent notation
   are unsupported. Preserve the same key for a retry of this exact request;
   reusing it for different input is a conflict.
3. The returned proposal contains the server-verified project, service,
   `old_price_rub`, `new_price_rub`, expiry, status and `review_url`.
   **Pending is not applied.** Follow the chat application workflow above if
   `owner:changes:apply` was explicitly granted; otherwise give the review link.
   Never act as the person's browser or request their cookie/CSRF token.
4. Without the apply permission the person signs in on the private review page, checks the exact before/after
   values and approves or rejects. This requires a current DB-backed browser
   session, actual owner/admin membership and CSRF protection; an agent Bearer
   token cannot authorize either decision.
5. Read `GET /owner/proposals/{proposal_id}` or `get_owner_proposal`.
   Report success only for `status=applied`. `rejected`, `expired`, `stale` and
   `invalidated` do not mean the requested price was written. A stale target
   needs a new proposal and a new decision, not an automatic rebase.

One proposal changes one fixed price. It expires after 10 minutes; at most 20
pending proposals may belong to one connection and 100 to a project. The initial supported case is
a visible, fixed-price slot service with one unambiguous price-list entry,
without variants, hourly/interval pricing, proportional fees or prepayments.
Inconsistent prices, unsupported entries and active legacy bookings without
an agreed-price snapshot are not editable through this path.

Approval checks the saved target snapshot and the source application's grant,
project, expiry, scopes and the consenting person's current role again. The
catalogue price, booking-service price and proposal result are committed together.
Created payment amounts and saved visit-price snapshots are not rewritten.
Some older booking displays read the current service price; do not promise
that every existing booking card will keep its old displayed price.

If a manual editor currently holds a target row, human approval returns
`409 price_busy` without changing either price or the saved decision. Read the
proposal again, then let the person retry once the editor has finished.

Revoking the source connection prevents applying its pending proposals.
Narrowing scopes on a token refresh narrows subsequent tokens; it does not
cancel an already saved proposal while the underlying consent remains valid.
Use explicit rejection or connection revocation to stop pending work.
The global agent-write switch also blocks proposal creation and application.
Proposal status remains readable when writes are disabled. Another connection,
even to the same project or application, cannot read this proposal as an agent.

## Owner calendar and service/window proposals

These methods require a personal delegated OAuth connection. Request
`owner:calendar:read` for schedule reading and separately request
`owner:changes:propose` plus the matching read scope for proposals. They start
unchecked on consent. Server keys and old price-only grants cannot use them.

### Read the schedule without customer details

Call `GET /owner/calendar?start=<UTC>&end=<UTC>` or `get_owner_calendar` with
`start` and `end` in strict ISO UTC (`Z` or `+00:00`), a positive range of at most
31 days, optional `limit` 1–100 (default 100), and the returned `next_cursor`
as `cursor` to continue the same project/range. Keep the range unchanged while
paging. Treat cursors as opaque.

The response includes the project timezone/mode, range, `events`,
`working_hours` and `working_hours_status`, and
`automatic_schedule.{enabled,materialized_until}`. An event has `id`, `kind`
(`free`, `busy`, `payment_hold`, `block`, `external_busy`), UTC `starts_at`,
nullable `ends_at`, nullable `slot_id`, `master_user_id`, `service_type_id`,
`service_type_ids` and `read_only`. No customer names, phone numbers, notes,
external event titles or payment details are returned. A free window may have
no fixed end. `read_only=false` is only a candidate for a proposal, never a
promise that approval will succeed.

`masters` lists up to 100 currently eligible booking masters as `{id,name}`,
including an eligible legacy owner. It excludes administrators who do not take
bookings, blocked users, explicit booking opt-outs and other projects.
`masters_truncated:true` means this list is incomplete; do not guess omitted IDs.
No master contact information is exposed.

`availability_authoritative` is **false**. This calendar is a bounded snapshot,
not complete bookable availability or a synchronization subscription. Automatic
windows beyond `materialized_until` may not exist yet. Use `/availability` with
`availability:read` before offering an appointment to a customer.

### Propose exact fields

Every proposal POST needs an `Idempotency-Key` of 1–128 printable nonspace ASCII
characters. Reuse the key only for the same unchanged payload and connection;
different input under the same key returns a conflict. MCP uses the equivalent
`idempotency_key` argument.

- Service: `POST /owner/change-proposals/service` with
  `{"service_type_id":123,"changes":{"name":"Manicure","duration_minutes":78,"is_hidden":false}}`.
  `kind:"service_update"` is optional in REST. Supply at least one changed field.
  Only `name` (trimmed, 1–200 characters), `duration_minutes` (integer 5–720), and
  `is_hidden` (boolean) are supported; explicit null and unknown fields are
  rejected. Omitted fields stay unchanged. Duration is rounded to the existing
  six-minute storage step; the human summary shows the effective result, such
  as 75 requested → 78 minutes. Only unarchived per-service entries in slot mode
  with one unambiguous top-level price card and no variants are supported.
  Changing duration is refused when an active legacy booking lacks a saved
  duration. This method cannot change the price, description, prepayment or
  pricing mode; use the separate price proposal for an eligible fixed price.
- New window: `POST /owner/change-proposals/slot` with
  `{"kind":"slot_create","starts_at":"2026-12-01T09:00:00Z","master_user_id":null,"service_type_ids":[123]}`.
  The date and IDs are illustrative; replace them with a permitted future time
  and identifiers from the connected project. `starts_at` is required, has
  minute precision and must be in the future, at most 730 days ahead. Omit
  `slot_id`. REST retains its legacy defaults: a null/omitted master means a general
  window; an empty/omitted service list means any service. MCP requires both
  fields explicitly for creation: missing choices return `clarification_required`,
  `missing_fields` and `proposal_created:false` without saving a proposal.
  Pass `null` / `[]` only after the person explicitly chose general/any service.
  A supplied master
  must accept bookings in this project; up to 50 distinct supplied services
  must be visible and belong to it.
- Existing window: use `kind:"slot_update"`, a real `slot_id` from the calendar,
  and at least one of `starts_at`, `master_user_id`, `service_type_ids`.
  Omitted fields stay unchanged; explicit null clears the master only.
- Remove a window: send only `{"kind":"slot_delete","slot_id":456}`.
  It removes that free window, not a customer booking. Changing occupied,
  payment-held, payment-history-linked or automatically generated windows is
  refused. Slot proposals are supported only in slot mode; busy records,
  blocks, imported calendar events and recurring rules remain read-only.

These proposals never accept `project_id`, customer identity, approval flags,
SQL or arbitrary property names. IDs must come from the connected project.
Creating an opening at a time does not guarantee that every service fits;
the booking availability endpoint still applies its duration and other rules.

### Confirm the exact proposal

The result has `kind`, `id`, `status`, project/timezone, source application,
`summary.{title,resource,changes}`, expiry, `review_url` and outcome. Each summary
change contains a label, primitive before/after values, and optional
`format:"datetime"` for UTC dates. With explicit `owner:changes:apply` use the
chat application workflow above. Otherwise send the private review link to the
person. The browser shows effective values in the project timezone; the
owner/admin confirms or rejects there. Never automate that browser decision.

Read `GET /owner/change-proposals/{proposal_id}` or `get_owner_change_proposal`
using the same connection. `pending` is not applied; only `applied` means saved.
`stale`, `expired`, `invalidated` and `rejected` mean no requested change was
applied by that proposal. A changed service, window, assignment or relevant
settings require a new proposal and a fresh decision, without automatic rebase.
Proposals expire after 10 minutes and share the 20-per-connection / 100-per-project
pending limits with price proposals.

The write switch blocks creation and approval, while status reading and human
rejection remain available. During a temporary external-calendar check outage,
GET returns the immutable summary as `pending`, `can_approve:false`,
`can_reject:true`, `blocked_reason:"target_temporarily_unavailable"`.
The human can check state later or reject; the proposal is not permanently
stale. Approval returns 503 and rolls back. Do not bypass a check; wait and
reconcile known proposal status.
On `409 change_busy` (or `price_busy` for old price proposals), neither target
nor decision is changed. After a lost decision response, the human page first
reads current status before offering another attempt. Do not blindly replay
writes or announce success from an HTTP 200 alone. Revocation blocks pending
work, and only the original connection can read it as an agent.

## Native-client verification status

Native HTTP loopback registration, PKCE, exact callback binding and refresh
have automated protocol tests. Codex CLI 0.172.0 has also completed native public
registration, browser login/owner consent, PKCE code exchange and an authenticated
`get_connection` MCP call on the test deployment. This verifies that connection
and read-only diagnostic path; it does not verify every tool or the client's
automatic refresh after access-token expiry. Server refresh rotation is tested
separately. CIMD is available where advertised by discovery metadata; server
support does not establish native ChatGPT/Dots compatibility. In
ChatGPT, refresh discovery and choose CIMD to remove the unsupported-CIMD
notice; ChatGPT's general custom-server warning remains.
An authenticated `get_connection` from an existing personal ChatGPT connection
has been verified on TEST. The new native permission-upgrade → return → proposal →
apply path and client-managed refresh in ChatGPT/Dots remain unverified. Check the
full login, consent, required tools and refresh lifecycle in the intended client
and deployment before relying on a persistent connection.

## MCP protocol

Send `initialize` with protocol version `2025-06-18`, then
`notifications/initialized`, `tools/list` and `tools/call`.
Pass `Authorization: Bearer <access_token>` on authenticated requests.
Use `Content-Type: application/json` and
`Accept: application/json, text/event-stream`. No server session state is required.

`initialize` is public: HTTP 200 contains only the protocol version, public
capabilities and server information. `ping` is public and
`notifications/initialized` returns 202 without executing a tool. None grants
project access. `tools/list` and `tools/call`, including `get_connection`, require
a valid Bearer token; without one they return HTTP 401 with a `WWW-Authenticate`
challenge pointing to the protected-resource metadata. A successful handshake
does not establish that the person has connected an account. The returned
`Mcp-Session-Id` is not an authentication credential.

First read-only tool call after initialization:

```json
{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"get_connection","arguments":{}}}
```

A successful HTTP 200 does not establish tool success: inspect `result.isError`.
Use `structuredContent` when supplied. Domain tool errors can be returned as text
with `isError: true`; do not assume they always have REST's error envelope.

## Customer booking workflow

1. Confirm the customer's intended studio, service and time. Get real service/slot
   IDs from the API; never fabricate identifiers or availability.
2. For slot bookings send `service_type_id`, `slot_id`, `customer_phone`
   (`+7XXXXXXXXXX`), optional `customer_name` and `notes` to `create_booking`.
   For interval rentals send `service_type_id`, `start` and `end` instead of `slot_id`.
3. The response is `pending_verification`, including `verification_id`, masked
   phone and expiration. It sends an SMS and **does not reserve the slot yet**.
4. Ask the customer for the code they received. Never invent or guess it. Call
   `confirm_booking` with that `verification_id` and `code`.
5. Read the returned status. `confirmed` means confirmed. `awaiting_payment`
   means prepayment is still pending: respect `requires_payment` and
   `payment_pending_until`. Do not tell the customer that payment has succeeded.
   This API does not provide a payment URL; direct them to the studio's normal
   booking/account interface and check the known booking again.
6. A slot may be taken between SMS creation and confirmation. On a conflict,
   refresh availability and ask the customer to choose another time.

The person must knowingly choose the service/time and perform verification.
A write scope is not a substitute for that customer's authorization.

### Cancellation and prepayment

Default to `accept_no_refund=false`. If cancellation would keep the prepayment,
REST returns `409 refund_not_available` with `error.client_text`; MCP returns a
tool error explaining the condition. The booking has **not** been cancelled.
Show the condition and ask the customer whether to cancel without a refund.
Only after explicit agreement retry REST with `?accept_no_refund=true` or MCP with
`"accept_no_refund": true`. Never set the flag automatically or promise a refund
without an actual verified outcome.

## Time, money and service constraints

- `price_rub` is Russian rubles. `duration_hours` is hours: `1.5` = 90 minutes.
- Timestamps are ISO 8601. Preserve offsets from the response; send an explicit
  UTC `Z` or offset. Display times in the requested timezone, using the project
  timezone from `get_connection` when appropriate. Never assume Moscow for all projects.
- In interval mode, `date=YYYY-MM-DD` is a **project-local date** and
  `service_type_id` is required to get availability. Select a valid subinterval;
  server-side duration, step, working-hours and overlap checks still apply.
- `slot_service_type_ids` is the full service restriction for a slot. Empty means
  general availability. The legacy `service_type_id` is only populated for a
  single-service binding; do not treat a missing scalar as an unrestricted slot.
- Availability is a point-in-time result, not a reservation or ongoing synchronization.
- The project is derived from the validated token. Do not supply `project_id` to
  switch projects or enumerate unknown booking IDs.

## Errors and retries

REST domain error envelope: `{"error":{"code":"…","message":"…"}}` with
possible additional fields. Request validation errors may use FastAPI's `detail`
array. Check both HTTP status and machine code.

- 400 `invalid_scope`: correct the request; do not retry the same invalid scope.
- 400 `invalid_code`: ask the person for the code they received; do not guess codes.
- 400 `intent_expired`, `code_expired`, `code_locked`: the verification is no longer
  usable. Start a new intent only with the customer's agreement; stop retrying the old code.
- 401: renew an expired token once using the applicable flow. On revoked access
  or `invalid_grant`, stop and reconnect with the owner; do not loop refresh calls.
- 403: do not work around missing permissions.
- 404: check the known identifier and connected project; do not enumerate IDs.
- 409 conflict: refresh availability; `refund_not_available` requires human agreement.
- 422: correct the arguments using OpenAPI.
- 429: back off and limit attempts, especially SMS requests.
- 503 or `writes_disabled`: stop writes and retry later within a bounded policy.

REST `POST /bookings` accepts `Idempotency-Key`. Generate one unique key per
unchanged booking intent and reuse it for a sequential retry after a network
failure. Keys are not request-body-bound: never reuse one for different data.
Deduplication expires; this is not an indefinite exactly-once guarantee.
`confirm_booking` caches results by `verification_id` for a limited time.
MCP `create_booking` has no idempotency argument. Cancellation/rescheduling have
no shared idempotency-key contract. Do not blindly replay write calls after an
uncertain timeout; reconcile known status first. Serialize writes for one intent.

## Discovery and sources

- [Authentication details](https://beatybook.ru/auth.md)
- [OpenAPI JSON](https://beatybook.ru/api/agent/v1/openapi.json)
- [MCP server card](https://beatybook.ru/.well-known/mcp/server-card.json)
- [Protected resource metadata](https://beatybook.ru/.well-known/oauth-protected-resource)
- [Authorization server metadata](https://beatybook.ru/.well-known/oauth-authorization-server)
- [API catalog](https://beatybook.ru/.well-known/api-catalog)
- [Agent skills index](https://beatybook.ru/.well-known/agent-skills/index.json)
- [Booking skill](https://beatybook.ru/.well-known/agent-skills/book-appointment/SKILL.md)

For support, send the operation, HTTP/machine error code and approximate time to
support@beatybook.ru. Remove credentials, SMS codes and customer personal data.
