{
  "openapi": "3.1.1",
  "info": {
    "title": "Business Management",
    "version": "3.0.0-preview",
    "termsOfService": "https://alteg.io/en/info/terms/",
    "license": {
      "name": "Altegio API Agreement",
      "url": "/en/api-license-agreement"
    },
    "description": "> ⚠️ **Preview — this API is not live yet.** Planned release: **October 2026**. The endpoint surface is not deployed; paths and schemas may change before the contract freeze, and try-it and production calls are unavailable.\n\n> **Coming soon — October 2026.** This is a contract prototype, not a working\n> API. The [V3 Prototype Guide](quickstart.md) is for implementation planning;\n> its requests cannot be executed today.\n\n# Overview\n\nThe Business Management API V3 is Altegio's next-generation public REST API.\nThis document is a **preview of the V3 contract**: it describes the target API surface so\npartners and tooling can review it before the endpoints go live.\n\n**Preview status — please read first:**\n\n- This is a **contract preview, not a live production API**. The endpoint surface is not\n  deployed yet; try-it consoles and production calls are unavailable.\n- Paths, schemas, and field names **may change before the contract freeze** without\n  backward-compatibility guarantees.\n- Every operation carries an `x-altegio-status`. Three values are defined:\n  `planned` — designed, not scheduled for the first production release;\n  `preview` — contract published for review, not deployed;\n  `available` — live in production and covered by the October 2026 release promise.\n  **Today every operation is `preview`** — none of them is deployed yet. The October\n  release covers only operations marked `available`, so publishing the full target\n  surface here is not a promise that all of it ships at once.\n  `available` is enforced by CI in `biz.erp`: an `available` operation without a registered\n  route fails the OpenAPI conformance gate.\n- Where a design decision is still pending, the affected element also carries\n  `x-altegio-assumption` describing the open question.\n\n**Base URL (resource API):** `https://api.alteg.io/api/v3`\n\nAll resources are under `/api/v3` and scoped to a Location:\n`/api/v3/locations/{location_id}/...`. The `location_id` in the path is verified against\nthe credential used for the call — a Location the credential cannot access responds with\n`404`. OAuth and discovery endpoints live on the authorization host root\n`https://api.alteg.io` (no `/api/v3` prefix) — see the Authorization tag.\n\nMarketplace developers manage their applications under\n`/api/v3/developers/{developer_id}/marketplace_apps`, checked against membership in that\ndeveloper account. The backend of a marketplace application calls\n`/api/v3/marketplace_apps/{marketplace_app_id}/installations` with its application token.\n\n**Canonical terms.** V3 uses one public name per entity:\n\n| Term | Meaning |\n|---|---|\n| `location` | A business location (branch). |\n| `team_member` | A person on the Location's team who provides services. |\n| `service` | A bookable service offered at a Location. |\n| `client` | A person served by a Location — the person appointments are scheduled for. |\n| `appointment` | A scheduled visit entry for one Team Member. |\n| `visit` | The billing unit that groups appointments and carries items and payments. |\n\n**Response format.** V3 is flat resource REST. Single resources are plain\nJSON objects with integer `id` and a string `object` type marker. Lists use one predictable\nenvelope. V3 does **not** use JSON:API (`data.attributes`) or wrapper envelopes such as `{success,data,meta}`\nenvelopes.\n\n**Object types.** Every resource declares its kind in the `object` field — the full\ndictionary of this preview:\n\n| `object` | What it is |\n|---|---|\n| `location` | A business location and its settings. |\n| `service` / `service_category` | Catalog: a bookable service (simple or package) and its category. |\n| `team_member` / `position` | A person on the team and the position dictionary. |\n| `client` | A person served by a Location. |\n| `availability` / `availability_dates` | Free slots and the dates with free slots (computed, read-only). |\n| `resource` / `resource_instance` | Bookable resources (rooms, equipment) and their instances. |\n| `appointment` | A scheduled entry for one Team Member. |\n| `visit` / `visit_item` | The billing unit grouping appointments; its service/product lines. |\n| `payment` / `refund` | A payment applied to a visit and its local reversal. |\n| `payment_method` / `account` | Payment configuration dictionaries of the Location. |\n| `product` | A sellable product from the Location catalog (minimal P0 read). |\n| `accessible_resource` | A Location or chain grant visible on the current token. |\n| `team_member_access` | System-access status and role for a Team Member. |\n| `appointment_create_result` | Package booking result with multiple appointments. |\n| `marketplace_app` / `scope_catalog` | A marketplace application of a developer account and the scopes it may request. |\n| `publication` | The marketplace card of an application and its moderation status. |\n| `installation` / `installation_payment` | An application installed in a Location and a payment the application reported for it. |\n| `list` | The list envelope wrapping any collection response. |\n\n# Authorization\n\nV3 accepts exactly one credential shape on every call:\n\n```\nAuthorization: Bearer <token>\n```\n\nTokens are **opaque** strings — never parse or decode them. There is **no public password\ngrant**: applications never collect Altegio passwords. Three kinds of credential exist. The\nfirst two ship in the first iteration; the third is planned for the second delivery.\n\n## API key (your own scripts and agents)\n\nFor a person automating their own work — a script, a private MCP server, an agent acting\nfor them:\n\n1. Any Business User creates an **API key** in the Developer Hub: they pick the Locations\n   and chains they have access to, the scopes, a name and an expiry (required, a date at most\n   one year out, read as the end of that day in UTC). The secret `ag_key_…` is shown exactly\n   once.\n2. The key itself is the Bearer credential — there is **no token exchange**:\n   `Authorization: Bearer ag_key_…`.\n3. The key **acts on behalf of its author**. Every call checks the key's grants on the\n   target Location or chain and the author's *current* business permissions there. When the\n   author loses a permission or a Location, the key loses it too; when the author's account\n   is removed, the key stops working everywhere. Nothing is copied into the key.\n4. The author sees and revokes only their own keys; revocation takes effect on the next\n   request. To change scopes, issue a new key and revoke the old one — there is no\n   regeneration.\n\nAPI keys work only on `/api/v3` routes. Scopes that hand out access to other people\n(`team_members:manage_access`, `chain_access:manage`) and other dangerous scopes are never\navailable to an API key — they are simply absent from the portal.\n\n## Authorization Code + PKCE (user-delegated: agents, MCP hosts, applications)\n\nFor applications and agent hosts acting on behalf of a specific Business User:\n\n1. Redirect the user's browser to `GET /oauth/authorize` with `client_id`, `redirect_uri`,\n   `scope`, `state`, `resource` (RFC 8707) and a PKCE `code_challenge` (S256).\n2. The user logs in with their Altegio account.\n3. A **consent screen** shows who is asking and every Location and chain the user has access\n   to; each one lists the requested scopes that the user's own permissions there allow. There\n   is no per-Location choice: the user grants the whole set or declines.\n4. The browser is redirected back to your `redirect_uri` with a short-lived, one-time\n   authorization `code`, your `state` and `iss` — the `issuer` from the authorization server\n   metadata (RFC 9207). Compare `iss` with the `issuer` you recorded before exchanging the code.\n5. Exchange the code at `POST /oauth/token` with `grant_type=authorization_code` and the\n   PKCE `code_verifier` — the response contains an access token (valid for one hour) and a\n   **rotating refresh token** (30 days per token, 90 days per family).\n6. Refresh with `grant_type=refresh_token`. Every use rotates the refresh token; replaying\n   an already-used refresh token revokes the whole token family.\n\n`GET /oauth/authorize` is a **browser web flow** (HTML login and consent pages), not a JSON\noperation — it is documented here in prose only. The delegated token acts with the current\nbusiness permissions of the user who granted it, exactly like an API key acts with its\nauthor's. `GET /oauth/accessible-resources` returns the Locations, chains and scopes of the\ncurrent token; it answers to API keys as well.\n\nOAuth client registration: official and known integrations are pre-registered as OAuth\nclients owned by a developer account. Any other host self-onboards by one of two mechanisms,\nand the host picks one. A `client_id` given as an HTTPS URL pointing to a client metadata\ndocument (CIMD, `draft-ietf-oauth-client-id-metadata-document-02`) is the main road: the\nauthorization server fetches the document on `/oauth/authorize`, `/oauth/token` and\n`/oauth/revoke`, checks that its `client_id` equals the URL, takes `client_name` and\n`redirect_uris` from it and caches it by the HTTP cache headers. The document must be a JSON\nobject whose `client_id` equals the URL, with `client_name`, 1 to 10 `redirect_uris` and no\nclient secret; otherwise the client is treated as unknown. Dynamic Client Registration\n(`POST /oauth/register`) stands\nbeside it for hosts that have no public domain to serve a metadata document from, and for\nhosts that have not moved to CIMD yet. Discovery advertises `registration_endpoint` and\n`client_id_metadata_document_supported: true`: a client attempts the URL form only when that\nflag is present, and some hosts go straight to registration by default.\nRegistration creates an **OAuth client identity only** — it does not\ncreate a marketplace application, an installation, a business grant, or any access to data;\nthose come from user consent. A self-registered client may ask for the same scopes as any\nclient without an application: everything a consent can grant on the requested resource.\n\n**`client_id` means two different things depending on the surface** — the word `client` is\noverloaded, so this contract keeps them apart:\n\n| Surface | Entity | Identifier |\n|---|---|---|\n| Resource API (`/clients`) | the person the business serves | `client_id` of a `/clients` resource |\n| OAuth (`/oauth/*`, `/.well-known/*`) | OAuth client registration | OAuth `client_id`, e.g. `ag_client_9c41` or a CIMD URL |\n| Marketplace / Developer Hub | the developer's marketplace application | `marketplace_app_id`; its OAuth client has its own `client_id` |\n\nOAuth `client_id` is the standard field name from RFC 6749 and is not renamed; prose in the\nauthorization sections always says **OAuth client** when it means the protocol entity.\n\n## Client Credentials + `location_id` (marketplace applications) — planned\n\nFor marketplace applications acting autonomously in the Locations that installed them. This\nflow is **planned for the second delivery** and is not part of the first iteration; the\ncontract is published so application developers can prepare:\n\n1. A business installs your application in a Location and approves the scopes your\n   application requests.\n2. Your backend calls `POST /oauth/token` with `grant_type=client_credentials`, HTTP Basic\n   client authentication (`client_id` / `client_secret`), and the explicit `location_id` you\n   want to act in. One token is bound to **one** Location — an application installed in\n   twenty Locations requests twenty tokens, and there is no account-wide token.\n3. The token **acts on behalf of the installation**, within the scopes the business\n   approved at install time. Access tokens last one hour;\n   this flow has **no refresh token** — request a new access token when the current one\n   expires.\n\nAn installation token is issued only for an `active` installation. Without `location_id` the same\ncall issues an **application token**: it carries no scopes, reads no Location data and calls only\nthe routes under `/marketplace_apps/{marketplace_app_id}/installations` — installation status,\n`activate` after the business finished setup on your page, uninstall, and payment reports when you\nbill the business yourself. See the Installations tag.\n\n**Not every scope exists in every credential class.** The `scopes` list published under each\nOAuth flow is the set that flow can actually be granted. `GET /oauth/authorize` narrows a\nrequest to that set (RFC 6749 §3.3): scopes outside it are dropped, codes we do not know\n(such as `openid`) are ignored, and a request without any known scope asks for every scope\nthe `resource` can grant. Only a request whose known scopes all fall outside the set is\nrefused with `invalid_scope`. API keys use the same public catalog with the exclusions\ncalled out here:\n\n| Scope | Availability |\n|---|---|\n| The 12 first-iteration scopes | Every credential kind. |\n| Scopes marked `Planned:` in the flow lists | Listed in discovery like any other scope, except the two rows below; a token may already be issued with them and starts working when the operation ships. |\n| `locations:create` | Authorization Code only, planned. Never available to API keys: creating a Location is account-level. |\n| `team_members:manage_access`, `chain_access:manage` | Handing out access to other people stays behind the human's own login. Documented here, but granted to nobody in this iteration and left out of `scopes_supported` until moderation for verified partners exists. |\n\nScopes are added to a flow or credential class, never removed: adding one later is\nbackward-compatible, so the published lists start conservative.\n\n# Access model\n\nEvery request is resolved through the same runtime formula:\n\n```\neffective access = token scopes\n                 ∩ grants of the credential on the target Location or chain\n                 ∩ what the business allows behind that credential\n                   (an API key: its author's rights; a delegated token: the rights\n                    of the person who consented; an installation token: what the\n                    business approved for the application)\n                 ∩ tenant (Location)\n```\n\n- A **scope opens an endpoint**; the rights behind the credential then decide which rows\n  and fields are visible or writable. Having a scope does not bypass the permission system\n  of the business, and those rights can change without you: when a business admin narrows\n  them, the credential narrows with them on the next request.\n- **Location binding:** resources live under `/api/v3/locations/{location_id}/...`; the\n  `location_id` in the route is checked against the token's grants. A foreign Location returns\n  `404` — existence is not leaked.\n- **Scopes are credential-class bounded.** A credential can use only scopes allowed for its\n  kind. An API key and a user-delegated token act with the *live* permissions of the\n  author or the consenting user, read on every request with a cache of at most one minute;\n  an installation token acts with the permissions granted to the installation. Revocation\n  is never cached: a revoked token fails on the very next request.\n- **No step-up in this preview.** Dangerous operations in this preview are protected by\n  explicit scopes, the subject's business permissions, audit, and rate limits.\n  A future human-confirmation flow will be added only with a complete challenge contract.\n\n# Conventions\n\n- **Resource shape:** a flat JSON object with integer `id`, a string `object` type marker,\n  and domain fields. No envelopes, no prefixes on ids.\n- **List shape:** `{\"object\": \"list\", \"data\": [...], \"has_more\": false, \"next_cursor\": null}`.\n  Pagination is cursor-based: pass `limit` and the `next_cursor` value from the previous\n  page as `cursor`. Cursors are opaque, expire one hour after the response that issued them\n  (every page issues a fresh cursor), and only work for the credential, list, ordering and\n  filter set that produced them. Paging is stable for rows whose ordering columns do not\n  change between pages; a row whose ordering column was updated meanwhile (for example a\n  moved appointment) may be skipped or returned twice, and a row created while you page may\n  be missing from this pass if it sorts before the current position. Page/offset pagination\n  does not exist in V3.\n- **Field naming:** all JSON fields, query parameters, and path segments are `snake_case`;\n  `operationId` values are `lowerCamelCase`.\n- **Dates and times:** RFC 3339 everywhere.\n  - Audit instants (`created_at`, `updated_at`, `cancelled_at`) are UTC: `2026-07-14T09:20:31Z`.\n  - Appointment times (`starts_at`, `ends_at`) carry the Location's local UTC offset:\n    `2026-07-09T11:30:00+01:00`.\n  - Date-only values are `YYYY-MM-DD`; wall-clock times (working hours, schedule intervals)\n    are `HH:MM` in the Location's timezone.\n  - Naive datetimes and Unix timestamps never appear.\n- **Money:** integer **minor units** of the Location currency (`1250` = one thousand two hundred fifty minor units). The\n  `currency` (ISO 4217) is server-controlled, read-only, and repeated in money-carrying\n  resources. Monetary field names use the `_minor` suffix. A value that is not an integer,\n  such as `15.5` or `\"1500\"`, fails with `422` and field code `amount_not_minor_units`.\n- **Partial updates:** `PATCH` bodies are `application/merge-patch+json`. A missing field\n  means \"leave unchanged\"; `null` clears a nullable field; arrays are cleared with an\n  explicit `[]`, never `null`. Clearing a non-nullable field fails with `422\n  field_not_nullable`; changing a field the object does not allow to change (for example\n  one managed by its chain) fails with `422 field_immutable`, and so does a read-only\n  response field sent in the request. Unknown request fields are rejected with field code\n  `unknown_field`; unknown response fields must be ignored by clients.\n- **`include[]`:** relations are returned as ids by default (`client_id`,\n  `team_member_ids`). Where an operation documents relations, `include[]=<relation>` adds\n  the related object or array of objects as a new field named after the relation\n  (allowlist per endpoint, one level deep); it never changes or removes another field, so\n  the ids stay. A relation the operation does not document or a nested path, including on\n  an operation without includable relations, fails with `422 validation_failed` and an\n  `errors[]` item with code `invalid_include` for the query parameter `include[]`. Fields\n  added by `include[]` are the only response fields that can be absent; every other\n  documented field is always present, `null` when there is no value. Including never\n  bypasses field-level permissions — see PII below.\n\n# Errors\n\nEvery error from a resource operation is `application/problem+json` (RFC 9457 hybrid):\n\n| Field | Meaning |\n|---|---|\n| `type` | Stable URL identifying the problem type (links to documentation). |\n| `title` | Human-readable summary of the problem type. |\n| `status` | HTTP status code. |\n| `detail` | Human-readable explanation of this occurrence. |\n| `code` | **Stable machine-readable code** — branch on this, never on text. |\n| `errors[]` | Field-level issues: `code`, `source`, `pointer`, `message`. `pointer` is a JSON Pointer for body errors and a parameter name for query/path/header errors. |\n| `instance` | Request identifier for support and log correlation. Same value as the `X-Request-Id` header of that response, so quoting either one is enough. |\n\nThe OAuth protocol and discovery endpoints are the one exception: `POST /oauth/token`,\n`POST /oauth/revoke`, `POST /oauth/register` and `/.well-known/*` return the standard OAuth 2.0\nerror object (`{\"error\": \"…\", \"error_description\": \"…\"}`) defined by RFC 6749, 7009 and 7591 —\nnot `application/problem+json`. The `GET /oauth/authorize` browser flow reports errors on its\nown HTML page or as OAuth error parameters on the redirect (`error`, `error_description`,\n`state`, `iss`), never as JSON. `GET\n/oauth/accessible-resources` is the opposite case: despite the path it is an ordinary\nBearer-authed read and uses `application/problem+json` like the rest of the API.\n\nEverything else in this section (stable codes, field-level `errors[]`, request correlation)\ndescribes resource operations. Rate limiting is the one rule both surfaces share: every `429`\ncarries `Retry-After`.\n\nTwo conventions keep this table stable:\n\n- **Promotion.** Only public machine-readable codes that clients are expected to branch on\n  enter this table. Adding a code means editing this table and registering it in the biz.erp\n  `V3ProblemCatalog` in the same cycle — the CI conformance gate keeps both sides in sync.\n  Internal exceptions are never promoted implicitly: an unregistered code degrades to the\n  generic status default and nothing internal leaks.\n- **Naming.** `invalid_*` means the supplied value does not exist or fails validation\n  (`invalid_token`, `invalid_city`, `invalid_business_type`); `unsupported_*` means the value\n  is valid but not supported by the product or policy (`unsupported_country`,\n  `unsupported_media_type`, `unsupported_token_subject`).\n\nStable codes used by this preview (branch on these; domain codes below are equally stable):\n\n| Code | HTTP | When |\n|---|---:|---|\n| `bad_request` | 400 | Generic client reject without a more specific registered code (status default for bare 400 and unknown 4xx). Does **not** mean broken JSON. |\n| `malformed_request` | 400 | Protocol-only: broken JSON / unparseable body / wire-format syntax. Thrown explicitly — never the catch-all for every 400. |\n| `invalid_token` | 401 | Missing, malformed, expired, or revoked credential, or its user account was deleted. v1/v2 authorization (`Bearer <partner>, User <hash>`, `user_hash`) is never accepted here. |\n| `missing_scope` | 403 | The token does not carry the required scope. |\n| `permission_denied` | 403 | Scope present, but the subject lacks the business permission. |\n| `subscription_inactive` | 403 | The Location has no active license (trial or paid). Stop calling this Location and ask its owner to renew the license; retrying or another user does not help. |\n| `user_not_verified` | 403 | Location create blocked: the user account is not verified. |\n| `location_creation_forbidden` | 403 | Location create is not allowed for this subject. |\n| `unsupported_token_subject` | 403 | This credential class cannot perform the operation (e.g. installation token on `locations:create`). |\n| `resource_not_found` | 404 | Generic 404 fallback: unknown `/api/v3/*` path, gate/FF hide, or tenant policy without a safe resource-specific code. |\n| `{resource}_not_found` | 404 | Resource absent or hidden by tenant policy (e.g. `appointment_not_found`, `location_not_found`). |\n| `method_not_allowed` | 405 | HTTP method is not supported on an existing v3 route. Emitted by routing before any operation is selected, so it is deliberately not declared per operation; the body is the same `Problem` shape as every other error. The response carries `Allow` with the methods the route does accept, e.g. `Allow: GET`. |\n| `not_acceptable` | 406 | `Accept` cannot be satisfied. |\n| `conflict` | 409 | Generic 409 fallback when the domain exception has no more specific registered code. |\n| `slot_taken` | 409 | Appointment create lost the race for the requested time slot. |\n| `idempotency_key_reused` | 409 | Same `Idempotency-Key` with a different request body. |\n| `idempotency_request_in_progress` | 409 | Same key while the first request is still running (`Retry-After` included). |\n| `duplicate_location` | 409 | Location create conflicts with an existing Location. |\n| `last_location_owner` | 409 | Cannot revoke the last owner of the Location. |\n| `invitation_already_pending` | 409 | A distinct pending invitation already exists. |\n| `access_already_active` | 409 | Team Member already has active system access. |\n| `visit_already_settled` | 409 | Visit is fully paid; adding a line would leave an unpaid remainder. |\n| `stale_version` | 412 | `If-Match` did not match — the resource was changed by another writer. |\n| `unsupported_media_type` | 415 | Request `Content-Type` is not supported. |\n| `validation_failed` | 422 | Semantic field validation failed (details in `errors[]`). |\n| `phone_taken` | 422 | Client phone already belongs to another client of the Location (under `clients:write`; audited and rate-limited). |\n| `exceeds_unpaid` | 422 | Payment amount exceeds the visit's unpaid remainder. |\n| `immutable_after_finance` | 422 | Country/currency cannot change after financial data exists. |\n| `field_not_nullable` | 422 | Merge-patch tried to `null` a non-nullable field. |\n| `field_immutable` | 422 | Merge-patch sent a read-only field or changed a field this object does not allow to change (its type, a field managed by its chain, a field locked by the Location plan). |\n| `role_not_assignable` | 422 | Requested access role is not assignable in this Location. |\n| `invitation_contact_required` | 422 | Invitation delivery needs a contact and none is available. |\n| `invalid_city` | 422 | `city_id` is invalid for location create. |\n| `unsupported_country` | 422 | Country derived from city is not supported. |\n| `invalid_business_type` | 422 | `business_type_id` is invalid. |\n| `location_quota_exceeded` | 422 | Account location quota exceeded. |\n| `instrument_not_applicable` | 422 | Gift card / membership / loyalty instrument is not usable for this visit (unified; does not distinguish unknown vs wrong tenant). |\n| `precondition_required` | 428 | Required `If-Match` header is missing. |\n| `rate_limit_exceeded` | 429 | Rate limit hit (`Retry-After` included). |\n| `location_creation_rate_limited` | 429 | Location create rate limit hit. |\n| `internal_error` | 500 | Unexpected server error. |\n| `dependency_unavailable` | 503 | A required dependency is down; the write was not performed (fail closed). |\n\nField-level codes inside `errors[]` (not top-level `code`) include `expired_cursor`,\n`invalid_cursor`, `foreign_cursor`, `filter_changed`, and validation codes such as\n`missing_field`, `unknown_field`, `invalid_type`, `invalid_choice`, `invalid_value`,\n`invalid_datetime` and `amount_not_minor_units`.\n\nExample — validation failure (`422`):\n\n```json\n{\n  \"type\": \"https://developer.alteg.io/problems/validation-error\",\n  \"title\": \"Request validation failed\",\n  \"status\": 422,\n  \"detail\": \"One or more fields are invalid.\",\n  \"instance\": \"urn:altegio:request:req_abc123\",\n  \"code\": \"validation_failed\",\n  \"errors\": [\n    {\n      \"code\": \"invalid_datetime\",\n      \"source\": \"body\",\n      \"pointer\": \"/starts_at\",\n      \"message\": \"starts_at must be a valid RFC 3339 datetime.\"\n    }\n  ]\n}\n```\n\nExample — stale optimistic-concurrency version (`412`):\n\n```json\n{\n  \"type\": \"https://developer.alteg.io/problems/stale-version\",\n  \"title\": \"Resource version is stale\",\n  \"status\": 412,\n  \"detail\": \"The resource was modified after the version supplied in If-Match. Re-read it and retry.\",\n  \"instance\": \"urn:altegio:request:req_def456\",\n  \"code\": \"stale_version\"\n}\n```\n\nRetry guidance depends on the code, not on a generic flag: fix the request on `422`;\nre-read the resource on `412`; retry the same `Idempotency-Key` after `Retry-After` on\n`409 idempotency_request_in_progress`; back off on `429`/`503`; after a network timeout on\na create or command, retry **only with the same `Idempotency-Key`**.\n\n# Idempotency & concurrency\n\nBoth mechanisms below belong to the contract but are **not part of the first iteration**: no\nfirst-iteration operation requires `Idempotency-Key` or `If-Match`, and reads do not return\n`ETag` yet. They arrive together with the operations that need them (appointment creation,\npayments, concurrent appointment edits) and before contract freeze; operations that already\ncarry the headers in this document are marked `planned`.\n\n**`Idempotency-Key`** will be required on every `POST` create and command where a retry could\nduplicate a side effect (creating appointments, clients, payments; cancel/status commands).\n\n- Generate a unique key per logical request (UUID recommended).\n- A retry with the same key and the same body returns the **original result** — including\n  the case where the first attempt committed but its response was lost.\n- The same key with a different body fails with `409 idempotency_key_reused`.\n- A concurrent duplicate fails with `409 idempotency_request_in_progress` and `Retry-After`.\n- Keys are retained for **at least 24 hours**, scoped to the credential, Location (when\n  present), and operation. After expiry the same key value may start a **new** logical\n  request (it is not `idempotency_key_reused`).\n- If the idempotency store is unavailable, the write is not performed: `503\n  dependency_unavailable`.\n\n**ETag / `If-Match`** will protect mutable resources from two writers silently overwriting\neach other (for example, a human and an agent editing the same appointment):\n\n1. `GET` a mutable resource — the response carries an `ETag` header (creates and updates\n   return the fresh `ETag` too).\n2. Send `PATCH` or `DELETE` with `If-Match: <etag>`.\n3. On success the response carries the new `ETag`. If the resource changed in between, the\n   call fails with `412 stale_version` — re-read, reapply your change, retry. A missing\n   `If-Match` where it is required fails with `428 precondition_required`.\n\n# PII & redaction\n\nClient contact fields — `phone`, `additional_phone`, `email` — are sensitive:\n\n- Reading them requires the `clients:read_contact` scope **and** the corresponding business\n  permission of the token subject.\n- When access is refused, a contact field is returned as `null` and its name is listed in `redacted_fields` of the same object. It is never replaced with a mask, a placeholder or an empty string, so an integration cannot write a redacted value back.\n- A client's `surname` and `patronymic` follow the same rule when the token subject lacks the\n  business permission to see client surnames; no extra scope is involved.\n- The client card `comment` follows the same rule when the token subject lacks the business\n  permission to see client card comments; it does not depend on contact access.\n- `include[]=client` follows the same rule: including a client on an appointment or visit\n  without contact access returns the client with redacted contact fields. Including never\n  widens access.\n- **`422 phone_taken` on create/update** is part of `clients:write` (no extra\n  `clients:read_contact`). It only signals that the phone is already owned by another\n  client of this Location — it does not return that client's identity or contact payload.\n  Phone-bearing writes are audited and share an anti-enumeration rate limit with exact\n  contact search so the existence signal cannot be bulk-probed.\n\n# HTTP negotiation and caching\n\nClients should send `Accept: application/json` for successful resource responses and `application/problem+json` for errors; unsupported response media types fail with `406 not_acceptable`. JSON is UTF-8; `Content-Type` may include `charset=utf-8`. Read operations may include `Cache-Control` appropriate to the resource (`no-store` for PII-bearing reads, short `private` or `public` max-age for dictionaries and metadata). `ETag` and `If-Match` are planned (see Idempotency & concurrency); when they ship, mutable resource reads return strong ETags and `If-Match: *` is not accepted on PATCH/DELETE — clients re-read and send the concrete strong ETag.\n"
  },
  "x-altegio-status": "preview",
  "servers": [
    {
      "url": "https://api.alteg.io/api/v3",
      "description": "Preview resource API contract - endpoint surface is not live yet"
    }
  ],
  "tags": [
    {
      "name": "Authorization",
      "description": "Step 0 of every integration: obtain a Bearer credential. A person automating their own\nwork creates an API key in the Developer Hub; agents, MCP hosts and\napplications acting for a user walk the Authorization Code + PKCE browser flow; marketplace\napplications will exchange client credentials for an installation token (planned, second\ndelivery). The OAuth endpoints live outside `/api/v3` on the authorization server host.\n"
    },
    {
      "name": "Locations",
      "description": "The Location is the root of the V3 resource tree. Read it to learn derived timezone, country, currency, locale, and business settings; update only the partner-relevant allowlist."
    },
    {
      "name": "Services",
      "description": "The service catalog of a Location: services and their categories. Services define what\ncan be scheduled, for how long, and at what price; per-team-member overrides link the\ncatalog to the people who deliver it. A service must be linked to at least one bookable\nTeam Member to appear in availability.\n"
    },
    {
      "name": "Team Members",
      "description": "Team Members deliver services and own the calendars that appointments are scheduled into.\nThis section covers the Team Member directory and each member's working schedule — the\nconfigured working days that availability search is computed from.\n"
    },
    {
      "name": "Products",
      "description": "Minimal product catalog read: enough to put a product line on a visit (`id`, title, price, unit). Inventory levels, categories, cost price and product management are outside the first iteration."
    },
    {
      "name": "Positions",
      "description": "Positions are the job-title directory of the Team Member domain (for example\n\"Barber\" or \"Senior stylist\"). Create positions first, then reference them from Team\nMembers via `position_id`.\n"
    },
    {
      "name": "Clients",
      "description": "The client base of a Location. Appointments can reference an existing client, resolve an\ninline client attach-only, or be clientless. Contact fields are PII and require the\n`clients:read_contact` scope on top of `clients:read`.\n"
    },
    {
      "name": "Availability",
      "description": "Computed free appointment slots and the dates that have them. Availability is derived\nfrom Team Member schedules, existing appointments, and service durations — query it\nright before creating an appointment to offer valid start times.\n"
    },
    {
      "name": "Resources",
      "description": "Bookable resources of a Location (rooms, chairs, equipment) and their instances.\nLocations that require resources for certain services pass `resource_instance_ids`\nwhen creating appointments. Read-only in the preview scope.\n"
    },
    {
      "name": "Appointments",
      "description": "The appointment workflow: create, list, read, reschedule, cancel, and change appointment status. The appointment id is also the public key for visit/payment operations because appointments without a client can still be paid."
    },
    {
      "name": "Visits",
      "description": "A visit groups appointment billing state: line items, applicable payment methods, payments from money and loyalty sources, and the remaining `amount_to_pay_minor`."
    },
    {
      "name": "Payments",
      "description": "Money and loyalty flow for an appointment's visit: discover payment methods and accounts, search loyalty instruments, record payments, and locally reverse a payment."
    },
    {
      "name": "Apps",
      "description": "**New flow for V3 applications.** This group covers how you create a marketplace application for API V3,\npublish it and get it installed. It is not related to the marketplace endpoints in Developer Tools, which\nserve applications built for API v1. The other sections of this API are what an installed application calls\nwith its installation token.\n\nYour V3 marketplace applications in the Developer Hub: create an application, choose the scopes it\nrequests, set the webhook address and the setup page, and read its OAuth client and install link. The routes\nlive under `/developers/{developer_id}/marketplace_apps` and answer to members of that developer account. The\nOAuth client secret and the webhook secret are issued and shown only in the Developer Hub.\n"
    },
    {
      "name": "Publication",
      "description": "Part of the new flow for V3 applications, not related to the marketplace endpoints in Developer Tools.\n\nThe marketplace card of an application and its moderation. The card is created with its first save, can be\nedited at any time, and is submitted for moderation when ready. Translations of the card are edited in the\nDeveloper Hub in this preview; the logo is uploaded there and its URL is saved in `logo_url`.\n"
    },
    {
      "name": "Installations",
      "description": "Part of the new flow for V3 applications, not related to the marketplace endpoints in Developer Tools.\n\nWhat your backend calls with the application token, and the webhooks Altegio sends about installations.\n\n**Installation.** A business opens `install_url`, reviews the scopes and picks its Locations. Without\n`setup_url` the installation is `active` at once and `installation.created` is sent. With `setup_url` the\ninstallation is `pending`: the business finishes setup on your page, then your backend calls\n`POST /marketplace_apps/{marketplace_app_id}/installations/{location_id}/activate`. A `pending`\ninstallation is deleted after 12 hours. Once the installation is `active`, request an installation token\nwith `grant_type=client_credentials` and the `location_id`.\n\n**Application token.** `grant_type=client_credentials` without `location_id` issues a token for the routes\nin this section only. It carries no scopes and reads no Location data.\n\n**Webhooks.** Altegio posts installation events to `webhook_url` following\n[Standard Webhooks](https://www.standardwebhooks.com/). Verify `webhook-signature`: `v1,` followed by\nbase64 of HMAC-SHA256 over `{webhook-id}.{webhook-timestamp}.{body}`, keyed with the webhook secret from\nthe Developer Hub. Reject a `webhook-timestamp` older than 5 minutes and drop a `webhook-id` you have\nalready processed. Answer with any `2xx`; any other status or a timeout is retried for up to 24 hours with\nthe same `webhook-id`. A rotated secret takes effect at once.\n"
    }
  ],
  "x-tagGroups": [
    {
      "name": "Authorization",
      "tags": [
        "Authorization"
      ]
    },
    {
      "name": "Location Setup",
      "tags": [
        "Locations",
        "Services",
        "Products",
        "Team Members",
        "Positions"
      ]
    },
    {
      "name": "Clients",
      "tags": [
        "Clients"
      ]
    },
    {
      "name": "Scheduling",
      "tags": [
        "Availability",
        "Resources",
        "Appointments"
      ]
    },
    {
      "name": "Visits & Payments",
      "tags": [
        "Visits",
        "Payments"
      ]
    },
    {
      "name": "Integrations",
      "tags": [
        "Apps",
        "Publication",
        "Installations"
      ]
    }
  ],
  "paths": {
    "/.well-known/oauth-authorization-server": {
      "servers": [
        {
          "url": "https://api.alteg.io",
          "description": "Preview authorization server - endpoint surface is not live yet"
        }
      ],
      "get": {
        "operationId": "getOAuthAuthorizationServerMetadata",
        "summary": "Get authorization server metadata",
        "description": "Machine-readable OAuth 2.0 authorization server metadata (RFC 8414): endpoint URLs,\nsupported grant types, PKCE methods, and scopes. Agents and MCP hosts use this\ndocument to discover the authorization and token endpoints automatically.\n",
        "tags": [
          "Authorization"
        ],
        "security": [],
        "x-altegio-status": "preview",
        "responses": {
          "200": {
            "description": "Authorization server metadata.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthAuthorizationServerMetadata"
                },
                "example": {
                  "issuer": "https://api.alteg.io",
                  "authorization_endpoint": "https://api.alteg.io/oauth/authorize",
                  "token_endpoint": "https://api.alteg.io/oauth/token",
                  "revocation_endpoint": "https://api.alteg.io/oauth/revoke",
                  "registration_endpoint": "https://api.alteg.io/oauth/register",
                  "response_types_supported": [
                    "code"
                  ],
                  "grant_types_supported": [
                    "authorization_code",
                    "refresh_token"
                  ],
                  "code_challenge_methods_supported": [
                    "S256"
                  ],
                  "token_endpoint_auth_methods_supported": [
                    "client_secret_basic",
                    "client_secret_post",
                    "none"
                  ],
                  "authorization_response_iss_parameter_supported": true,
                  "client_id_metadata_document_supported": true,
                  "scopes_supported": [
                    "analytics:read",
                    "analytics:write",
                    "appointments:create",
                    "appointments:read",
                    "appointments:write",
                    "audit:read",
                    "availability:read",
                    "checkout:cancel",
                    "checkout:capture",
                    "checkout:read",
                    "checkout:refund",
                    "client_accounts:read",
                    "client_accounts:write",
                    "clients:read",
                    "clients:read_contact",
                    "clients:write",
                    "finance:read",
                    "finance:write",
                    "events:read",
                    "events:write",
                    "fiscalization:configure",
                    "fiscalization:operate",
                    "fiscalization:read",
                    "inventory:operate",
                    "inventory:read",
                    "inventory:sell",
                    "locations:read",
                    "locations:write",
                    "loyalty:issue",
                    "loyalty:read",
                    "loyalty:transact",
                    "notifications:configure",
                    "notifications:read",
                    "notifications:send",
                    "online_booking:configure",
                    "online_booking:read",
                    "payment_policies:apply",
                    "payment_policies:configure",
                    "payment_policies:read",
                    "payroll:adjust",
                    "payroll:configure",
                    "payroll:pay",
                    "payroll:read",
                    "products:read",
                    "products:write",
                    "reviews:manage",
                    "reviews:read",
                    "services:read",
                    "services:write",
                    "team_members:read",
                    "team_members:schedule",
                    "team_members:write",
                    "webhooks:manage",
                    "chain_analytics:read",
                    "chain_client_accounts:configure",
                    "chain_client_accounts:read",
                    "chain_clients:read",
                    "chain_clients:read_contact",
                    "chain_custom_fields:configure",
                    "chain_loyalty:configure",
                    "chain_loyalty:read",
                    "chain_loyalty:transact",
                    "chain_payroll:read",
                    "chain_products:read",
                    "chain_products:write",
                    "chain_services:read",
                    "chain_services:write",
                    "chain_structure:manage",
                    "chain_team_members:read",
                    "chain_team_members:write"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              },
              "Cache-Control": {
                "description": "Public metadata may be cached briefly; clients should revalidate before long-lived use.",
                "schema": {
                  "type": "string"
                },
                "example": "public, max-age=3600"
              }
            }
          },
          "400": {
            "description": "Invalid metadata request (OAuth error object).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                }
              }
            }
          },
          "404": {
            "description": "Metadata document is not available."
          },
          "429": {
            "description": "Too many metadata requests from this address. Discovery is cacheable — honour\n`Cache-Control` instead of polling. Retry after the interval in `Retry-After`.\n",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                },
                "example": 60
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                },
                "example": {
                  "error": "temporarily_unavailable",
                  "error_description": "Metadata request rate limit exceeded. Retry later."
                }
              }
            }
          },
          "500": {
            "description": "Metadata document cannot be generated (OAuth error object).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                }
              }
            }
          },
          "503": {
            "description": "Authorization metadata dependency is unavailable (OAuth error object).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                }
              }
            }
          }
        }
      }
    },
    "/.well-known/oauth-protected-resource/api/v3": {
      "servers": [
        {
          "url": "https://api.alteg.io",
          "description": "Preview authorization server - endpoint surface is not live yet"
        }
      ],
      "get": {
        "operationId": "getOAuthProtectedResourceMetadata",
        "summary": "Get protected resource metadata",
        "description": "OAuth 2.0 protected resource metadata (RFC 9728) of API V3: the resource identifier,\nthe authorization server that issues tokens for it, and the scopes it accepts. The\npath follows RFC 9728 §3.1: the well-known suffix is inserted between the host and\nthe path of the resource identifier `https://api.alteg.io/api/v3`. A `401` from\n`/api/v3` points here in `WWW-Authenticate: Bearer resource_metadata=\"...\"`.\n",
        "tags": [
          "Authorization"
        ],
        "security": [],
        "x-altegio-status": "preview",
        "responses": {
          "200": {
            "description": "Protected resource metadata.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthProtectedResourceMetadata"
                },
                "example": {
                  "resource": "https://api.alteg.io/api/v3",
                  "authorization_servers": [
                    "https://api.alteg.io"
                  ],
                  "bearer_methods_supported": [
                    "header"
                  ],
                  "scopes_supported": [
                    "appointments:read",
                    "clients:read"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              },
              "Cache-Control": {
                "description": "Public metadata may be cached briefly; clients should revalidate before long-lived use.",
                "schema": {
                  "type": "string"
                },
                "example": "public, max-age=3600"
              }
            }
          },
          "429": {
            "description": "Too many metadata requests from this address. Metadata is cacheable — honour\n`Cache-Control` instead of polling. Retry after the interval in `Retry-After`.\n",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                },
                "example": 60
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                },
                "example": {
                  "error": "temporarily_unavailable",
                  "error_description": "Rate limit exceeded. Retry later."
                }
              }
            }
          },
          "500": {
            "description": "Metadata document cannot be generated (OAuth error object).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                }
              }
            }
          }
        }
      }
    },
    "/oauth/token": {
      "servers": [
        {
          "url": "https://api.alteg.io",
          "description": "Preview authorization server - endpoint surface is not live yet"
        }
      ],
      "post": {
        "operationId": "createOAuthToken",
        "summary": "Issue an access token",
        "description": "OAuth 2.0 token endpoint (RFC 6749). Supports three grants:\n\n- `authorization_code` — exchange a code obtained from the browser\n  `GET /oauth/authorize` flow (PKCE `code_verifier` required). Returns an access\n  token and a rotating refresh token.\n- `client_credentials` — machine-to-machine token for a marketplace application. With\n  `location_id` it is an installation token: the installation is resolved from the\n  authenticated OAuth client plus that Location and must be `active`. Without\n  `location_id` it is an application token: no scopes, only the application's own\n  `/marketplace_apps/{marketplace_app_id}/installations` routes. No refresh token is\n  returned.\n- `refresh_token` — rotate a refresh token from the Authorization Code flow.\n  The previous refresh token is invalidated; replaying it revokes the token family.\n  The new access token never exceeds the scopes of the original consent: `scope` may\n  narrow it, unknown codes are ignored, and `invalid_scope` is returned when every known\n  scope in `scope` is outside the consent (the refresh token is not rotated then). The\n  same rule applies to `scope` on the code exchange. A refresh token lives 30 days from\n  its issue, the family 90 days from the code exchange; after that the user approves\n  access again.\n\nConfidential clients authenticate with HTTP Basic (`client_secret_basic`) or send\n`client_id` and `client_secret` in the form body (`client_secret_post`); public clients\n(PKCE-only) send their `client_id` in the form body. There is **no password grant**.\n\nErrors from this endpoint use the standard OAuth 2.0 error object\n(`{\"error\": \"...\", \"error_description\": \"...\"}`), not `application/problem+json`.\n",
        "tags": [
          "Authorization"
        ],
        "security": [],
        "x-altegio-status": "preview",
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/OAuthTokenRequest"
              },
              "examples": {
                "clientCredentials": {
                  "summary": "Marketplace M2M token for one Location",
                  "value": {
                    "grant_type": "client_credentials",
                    "location_id": 90211,
                    "scope": "appointments:read appointments:create clients:read"
                  }
                },
                "applicationToken": {
                  "summary": "Marketplace application token, no Location",
                  "value": {
                    "grant_type": "client_credentials"
                  }
                },
                "authorizationCode": {
                  "summary": "Exchange an authorization code (PKCE)",
                  "value": {
                    "grant_type": "authorization_code",
                    "code": "SplxlOBeZQQYbYS6WxSbIA",
                    "redirect_uri": "https://partner.example.com/oauth/callback",
                    "client_id": "ag_client_2f6d9c41e0",
                    "code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"
                  }
                },
                "refreshToken": {
                  "summary": "Rotate a refresh token",
                  "value": {
                    "grant_type": "refresh_token",
                    "refresh_token": "ag_rt_5b8e2d4f68a1c9e0b2d4f68a",
                    "client_id": "ag_client_2f6d9c41e0"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Token issued.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthTokenResponse"
                },
                "example": {
                  "access_token": "ag_at_7f3a1c9e0b2d4f68a1c9e0b2",
                  "token_type": "Bearer",
                  "expires_in": 3600,
                  "refresh_token": "ag_rt_5b8e2d4f68a1c9e0b2d4f68a",
                  "scope": "appointments:read appointments:create clients:read"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request or grant (RFC 6749 error object).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                },
                "example": {
                  "error": "invalid_grant",
                  "error_description": "Authorization code is expired or already used."
                }
              }
            }
          },
          "401": {
            "description": "Client authentication failed (RFC 6749 error object).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                },
                "example": {
                  "error": "invalid_client",
                  "error_description": "Unknown client or invalid client credentials."
                }
              }
            }
          },
          "429": {
            "description": "Too many token requests for this client, subject or address. Failed grant attempts\ncount against the same budget. Retry after the interval in `Retry-After`; do not\nretry a rejected `authorization_code` — start a new authorization.\n",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                },
                "example": 60
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                },
                "example": {
                  "error": "temporarily_unavailable",
                  "error_description": "Token request rate limit exceeded. Retry later."
                }
              }
            }
          },
          "500": {
            "description": "Token could not be issued because of an unexpected server error (OAuth error object).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                },
                "example": {
                  "error": "server_error",
                  "error_description": "Token could not be issued. Retry later."
                }
              }
            }
          },
          "503": {
            "description": "An authorization dependency is unavailable (OAuth error object). Back off and retry;\nalready-issued access tokens keep working until they expire.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                },
                "example": {
                  "error": "temporarily_unavailable",
                  "error_description": "Authorization server dependency is unavailable. Retry later."
                }
              }
            }
          }
        }
      }
    },
    "/oauth/revoke": {
      "servers": [
        {
          "url": "https://api.alteg.io",
          "description": "Preview authorization server - endpoint surface is not live yet"
        }
      ],
      "post": {
        "operationId": "revokeOAuthToken",
        "summary": "Revoke a token",
        "description": "OAuth 2.0 token revocation (RFC 7009). Revokes an access token or a refresh token;\nrevoking a refresh token revokes its whole token family. The endpoint returns `200`\neven when the token is already invalid, as required by the RFC.\n\nConfidential clients authenticate with HTTP Basic (`client_secret_basic`); public\nclients send their `client_id` in the form body. A client revokes only its own tokens:\na token of another client is left untouched and still answers `200`.\n",
        "tags": [
          "Authorization"
        ],
        "security": [],
        "x-altegio-status": "preview",
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/OAuthRevokeRequest"
              },
              "example": {
                "token": "ag_rt_5b8e2d4f68a1c9e0b2d4f68a",
                "client_id": "ag_client_9079b3b06d7d9535"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The token has been revoked (or was already invalid)."
          },
          "400": {
            "description": "The `token` parameter is missing (RFC 6749 error object).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                },
                "example": {
                  "error": "invalid_request",
                  "error_description": "The token parameter is required."
                }
              }
            }
          },
          "401": {
            "description": "Client authentication failed (RFC 6749 error object).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                },
                "example": {
                  "error": "invalid_client",
                  "error_description": "Unknown client or invalid client credentials."
                }
              }
            }
          },
          "429": {
            "description": "Too many revocation requests for this client or address. Retry after the interval in\n`Retry-After`; a `429` does not mean the token survived — re-send the same request.\n",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                },
                "example": 60
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                },
                "example": {
                  "error": "temporarily_unavailable",
                  "error_description": "Revocation rate limit exceeded. Retry later."
                }
              }
            }
          },
          "500": {
            "description": "Revocation could not be completed because of an unexpected server error (OAuth error\nobject). The token may still be valid — retry until the endpoint returns `200`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                },
                "example": {
                  "error": "server_error",
                  "error_description": "Revocation could not be completed. Retry later."
                }
              }
            }
          },
          "503": {
            "description": "A revocation dependency is unavailable (OAuth error object). The token may still be\nvalid — back off and retry until the endpoint returns `200`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                },
                "example": {
                  "error": "temporarily_unavailable",
                  "error_description": "Revocation dependency is unavailable. Retry later."
                }
              }
            }
          }
        }
      }
    },
    "/oauth/register": {
      "servers": [
        {
          "url": "https://api.alteg.io",
          "description": "Preview authorization server - endpoint surface is not live yet"
        }
      ],
      "post": {
        "operationId": "registerOAuthClient",
        "summary": "Register an OAuth client (DCR)",
        "description": "Minimal Dynamic Client Registration (RFC 7591) for MCP hosts and other clients that\nare not pre-registered. Registration only issues a `client_id` — access to any data\nstill requires the user login/consent flow and granted scopes.\n\nThe body must be `application/json` (RFC 7591 §3.1): a body of any other type is read as\nempty and answered with `invalid_client_metadata`.\n\nEvery registered client is **public**: it receives **no `client_secret`**, the response\nalways says `token_endpoint_auth_method: none` whatever was requested, and the client\nmust use Authorization Code + PKCE. Only `client_name` and `redirect_uris` are kept;\nother RFC 7591 metadata is accepted and ignored. Redirect URIs that are neither absolute\nHTTPS nor loopback (for example a custom scheme) are dropped from the registration, and\nthe request fails only when none is left. Every registration creates a new client with a\nnew `client_id`; a client that receives no consent within a day of registration is\ndeleted.\n\nA `client_id` supplied as an HTTPS URL pointing to a Client ID Metadata Document\n(CIMD) is accepted at the authorization, token and revocation endpoints without prior\nregistration.\n\nRegistration is rate-limited.\n",
        "tags": [
          "Authorization"
        ],
        "security": [],
        "x-altegio-status": "preview",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OAuthClientRegistrationRequest"
              },
              "example": {
                "client_name": "Example MCP Host",
                "redirect_uris": [
                  "https://mcp-host.example.com/oauth/callback",
                  "http://127.0.0.1/callback"
                ],
                "grant_types": [
                  "authorization_code",
                  "refresh_token"
                ],
                "token_endpoint_auth_method": "none"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Client registered.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthClientRegistrationResponse"
                },
                "example": {
                  "client_id": "ag_client_9c41a7d3b2",
                  "client_id_issued_at": 1784900000,
                  "client_name": "Example MCP Host",
                  "redirect_uris": [
                    "https://mcp-host.example.com/oauth/callback",
                    "http://127.0.0.1/callback"
                  ],
                  "grant_types": [
                    "authorization_code",
                    "refresh_token"
                  ],
                  "token_endpoint_auth_method": "none"
                }
              }
            }
          },
          "400": {
            "description": "Invalid client metadata (RFC 7591 error object).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                },
                "example": {
                  "error": "invalid_redirect_uri",
                  "error_description": "redirect_uris must be absolute HTTPS URLs or RFC 8252 loopback addresses."
                }
              }
            }
          },
          "429": {
            "description": "Too many registration attempts. Retry after the interval in `Retry-After`.\n",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                },
                "example": 60
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                },
                "example": {
                  "error": "temporarily_unavailable",
                  "error_description": "Rate limit exceeded. Retry later."
                }
              }
            }
          },
          "500": {
            "description": "Client could not be registered because of an unexpected server error (OAuth error object).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                },
                "example": {
                  "error": "server_error",
                  "error_description": "The request could not be completed. Retry later."
                }
              }
            }
          },
          "503": {
            "description": "Dynamic client registration is temporarily unavailable (OAuth error object).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                },
                "example": {
                  "error": "temporarily_unavailable",
                  "error_description": "Dynamic client registration is disabled."
                }
              }
            }
          }
        }
      }
    },
    "/oauth/accessible-resources": {
      "servers": [
        {
          "url": "https://api.alteg.io",
          "description": "Preview authorization server - endpoint surface is not live yet"
        }
      ],
      "get": {
        "operationId": "listAccessibleResources",
        "summary": "List the resources the current token can access",
        "description": "Returns the resources **this token** is actually granted — not everything the user or\napplication could reach. Each entry carries the scopes granted on that resource, so a\nclient knows which `location_id` to use in a path and which chain-level calls it may make.\n\nA consent may grant several resources at once; each becomes an independent entry that can be\nrevoked on its own. A `chain` entry does not imply its locations: chain grants and\nlocation grants are separate, and a new location added to a chain later is not covered\nautomatically.",
        "tags": [
          "Authorization"
        ],
        "security": [
          {
            "OAuth2": []
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "responses": {
          "200": {
            "description": "Resources accessible with the current token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccessibleResourceList"
                },
                "examples": {
                  "oneChainTwoLocations": {
                    "summary": "A chain grant plus two location grants",
                    "value": {
                      "object": "list",
                      "data": [
                        {
                          "object": "accessible_resource",
                          "type": "chain",
                          "id": 42,
                          "name": "Lumière",
                          "main_chain_id": null,
                          "scopes": [
                            "chain_services:read"
                          ]
                        },
                        {
                          "object": "accessible_resource",
                          "type": "location",
                          "id": 10,
                          "name": "Lumière Centre",
                          "main_chain_id": 42,
                          "scopes": [
                            "appointments:read",
                            "appointments:create"
                          ]
                        },
                        {
                          "object": "accessible_resource",
                          "type": "location",
                          "id": 11,
                          "name": "Lumière Riverside",
                          "main_chain_id": 42,
                          "scopes": [
                            "appointments:read"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              },
              "Cache-Control": {
                "description": "Grants change independently of the token; do not cache beyond the token lifetime.",
                "schema": {
                  "type": "string"
                },
                "example": "no-store"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/me": {
      "get": {
        "operationId": "getMe",
        "summary": "Get the current user",
        "description": "Returns the Altegio user the token or API key acts for: the person who gave the OAuth\nconsent, or the author of the API key. Needs no scope and no location: a token or key\nissued before this operation existed can call it too, for example to tell its users apart.\n\nA person must be behind the credential: the technical user of a marketplace application\ngets `403 permission_denied`. An installation credential is refused with `401 invalid_token`.\n\nOnly `id` for now. Personal fields (name, email, phone) will come with their own field\nscope; without it such a field is `null` and listed in `redacted_fields`.",
        "tags": [
          "Authorization"
        ],
        "security": [
          {
            "OAuth2": []
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "responses": {
          "200": {
            "description": "The user behind the credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/User"
                },
                "example": {
                  "id": 1045,
                  "object": "user"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              },
              "Cache-Control": {
                "description": "The answer belongs to this credential; do not cache it.",
                "schema": {
                  "type": "string"
                },
                "example": "no-store"
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/reference/cities": {
      "get": {
        "operationId": "listCities",
        "summary": "List cities",
        "description": "Cursor-paginated list. Default ordering: country_id, name, id tie-breaker. Cursors use the `cursor` query parameter, expire after one hour, and are bound to the credential, tenant, list, and filters. Expired, malformed, foreign, or re-filtered cursors fail with `422 validation_failed` using field codes `expired_cursor`, `invalid_cursor`, `foreign_cursor`, or `filter_changed`.",
        "tags": [
          "Locations"
        ],
        "security": [
          {
            "OAuth2": []
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "planned",
        "parameters": [
          {
            "$ref": "#/components/parameters/CountryId"
          },
          {
            "$ref": "#/components/parameters/Query"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CityList"
                }
              }
            },
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "412": {
            "$ref": "#/components/responses/PreconditionFailed"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "428": {
            "$ref": "#/components/responses/PreconditionRequired"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/reference/business_types": {
      "get": {
        "operationId": "listBusinessTypes",
        "summary": "List business types",
        "description": "Cursor-paginated list. Default ordering: title, id tie-breaker. Cursors use the `cursor` query parameter, expire after one hour, and are bound to the credential, tenant, list, and filters. Expired, malformed, foreign, or re-filtered cursors fail with `422 validation_failed` using field codes `expired_cursor`, `invalid_cursor`, `foreign_cursor`, or `filter_changed`.",
        "tags": [
          "Locations"
        ],
        "security": [
          {
            "OAuth2": []
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "planned",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BusinessTypeList"
                }
              }
            },
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "412": {
            "$ref": "#/components/responses/PreconditionFailed"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "428": {
            "$ref": "#/components/responses/PreconditionRequired"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations": {
      "post": {
        "operationId": "createLocation",
        "summary": "Create a location",
        "description": "Creates a standalone Location for the current authenticated user.\n\nAuthorization is user-delegated only (Authorization Code + PKCE); installation\ntokens and API keys are rejected. `country_code`,\n`timezone`, and `currency` are derived from `city_id` and are not writable.\n\nThe `201` response carries `provisioning_status`: `ready` means base accounts and\npayment methods already exist, `pending` means defaults are still being provisioned.\nRequires `Idempotency-Key`.\n\nErrors: `403 user_not_verified` / `location_creation_forbidden` /\n`unsupported_token_subject`; `409 duplicate_location`; `422 invalid_city` /\n`unsupported_country` / `invalid_business_type` / `location_quota_exceeded`;\n`429 location_creation_rate_limited`.\n",
        "tags": [
          "Locations"
        ],
        "security": [
          {
            "OAuth2": [
              "locations:create"
            ]
          }
        ],
        "x-altegio-status": "planned",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LocationCreate"
              },
              "example": {
                "name": "Lisbon Center",
                "city_id": 6201,
                "business_type_id": 1,
                "language": "en-PT",
                "datetime_format": "EU"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "Location": {
                "$ref": "#/components/headers/Location"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LocationCreated"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "412": {
            "$ref": "#/components/responses/PreconditionFailed"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "428": {
            "$ref": "#/components/responses/PreconditionRequired"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        }
      ],
      "get": {
        "operationId": "getLocation",
        "summary": "Get a location",
        "description": "Returns the Location resource: name, address, contacts, timezone, and\ncurrency.\n",
        "tags": [
          "Locations"
        ],
        "security": [
          {
            "OAuth2": [
              "locations:read"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "responses": {
          "200": {
            "description": "The Location.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Location"
                },
                "examples": {
                  "location": {
                    "$ref": "#/components/examples/LocationExample"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      },
      "patch": {
        "operationId": "updateLocation",
        "summary": "Update a location",
        "description": "Partially updates partner-relevant Location settings with a merge-patch body.\n\n`timezone`, `country`, and `currency` are read-only and intentionally absent from the\nupdate schema — they follow `city_id`. Changing `city_id` to a city that would alter the\ncountry or currency is rejected with `422 immutable_after_finance` once financial data\nexists for the Location; before that the move is allowed and the derived values follow.\n",
        "tags": [
          "Locations"
        ],
        "security": [
          {
            "OAuth2": [
              "locations:write"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "requestBody": {
          "required": true,
          "content": {
            "application/merge-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/LocationUpdate"
              },
              "example": {
                "name": "Lisbon Center",
                "phones": [
                  "+351210000000"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated Location.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Location"
                },
                "examples": {
                  "location": {
                    "$ref": "#/components/examples/LocationExample"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}/services": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        }
      ],
      "get": {
        "operationId": "listServices",
        "summary": "List services",
        "description": "Returns the services of the Location as a cursor-paginated list. Prices are integer\nminor units; `duration_seconds` is the default duration, and `team_members[]` lists the\nTeam Members providing the service by id.\n\n\nCursor-paginated list. Default ordering: `id` ascending. Cursors use the `cursor` query parameter, expire after one hour, and are bound to the credential, tenant, list, and filters. Expired, malformed, foreign, or re-filtered cursors fail with `422 validation_failed` using field codes `expired_cursor`, `invalid_cursor`, `foreign_cursor`, or `filter_changed`.",
        "tags": [
          "Services"
        ],
        "security": [
          {
            "OAuth2": [
              "services:read"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of services.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "id": 100,
                      "object": "service",
                      "type": "simple",
                      "name": "Men's haircut",
                      "online_booking_name": "Haircut for men",
                      "online_booking_description": "Wash, cut and styling.",
                      "category_id": 205,
                      "chain_id": null,
                      "duration_seconds": 3600,
                      "weight": 2,
                      "currency": "EUR",
                      "online_booking_enabled": true,
                      "team_member_ids": [
                        321,
                        322
                      ],
                      "package": null,
                      "created_at": "2026-07-01T08:00:00Z",
                      "price_min_minor": 250000,
                      "price_max_minor": 300000
                    },
                    {
                      "id": 200,
                      "object": "service",
                      "type": "package",
                      "package": {
                        "exec_order": "sequential",
                        "pricing_type": "sum",
                        "price_discount_percent": 10,
                        "status": "ready",
                        "components": [
                          {
                            "id": 77,
                            "service_id": 1501,
                            "position": 1
                          },
                          {
                            "id": 78,
                            "service_id": 1502,
                            "position": 2
                          }
                        ]
                      },
                      "name": "Spa day",
                      "online_booking_name": "Spa day",
                      "online_booking_description": null,
                      "category_id": 205,
                      "chain_id": null,
                      "duration_seconds": 7200,
                      "weight": 1,
                      "currency": "EUR",
                      "online_booking_enabled": true,
                      "team_member_ids": [
                        321
                      ],
                      "created_at": "2026-07-01T08:00:00Z",
                      "price_min_minor": 500000,
                      "price_max_minor": 500000
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null
                }
              }
            },
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      },
      "post": {
        "operationId": "createService",
        "summary": "Create a service",
        "description": "Creates a service in the Location catalog: a simple service (`type: simple`) or a\npackage of simple services (`type: package` with a `package` block). The response is\nthe new service as `getService` returns it; the `Location` header holds its URL.\n\n- **Team Members.** A simple service is created without Team Members: link them through\n  `updateTeamMemberServices`, since a service without a bookable Team Member link does\n  not appear in availability search. A package is linked to every Team Member who\n  provides at least one of its components.\n- **Names.** A link in `name` or `online_booking_name` fails with `422` at the field:\n  Altegio would cut it out of the name. A link is a URL or any `word.word` without a\n  space, such as `Dr.Lash`. Without `online_booking_name`, or with `null`,\n  the service shows `name` in online booking. Characters outside the Basic\n  Multilingual Plane (emoji and other 4-byte UTF-8 characters) in `name`,\n  `online_booking_name` and `online_booking_description` fail with `422` at the field.\n- **Prices.** Integer minor units of the Location currency. Omit `price_max_minor` for a\n  single price, send `null` for a \"from X\" price without an upper bound, or send\n  `price_min_minor: 0` with `price_max_minor` for an \"up to Y\" price. Altegio stores\n  two decimals: in a currency with three, an amount that is not a multiple of 10 fails\n  with `422` and field code `invalid_value`. An amount above what Altegio can\n  store fails with `422`.\n- **Packages.** Altegio computes the package duration from its components (`parallel`:\n  the longest component, otherwise the sum) and, unless `pricing_type` is `manual`,\n  the package price.\n- A new service gets `weight` `0`, like one created in Altegio, so it is listed after\n  the services the business has ordered. It is never a group-event service.\n  Permissions on single fields are not checked on creation. When the plan of the\n  Location does not allow switching online booking of services, `online_booking_enabled`\n  must be `false`: `true`, or an omitted field, fails with `422` and field code\n  `invalid_value`.\n\nA `category_id` or component `service_id` that is not listed in this Location fails\nwith the same `422 validation_failed` at its pointer, whether it belongs to another\nLocation, is deleted, or does not exist; a chain category (`chain_id` set) fails the same way. The\nbody must be a JSON object sent as\n`application/json`: another media type fails with `415 unsupported_media_type`,\nbroken JSON or a body that is not an object with `400 malformed_request`.\n",
        "tags": [
          "Services"
        ],
        "security": [
          {
            "OAuth2": [
              "services:write"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ServiceCreate"
              },
              "examples": {
                "simple": {
                  "summary": "simple",
                  "value": {
                    "type": "simple",
                    "name": "Men's haircut",
                    "online_booking_name": "Haircut for men",
                    "online_booking_description": "Wash, cut and styling.",
                    "category_id": 205,
                    "duration_seconds": 3600,
                    "price_min_minor": 250000,
                    "price_max_minor": 300000
                  }
                },
                "package": {
                  "summary": "package",
                  "value": {
                    "type": "package",
                    "name": "Spa day",
                    "category_id": 205,
                    "package": {
                      "exec_order": "sequential",
                      "pricing_type": "discount",
                      "price_discount_percent": 10,
                      "components": [
                        {
                          "service_id": 1501
                        },
                        {
                          "service_id": 1502
                        }
                      ]
                    }
                  }
                },
                "package_manual": {
                  "summary": "package with a manual price",
                  "value": {
                    "type": "package",
                    "name": "Spa weekend",
                    "category_id": 205,
                    "package": {
                      "exec_order": "parallel",
                      "pricing_type": "manual",
                      "components": [
                        {
                          "service_id": 1501
                        },
                        {
                          "service_id": 1502
                        },
                        {
                          "service_id": 1501
                        }
                      ]
                    },
                    "price_min_minor": 900000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The created service. `Location` holds its URL, `/api/v3/locations/{location_id}/services/{id}`.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "Location": {
                "$ref": "#/components/headers/Location"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Service"
                },
                "examples": {
                  "service": {
                    "summary": "A created service",
                    "value": {
                      "id": 101,
                      "object": "service",
                      "type": "simple",
                      "name": "Men's haircut",
                      "online_booking_name": "Haircut for men",
                      "online_booking_description": "Wash, cut and styling.",
                      "category_id": 205,
                      "chain_id": null,
                      "duration_seconds": 3600,
                      "weight": 0,
                      "currency": "EUR",
                      "online_booking_enabled": true,
                      "team_member_ids": [],
                      "package": null,
                      "created_at": "2026-11-03T08:00:00Z",
                      "price_min_minor": 250000,
                      "price_max_minor": 300000
                    }
                  },
                  "package": {
                    "summary": "A created service package",
                    "value": {
                      "id": 201,
                      "object": "service",
                      "type": "package",
                      "package": {
                        "exec_order": "sequential",
                        "pricing_type": "discount",
                        "price_discount_percent": 10,
                        "status": "ready",
                        "components": [
                          {
                            "id": 79,
                            "service_id": 1501,
                            "position": 1
                          },
                          {
                            "id": 80,
                            "service_id": 1502,
                            "position": 2
                          }
                        ]
                      },
                      "name": "Spa day",
                      "online_booking_name": "Spa day",
                      "online_booking_description": null,
                      "category_id": 205,
                      "chain_id": null,
                      "duration_seconds": 7200,
                      "weight": 0,
                      "currency": "EUR",
                      "online_booking_enabled": true,
                      "team_member_ids": [
                        321
                      ],
                      "created_at": "2026-11-03T08:00:00Z",
                      "price_min_minor": 450000,
                      "price_max_minor": 450000
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}/services/{service_id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        },
        {
          "$ref": "#/components/parameters/ServiceId"
        }
      ],
      "get": {
        "operationId": "getService",
        "summary": "Get a service",
        "description": "Returns a single service with its category, pricing, duration, Team Member ids, and\npackage components when `type` is `package`. With `include[]=team_members` the response\nalso carries `team_members`: the duration, price and online booking setting of each\nTeam Member for the service.\n",
        "tags": [
          "Services"
        ],
        "security": [
          {
            "OAuth2": [
              "services:read"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "parameters": [
          {
            "$ref": "#/components/parameters/IncludeService"
          }
        ],
        "responses": {
          "200": {
            "description": "The service.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Service"
                },
                "examples": {
                  "service": {
                    "$ref": "#/components/examples/ServiceExample"
                  },
                  "package": {
                    "$ref": "#/components/examples/ServicePackageExample"
                  },
                  "included_team_members": {
                    "$ref": "#/components/examples/ServiceIncludedTeamMembersExample"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      },
      "patch": {
        "operationId": "updateService",
        "summary": "Update a service",
        "description": "Partially updates a service with a merge-patch body (RFC 7396); `application/json` is\naccepted with the same semantics. A missing field is left unchanged, so `{}` changes\nnothing. `null` clears `online_booking_name` (online booking shows `name` again),\n`online_booking_description`, and `price_max_minor` (a \"from X\" price); `null` on any other field fails\nwith `422 field_not_nullable`. Team Member links are written through\n`updateTeamMemberServices`; only a package change also relinks them (see **Packages**).\n\n- **Prices.** When `price_min_minor` comes without `price_max_minor`, a stored single\n  price stays single (the maximum follows the new minimum), a stored range keeps its\n  maximum (a new minimum above it fails with `422`), and a stored \"from X\" price stays\n  \"from\". The money rules of `createService` apply.\n- **Packages.** `package` is merged field by field (`ServicePackageUpdate`), and\n  `package.components` replaces the whole list. After a change of `package` or of the\n  package price, Altegio recalculates the duration, the status and, for `sum` or\n  `discount` pricing, the price from the current components. It also links the package\n  to every Team Member who provides at least one component, as on creation, and unlinks\n  the other Team Members when the token subject may edit Team Member services and\n  durations. The pricing rules of `createService` apply to the resulting package.\n  `duration_seconds` of a package is computed from its components and fails with\n  `422 field_immutable`.\n- **Online booking.** Changing `online_booking_enabled` switches online booking for every\n  Team Member link of the service. When the plan of the Location does not allow switching\n  online booking of services, a change fails with `422 field_immutable`; the stored value\n  passes. An `online_booking_name` equal to `name` changes nothing while the service\n  has no own online name: online booking keeps following `name`. When the service has\n  an own online name, the sent value becomes the new own name even if it equals `name`;\n  send `null` to make online booking follow `name` again.\n- **Duration.** A new `duration_seconds` also becomes the duration of the Team Member\n  links of the service when they all had the same duration and the token subject may\n  edit Team Member services and durations, as in Altegio.\n- **Unlisted category.** When the stored category is not listed in the Location\n  (`category_id` reads `null`), a request without `category_id` keeps that category.\n- **Field permissions.** Changing a field the token subject may not change in Altegio\n  fails with `403 permission_denied` and an `errors[]` item per field: `name` and\n  `online_booking_name`; `category_id`; `price_min_minor`, `price_max_minor`,\n  `package.pricing_type` and `package.price_discount_percent`; `online_booking_enabled`.\n- **Chain services.** A service managed by its chain (`chain_id` set) fails with `422 field_immutable` and\n  an `errors[]` item per field on a change to `name`, `online_booking_name`,\n  `category_id`, `duration_seconds` or `package`, to the prices when the chain manages\n  the price, and to `online_booking_description` when the chain manages the description.\n- **Type.** `type` fails with `422 field_immutable` unless it equals the current value.\n\nSending the stored value of a protected field passes. A service of another Location, a\ndeleted service, a category, or a missing id fails with the same\n`404 resource_not_found`. Another media type fails with `415 unsupported_media_type`,\nbroken JSON or a body that is not an object with `400 malformed_request`.\n",
        "tags": [
          "Services"
        ],
        "security": [
          {
            "OAuth2": [
              "services:write"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "requestBody": {
          "required": true,
          "content": {
            "application/merge-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/ServiceUpdate"
              },
              "examples": {
                "price": {
                  "summary": "New price; a stored single price stays single",
                  "value": {
                    "price_min_minor": 280000
                  }
                },
                "rename": {
                  "summary": "Rename and clear the online booking name and description",
                  "value": {
                    "name": "Men's haircut and beard trim",
                    "online_booking_name": null,
                    "online_booking_description": null
                  }
                },
                "package_components": {
                  "summary": "Replace the components of a package",
                  "value": {
                    "package": {
                      "components": [
                        {
                          "service_id": 1501
                        },
                        {
                          "service_id": 1503
                        }
                      ]
                    }
                  }
                }
              }
            },
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ServiceUpdate"
              },
              "example": {
                "online_booking_enabled": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated service.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Service"
                },
                "examples": {
                  "service": {
                    "$ref": "#/components/examples/ServiceExample"
                  },
                  "package": {
                    "$ref": "#/components/examples/ServicePackageExample"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      },
      "delete": {
        "operationId": "deleteService",
        "summary": "Delete a service",
        "description": "Deletes a service from the Location catalog. A package is deleted with its component\nlist. A simple service that is a component of packages can be deleted: it leaves those\npackages, and Altegio recalculates only their duration afterwards: their `status` and\nprice stay as they were until the package is changed.\n\nFails with `409 conflict`, the reason in `detail`, when the service is managed by its\nchain (`chain_id` set; delete it in the chain) or when it is included in a Membership that clients\nkeep with active auto-renewal. A service of another Location, a deleted service,\na category, or a missing id fails with the same `404 resource_not_found`.\n",
        "tags": [
          "Services"
        ],
        "security": [
          {
            "OAuth2": [
              "services:write"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "responses": {
          "204": {
            "description": "The service has been deleted.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}/service_categories": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        }
      ],
      "get": {
        "operationId": "listServiceCategories",
        "summary": "List service categories",
        "description": "Returns the service categories of the Location. Use a category `id` as `category_id`\nwhen creating services.\n\n\nCursor-paginated list. Default ordering: `id` ascending. Cursors use the `cursor` query parameter, expire after one hour, and are bound to the credential, tenant, list, and filters. Expired, malformed, foreign, or re-filtered cursors fail with `422 validation_failed` using field codes `expired_cursor`, `invalid_cursor`, `foreign_cursor`, or `filter_changed`.",
        "tags": [
          "Services"
        ],
        "security": [
          {
            "OAuth2": [
              "services:read"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of service categories.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceCategoryList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "id": 205,
                      "object": "service_category",
                      "name": "Haircuts",
                      "chain_id": null,
                      "weight": 10
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null
                }
              }
            },
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      },
      "post": {
        "operationId": "createServiceCategory",
        "summary": "Create a service category",
        "description": "Creates a service category in the Location catalog. The response is the new category\nas `listServiceCategories` returns it; the `Location` header holds its URL.\n\n- **Name.** Leading and trailing spaces are trimmed. A name with a link (a URL or any\n  `word.word` without a space) fails with `422` at `/name`, as in `createService`:\n  Altegio would remove the link. A name that is empty after trimming, and characters\n  outside the Basic Multilingual Plane (emoji), fail with `422` too.\n- **Weight.** Without `weight` the category gets the highest `weight` among the\n  services and categories of the Location plus one, but not more than `2147483647`.\n\nThe body must be a JSON object sent as `application/json`: another media type fails\nwith `415 unsupported_media_type`, broken JSON or a body that is not an object with\n`400 malformed_request`.\n",
        "tags": [
          "Services"
        ],
        "security": [
          {
            "OAuth2": [
              "services:write"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ServiceCategoryCreate"
              },
              "example": {
                "name": "Haircuts",
                "weight": 10
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The created service category. `Location` holds its URL, `/api/v3/locations/{location_id}/service_categories/{id}`.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "Location": {
                "$ref": "#/components/headers/Location"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceCategory"
                },
                "example": {
                  "id": 205,
                  "object": "service_category",
                  "name": "Haircuts",
                  "chain_id": null,
                  "weight": 10
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}/service_categories/{service_category_id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        },
        {
          "$ref": "#/components/parameters/ServiceCategoryId"
        }
      ],
      "patch": {
        "operationId": "updateServiceCategory",
        "summary": "Update a service category",
        "description": "Partially updates a service category with a merge-patch body (RFC 7396);\n`application/json` is accepted with the same semantics. A missing field is left\nunchanged, so `{}` changes nothing; `null` on `name` or `weight` fails with\n`422 field_not_nullable`. The name rules of `createServiceCategory` apply.\n\nA category managed by its chain fails with `422 field_immutable` at `/name` on a name\nchange; its `weight` is a setting of this Location and can be changed. Sending the\nstored value passes. A category of another Location, a deleted category, a service\nid, a chain category not linked to this Location, or a missing id fails with the same\n`404 resource_not_found`. Another media type fails with\n`415 unsupported_media_type`, broken JSON or a body that is not an object with\n`400 malformed_request`.\n",
        "tags": [
          "Services"
        ],
        "security": [
          {
            "OAuth2": [
              "services:write"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "requestBody": {
          "required": true,
          "content": {
            "application/merge-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/ServiceCategoryUpdate"
              },
              "example": {
                "name": "Cuts & styling"
              }
            },
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ServiceCategoryUpdate"
              },
              "example": {
                "weight": 20
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated service category.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceCategory"
                },
                "example": {
                  "id": 205,
                  "object": "service_category",
                  "name": "Cuts & styling",
                  "chain_id": null,
                  "weight": 10
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      },
      "delete": {
        "operationId": "deleteServiceCategory",
        "summary": "Delete a service category",
        "description": "Deletes an empty service category from the Location catalog.\n\nFails with `409 conflict`, the reason in `detail`, when the category still holds\nservices of this Location (packages and package components included; move or delete\nthem first with `updateService` or `deleteService`), or when the category is managed\nby its chain. A category of another Location, a deleted category, a service id, a\nchain category not linked to this Location, or a missing id fails with the same\n`404 resource_not_found`.\n",
        "tags": [
          "Services"
        ],
        "security": [
          {
            "OAuth2": [
              "services:write"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "responses": {
          "204": {
            "description": "The service category has been deleted.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}/team_members": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        }
      ],
      "get": {
        "operationId": "listTeamMembers",
        "summary": "List team members",
        "description": "Returns the working Team Members of the Location as a cursor-paginated list; dismissed\nmembers are readable by id via `getTeamMember`. The list representation is the same Team\nMember object as `getTeamMember`. Team Member personal contact data is not exposed in the\npreview scope.\n\n\nCursor-paginated list. Default ordering: `id` ascending. Cursors use the `cursor` query parameter, expire after one hour, and are bound to the credential, tenant, list, and filters. Expired, malformed, foreign, or re-filtered cursors fail with `422 validation_failed` using field codes `expired_cursor`, `invalid_cursor`, `foreign_cursor`, or `filter_changed`.",
        "tags": [
          "Team Members"
        ],
        "security": [
          {
            "OAuth2": [
              "team_members:read"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of team members.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TeamMemberList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "id": 321,
                      "object": "team_member",
                      "name": "Aigerim Bekova",
                      "specialization": "Hairdresser",
                      "avatar_url": "https://assets.alteg.io/masters/norm/4/48/48c3c5a1b0e1e8d_20260601093015.png",
                      "position_id": 15,
                      "online_booking_enabled": true,
                      "dismissal_date": null,
                      "created_at": "2026-06-01T08:00:00Z"
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null
                }
              }
            },
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      },
      "post": {
        "operationId": "createTeamMember",
        "summary": "Create a team member",
        "description": "Creates a Team Member in the Location. After creating, set the working schedule\n(`PATCH .../schedule`) and link services (`PATCH .../services`) — otherwise the member\ndoes not appear in availability search. System access for the new member (login, role,\ninvitation) is a separate planned operation, `sendTeamMemberInvitation`.\n",
        "tags": [
          "Team Members"
        ],
        "security": [
          {
            "OAuth2": [
              "team_members:write"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TeamMemberCreate"
              },
              "example": {
                "name": "Aigerim Bekova",
                "specialization": "Hairdresser",
                "position_id": 15
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The created team member.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "Location": {
                "$ref": "#/components/headers/Location"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TeamMember"
                },
                "examples": {
                  "team_member": {
                    "$ref": "#/components/examples/TeamMemberExample"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}/team_members/{team_member_id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        },
        {
          "$ref": "#/components/parameters/TeamMemberId"
        }
      ],
      "get": {
        "operationId": "getTeamMember",
        "summary": "Get a team member",
        "description": "Returns a single Team Member. Dismissed members are readable; deleted ones answer\n`404 resource_not_found`.\n",
        "tags": [
          "Team Members"
        ],
        "security": [
          {
            "OAuth2": [
              "team_members:read"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "responses": {
          "200": {
            "description": "The team member.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TeamMember"
                },
                "examples": {
                  "team_member": {
                    "$ref": "#/components/examples/TeamMemberExample"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      },
      "patch": {
        "operationId": "updateTeamMember",
        "summary": "Update a team member",
        "description": "Partially updates the Team Member card with a merge-patch body: name, specialization,\nposition and the paid-seat flag. Service links are written through\n`updateTeamMemberServices` and dismissal through `dismissTeamMember`; neither is a field\nof the card.\n",
        "tags": [
          "Team Members"
        ],
        "security": [
          {
            "OAuth2": [
              "team_members:write"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "requestBody": {
          "required": true,
          "content": {
            "application/merge-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/TeamMemberUpdate"
              },
              "example": {
                "position_id": 16
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated team member.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TeamMember"
                },
                "examples": {
                  "team_member": {
                    "$ref": "#/components/examples/TeamMemberExample"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      },
      "delete": {
        "operationId": "deleteTeamMember",
        "summary": "Delete a team member",
        "description": "Removes a Team Member from the Location.\n",
        "tags": [
          "Team Members"
        ],
        "security": [
          {
            "OAuth2": [
              "team_members:write"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "responses": {
          "204": {
            "description": "The team member has been deleted.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}/team_members/{team_member_id}/schedule": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        },
        {
          "$ref": "#/components/parameters/TeamMemberId"
        }
      ],
      "get": {
        "operationId": "getTeamMemberSchedule",
        "summary": "Get a team member's schedule",
        "description": "Returns the **configured working schedule** of a Team Member for a date range — the\ndays and working intervals set by the business. This is not availability: free bookable\nslots come from `GET /locations/{location_id}/availability`.\n\nVisibility follows the acting user's rights in the Digital schedule: a member outside\nthe user's allowed team members (own appointments or own position) answers\n`404 resource_not_found`, and days before the user's history access limit (N days back\nfrom today) are omitted from `days`; `date_from` and `date_to` stay as requested.\n",
        "tags": [
          "Team Members"
        ],
        "security": [
          {
            "OAuth2": [
              "team_members:read"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "parameters": [
          {
            "name": "date_from",
            "in": "query",
            "required": true,
            "description": "First date of the range (inclusive), `YYYY-MM-DD`.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "date_to",
            "in": "query",
            "required": true,
            "description": "Last date of the range (inclusive), `YYYY-MM-DD`. Must not be earlier than `date_from`; the range covers at most 92 calendar days inclusive, i.e. `date_to` is at most 91 days after `date_from` (any three calendar months); otherwise `422 validation_failed` with `errors[0].pointer = date_to`, `source = query` and `code = invalid_value`.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Every visible day of the requested range with its working intervals; a day off has an empty `intervals` array, a day closed by the history access limit is absent.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TeamMemberSchedule"
                },
                "example": {
                  "object": "team_member_schedule",
                  "team_member_id": 321,
                  "date_from": "2026-07-24",
                  "date_to": "2026-07-26",
                  "days": [
                    {
                      "date": "2026-07-24",
                      "intervals": [
                        {
                          "from": "09:00",
                          "to": "13:00"
                        },
                        {
                          "from": "14:00",
                          "to": "18:00"
                        }
                      ]
                    },
                    {
                      "date": "2026-07-25",
                      "intervals": [
                        {
                          "from": "10:00",
                          "to": "16:00"
                        }
                      ]
                    },
                    {
                      "date": "2026-07-26",
                      "intervals": []
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      },
      "patch": {
        "operationId": "updateTeamMemberSchedule",
        "summary": "Update a team member's schedule",
        "description": "Updates the working schedule as a **merge-patch map keyed by date**: each key is a\n`YYYY-MM-DD` date, the value sets the working intervals of that day, and `null` clears the\nday. Dates absent from the body are left unchanged. Times are wall-clock `HH:MM` in\nthe Location's timezone. The response covers every day from the earliest to the latest\ndate of the body, as `date_from` and `date_to`.\n",
        "tags": [
          "Team Members"
        ],
        "security": [
          {
            "OAuth2": [
              "team_members:schedule"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "requestBody": {
          "required": true,
          "content": {
            "application/merge-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/TeamMemberSchedulePatch"
              },
              "example": {
                "2026-07-24": {
                  "intervals": [
                    {
                      "from": "09:00",
                      "to": "18:00"
                    }
                  ]
                },
                "2026-07-25": null
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The days updated by this request.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TeamMemberSchedule"
                },
                "example": {
                  "object": "team_member_schedule",
                  "team_member_id": 321,
                  "date_from": "2026-07-24",
                  "date_to": "2026-07-25",
                  "days": [
                    {
                      "date": "2026-07-24",
                      "intervals": [
                        {
                          "from": "09:00",
                          "to": "18:00"
                        }
                      ]
                    },
                    {
                      "date": "2026-07-25",
                      "intervals": []
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}/team_members/{team_member_id}/dismiss": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        },
        {
          "$ref": "#/components/parameters/TeamMemberId"
        }
      ],
      "post": {
        "operationId": "dismissTeamMember",
        "summary": "Dismiss a team member",
        "description": "Dismisses a Team Member as a command: the response is the Team Member with\n`dismissal_date` set and `online_booking_enabled: false`. Dismissal is not a field of the Team\nMember card — `updateTeamMember` cannot set it. The acting user needs the dismissal\npermission of the Location; dismissing a member who has a system login also needs the\npermission to delete users, otherwise `403 permission_denied`. Dismissing an already\ndismissed member returns the current state unchanged.\n",
        "tags": [
          "Team Members"
        ],
        "security": [
          {
            "OAuth2": [
              "team_members:write"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TeamMemberDismissRequest"
              },
              "example": {
                "dismissal_date": "2026-10-31",
                "reason": "moved to another city"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The dismissed team member.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TeamMember"
                },
                "example": {
                  "id": 321,
                  "object": "team_member",
                  "name": "Beatriz Costa",
                  "specialization": "Hair stylist",
                  "avatar_url": null,
                  "position_id": 7,
                  "online_booking_enabled": false,
                  "dismissal_date": "2026-10-31",
                  "created_at": "2025-03-02T10:00:00Z"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}/team_members/{team_member_id}/services": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        },
        {
          "$ref": "#/components/parameters/TeamMemberId"
        }
      ],
      "patch": {
        "operationId": "updateTeamMemberServices",
        "summary": "Update a team member's service links",
        "description": "Updates which services a Team Member provides and the per-member overrides, as a\n**merge-patch map keyed by `service_id`**: a value creates or updates the link, `null`\nunlinks the service, services absent from the body are left unchanged. This is the only\ndirect write path for the Team Member ↔ service link: service and team member bodies do\nnot carry link arrays, and creating or changing a package links it to the Team Members of\nits components (`createService`, `updateService`). The response lists all current links of the member.\n",
        "tags": [
          "Team Members"
        ],
        "security": [
          {
            "OAuth2": [
              "team_members:write"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "requestBody": {
          "required": true,
          "content": {
            "application/merge-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/TeamMemberServicesPatch"
              },
              "example": {
                "100": {
                  "price_minor": 250000,
                  "duration_seconds": 3600
                },
                "101": null
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "All current service links of the team member.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TeamMemberServiceLinkList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "service_id": 100,
                      "duration_seconds": 3600,
                      "price_minor": 250000,
                      "bill_of_materials_id": null,
                      "is_bookable": null,
                      "online_booking_enabled": null
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}/access_roles": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        }
      ],
      "get": {
        "operationId": "listLocationAccessRoles",
        "summary": "List location access roles",
        "description": "Returns public role ids and titles only; internal permission slugs are never exposed.\n\nCursor-paginated list. Default ordering: title, role_id tie-breaker. Cursors use the `cursor` query parameter, expire after one hour, and are bound to the credential, tenant, list, and filters. Expired, malformed, foreign, or re-filtered cursors fail with `422 validation_failed` using field codes `expired_cursor`, `invalid_cursor`, `foreign_cursor`, or `filter_changed`.",
        "tags": [
          "Team Members"
        ],
        "security": [
          {
            "OAuth2": [
              "team_members:manage_access"
            ]
          }
        ],
        "x-altegio-status": "planned",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LocationAccessRoleList"
                }
              }
            },
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "412": {
            "$ref": "#/components/responses/PreconditionFailed"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "428": {
            "$ref": "#/components/responses/PreconditionRequired"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}/team_members/{team_member_id}/access": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        },
        {
          "$ref": "#/components/parameters/TeamMemberId"
        }
      ],
      "get": {
        "operationId": "getTeamMemberAccess",
        "summary": "Get team member access",
        "description": "Returns current system-access status for a Team Member: `none`, `invited`, or `active`, plus public `role_id` and pending invitation timestamps. The response carries a strong `ETag` for a subsequent access `PATCH`.",
        "tags": [
          "Team Members"
        ],
        "security": [
          {
            "OAuth2": [
              "team_members:manage_access"
            ]
          }
        ],
        "x-altegio-status": "planned",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TeamMemberAccess"
                }
              }
            },
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "ETag": {
                "$ref": "#/components/headers/ETag"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      },
      "patch": {
        "operationId": "updateTeamMemberAccess",
        "summary": "Update team member access",
        "description": "Merge-patch access settings. Only `role_id` is mutable; unavailable roles fail with `422 role_not_assignable`. Requires `If-Match` with the `ETag` from `getTeamMemberAccess` (or a prior successful write).",
        "tags": [
          "Team Members"
        ],
        "security": [
          {
            "OAuth2": [
              "team_members:manage_access"
            ]
          }
        ],
        "x-altegio-status": "planned",
        "parameters": [
          {
            "$ref": "#/components/parameters/IfMatch"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/merge-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/TeamMemberAccessUpdate"
              },
              "example": {
                "role_id": 7
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TeamMemberAccess"
                }
              }
            },
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "ETag": {
                "$ref": "#/components/headers/ETag"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "412": {
            "$ref": "#/components/responses/PreconditionFailed"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "428": {
            "$ref": "#/components/responses/PreconditionRequired"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      },
      "delete": {
        "operationId": "revokeTeamMemberAccess",
        "summary": "Revoke team member access",
        "description": "Revokes pending or active system access and returns the Team Member to `none`; the Team Member record is not deleted. The last location owner cannot be revoked (`409 last_location_owner`). Requires `Idempotency-Key`. The `200` response carries a fresh access `ETag`.",
        "tags": [
          "Team Members"
        ],
        "security": [
          {
            "OAuth2": [
              "team_members:manage_access"
            ]
          }
        ],
        "x-altegio-status": "planned",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TeamMemberAccess"
                }
              }
            },
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "ETag": {
                "$ref": "#/components/headers/ETag"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}/team_members/{team_member_id}/invitation": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        },
        {
          "$ref": "#/components/parameters/TeamMemberId"
        }
      ],
      "post": {
        "operationId": "sendTeamMemberInvitation",
        "summary": "Send team member invitation",
        "description": "Sends or resends delivery for the single pending invitation of this Team Member.\nDelivery contact is set only at Team Member create via write-only `access_invitation.phone` /\n`access_invitation.email`; this resend uses the stored delivery target and does not accept\na contact override in the body. `422 invitation_contact_required` when no delivery contact\nexists; `409 invitation_already_pending` when a distinct pending invitation already exists;\n`409 access_already_active` when the Team Member already has active access. Requires\n`Idempotency-Key`.\n",
        "tags": [
          "Team Members"
        ],
        "security": [
          {
            "OAuth2": [
              "team_members:manage_access"
            ]
          }
        ],
        "x-altegio-status": "planned",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TeamMemberInvitationCreate"
              },
              "example": {}
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TeamMemberAccess"
                }
              }
            },
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "412": {
            "$ref": "#/components/responses/PreconditionFailed"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "428": {
            "$ref": "#/components/responses/PreconditionRequired"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}/positions": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        }
      ],
      "get": {
        "operationId": "listPositions",
        "summary": "List positions",
        "description": "Returns the position directory of the Location. Reference a position from a Team\nMember via `position_id`.\n\n\nCursor-paginated list. Default ordering: `id` ascending. Cursors use the `cursor` query parameter, expire after one hour, and are bound to the credential, tenant, list, and filters. Expired, malformed, foreign, or re-filtered cursors fail with `422 validation_failed` using field codes `expired_cursor`, `invalid_cursor`, `foreign_cursor`, or `filter_changed`.",
        "tags": [
          "Positions"
        ],
        "security": [
          {
            "OAuth2": [
              "team_members:read"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of positions.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PositionList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "id": 15,
                      "object": "position",
                      "title": "Barber"
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null
                }
              }
            },
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      },
      "post": {
        "operationId": "createPosition",
        "summary": "Create a position",
        "description": "Creates a position.",
        "tags": [
          "Positions"
        ],
        "security": [
          {
            "OAuth2": [
              "team_members:write"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PositionCreate"
              },
              "example": {
                "title": "Barber"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The created position.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "Location": {
                "$ref": "#/components/headers/Location"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Position"
                },
                "example": {
                  "id": 15,
                  "object": "position",
                  "title": "Barber"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}/positions/{position_id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        },
        {
          "$ref": "#/components/parameters/PositionId"
        }
      ],
      "get": {
        "operationId": "getPosition",
        "summary": "Get a position",
        "description": "Returns a single position.\n",
        "tags": [
          "Positions"
        ],
        "security": [
          {
            "OAuth2": [
              "team_members:read"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "available",
        "responses": {
          "200": {
            "description": "The position.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Position"
                },
                "example": {
                  "id": 15,
                  "object": "position",
                  "title": "Barber"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      },
      "patch": {
        "operationId": "updatePosition",
        "summary": "Update a position",
        "description": "Partially updates a position with a merge-patch body.",
        "tags": [
          "Positions"
        ],
        "security": [
          {
            "OAuth2": [
              "team_members:write"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "requestBody": {
          "required": true,
          "content": {
            "application/merge-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/PositionUpdate"
              },
              "example": {
                "title": "Senior barber"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated position.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Position"
                },
                "example": {
                  "id": 15,
                  "object": "position",
                  "title": "Senior barber"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      },
      "delete": {
        "operationId": "deletePosition",
        "summary": "Delete a position",
        "description": "Deletes a position.",
        "tags": [
          "Positions"
        ],
        "security": [
          {
            "OAuth2": [
              "team_members:write"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "responses": {
          "204": {
            "description": "The position has been deleted.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}/clients": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        }
      ],
      "get": {
        "operationId": "listClients",
        "summary": "List and search clients",
        "description": "Searches the client base of the Location. Exact `phone` and `email` contact searches require `clients:read_contact` plus the subject's permission to see client phone numbers and emails in the client list: without the scope the API returns `403 missing_scope`, without the permission `403 permission_denied`, never an empty result. Free-text `query` remains under `clients:read`. Contact fields (`phone`, `additional_phone`, `email`) use the redaction contract when contact access is absent; `surname` and `patronymic` use it without the permission to see client surnames, `comment` without the permission to see client card comments. A subject limited to the clients of one team member sees only clients with an appointment with that team member, on every page. This endpoint is rate-limited.\\n\\nCursor-paginated list. Default ordering: id. Cursors use the `cursor` query parameter, expire after one hour, and are bound to the credential, tenant, list, and filters. Expired, malformed, foreign, or re-filtered cursors fail with `422 validation_failed` using field codes `expired_cursor`, `invalid_cursor`, `foreign_cursor`, or `filter_changed`.",
        "tags": [
          "Clients"
        ],
        "security": [
          {
            "OAuth2": [
              "clients:read"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "parameters": [
          {
            "name": "phone",
            "in": "query",
            "required": false,
            "description": "Exact phone number to search for, in international format; spaces, brackets, dashes and a leading `+` are ignored. Matches the client's main phone. Requires `clients:read_contact`; without it the response is `403`, not an empty list. An empty value or a value without digits fails with `422 validation_failed`.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255
            }
          },
          {
            "name": "email",
            "in": "query",
            "required": false,
            "description": "Exact email to search for, case-insensitive. Requires `clients:read_contact`; without it the response is `403`, not an empty list. An empty value fails with `422 validation_failed`.",
            "schema": {
              "type": "string",
              "format": "email",
              "minLength": 1,
              "maxLength": 255
            }
          },
          {
            "name": "query",
            "in": "query",
            "required": false,
            "description": "Case-insensitive substring of the client's `name`, and of `surname` and `patronymic` when the Location keeps the field and the caller may see it (not `null` because of a turned-off field, not listed in `redacted_fields`). Never matches phone numbers, emails or other contact data; contact search uses `phone`/`email` and requires `clients:read_contact`. An empty value fails with `422 validation_failed`.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255
            }
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of clients matching the search.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "id": 789,
                      "object": "client",
                      "name": "Demo",
                      "surname": "Client",
                      "patronymic": null,
                      "phone": "+351210000175",
                      "additional_phone": null,
                      "email": "demo.client@example.com",
                      "comment": null,
                      "card_number": null,
                      "gender": null,
                      "importance": null,
                      "birth_day": 12,
                      "birth_month": 4,
                      "birth_year": 1990,
                      "discount_percent": 5,
                      "visits_count": 12,
                      "first_visit_at": "2025-11-02T10:00:00+00:00",
                      "last_visit_at": "2026-07-09T11:30:00+01:00",
                      "sold_amount_minor": 1250000,
                      "currency": "EUR",
                      "created_at": "2025-11-02T09:57:15Z",
                      "updated_at": "2026-07-09T09:57:15Z",
                      "redacted_fields": []
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null
                }
              }
            },
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      },
      "post": {
        "operationId": "createClient",
        "summary": "Create a client",
        "description": "Creates a client. `name` and `phone` are required. The phone number is deduplicated\nwithin the Location: if another (non-deleted) client already owns it, the request\nfails with `422 phone_taken`. That signal is part of `clients:write` (no\n`clients:read_contact` required); it does not reveal the other client's id or contacts.\nPhone-bearing writes are audited and rate-limited against enumeration. Requires\n`Idempotency-Key`.\n\nContact fields in the response follow the redaction contract: without\n`clients:read_contact` they are returned as `null` and listed in `redacted_fields`,\nnever as a placeholder string.\n",
        "tags": [
          "Clients"
        ],
        "security": [
          {
            "OAuth2": [
              "clients:write"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ClientCreate"
              },
              "example": {
                "name": "Demo",
                "surname": "Client",
                "phone": "+351210000175",
                "email": "demo.client@example.com",
                "birth_date": "1990-04-12"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The created client.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "Location": {
                "$ref": "#/components/headers/Location"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Client"
                },
                "examples": {
                  "client": {
                    "$ref": "#/components/examples/ClientExample"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "description": "Validation failed, or the phone number already belongs to another client (`phone_taken`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "examples": {
                  "phone_taken": {
                    "summary": "Phone already belongs to another client",
                    "value": {
                      "type": "https://developer.alteg.io/problems/phone-taken",
                      "title": "Phone number already in use",
                      "status": 422,
                      "detail": "Another client of this location already uses this phone number.",
                      "instance": "urn:altegio:request:req_c1x9",
                      "code": "phone_taken"
                    }
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}/clients/{client_id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        },
        {
          "$ref": "#/components/parameters/ClientId"
        }
      ],
      "get": {
        "operationId": "getClient",
        "summary": "Get a client",
        "description": "Returns a single client. Contact fields (`phone`, `additional_phone`, `email`) require\n`clients:read_contact` plus the subject's permission to see phone numbers in the client\ncard; `surname` and `patronymic` require the subject's permission to see client surnames;\n`comment` requires the subject's permission to see client card comments, independently of\ncontact access. A withheld field is returned as `null` and listed in `redacted_fields`\ninstead of exposing its value.\n\nA client of another Location (including a Location of the same chain), a deleted\nclient and, for a subject limited to the clients of one team member, a client without\nan appointment with that team member all return the same `404 resource_not_found`.\n",
        "tags": [
          "Clients"
        ],
        "security": [
          {
            "OAuth2": [
              "clients:read"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "responses": {
          "200": {
            "description": "The client.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Client"
                },
                "examples": {
                  "client": {
                    "$ref": "#/components/examples/ClientExample"
                  },
                  "redacted": {
                    "$ref": "#/components/examples/ClientRedactedExample"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      },
      "patch": {
        "operationId": "updateClient",
        "summary": "Update a client",
        "description": "Partially updates a client with a merge-patch body. Changing the\nphone to a number owned by another client fails with `422 phone_taken` — the same\n`clients:write` signal as on create (audited and rate-limited; no other client identity\nis returned). Clearing a nullable field is done with `null`; clearing contact fields\nrequires contact write access.\n",
        "tags": [
          "Clients"
        ],
        "security": [
          {
            "OAuth2": [
              "clients:write"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "requestBody": {
          "required": true,
          "content": {
            "application/merge-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/ClientUpdate"
              },
              "example": {
                "email": "new.email@example.com",
                "comment": "Prefers morning visits"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated client.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Client"
                },
                "examples": {
                  "client": {
                    "$ref": "#/components/examples/ClientExample"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "description": "Validation failed, the phone is taken (`phone_taken`), or merge-patch semantics were violated (`field_not_nullable`, `field_immutable`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "examples": {
                  "phone_taken": {
                    "summary": "Phone already belongs to another client",
                    "value": {
                      "type": "https://developer.alteg.io/problems/phone-taken",
                      "title": "Phone number already in use",
                      "status": 422,
                      "detail": "Another client of this location already uses this phone number.",
                      "instance": "urn:altegio:request:req_c4x2",
                      "code": "phone_taken"
                    }
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      },
      "delete": {
        "operationId": "deleteClient",
        "summary": "Delete a client",
        "description": "Deletes a client (soft delete). A client with the same phone can be created again\nafterwards.\n",
        "tags": [
          "Clients"
        ],
        "security": [
          {
            "OAuth2": [
              "clients:write"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "responses": {
          "204": {
            "description": "The client has been deleted.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}/availability": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        }
      ],
      "get": {
        "operationId": "getAvailability",
        "summary": "Search free slots",
        "description": "Computes the free start times for the given services within a date range of up to\n7 days, optionally narrowed to one Team Member, by the same calculation as online\nbooking. A slot is one Team Member at one start time: when several Team Members are\nfree at the same time, each gets its own slot. `starts_at` carries the Location's UTC\noffset; pass it with `team_member_id` to `createAppointment`. Slots are sorted by\n`starts_at`, then `team_member_id`. For the dates with free time over a longer range\n(a booking calendar) use `getAvailabilityDates`.\n\n- Only services with online booking enabled in the Location are searched. Without\n  `team_member_id` the search covers Team Members open for online booking.\n  A working Team Member currently hidden from online booking yields `200` with an\n  empty result, including when passed explicitly. An explicit id does not bypass\n  the Team Member's current visibility setting.\n- The Location's technical Team Member setting is separate from the Team Member's\n  online visibility. If a technical Team Member is configured, an incompatible\n  explicit `team_member_id` returns `200` with an empty result. Without the parameter,\n  the existing technical Team Member setting applies. An explicit matching id or\n  an omitted parameter can return availability only if that technical Team Member\n  is currently visible for online booking and the acting user's rights permit it.\n- Days before today in the Location's time zone have no free time.\n- Package services are planned: a package in `service_ids[]` fails with\n  `422 validation_failed` and `errors[0].code = unsupported_service_type`.\n- Visibility follows the acting user's rights in the Digital schedule: a Team Member\n  outside the user's allowed Team Members (own appointments or own position) yields\n  an empty result, and without `team_member_id` only allowed Team Members are searched.\n\nThis is a computed read-only aggregate: slots have no ids and can disappear at any\nmoment when another request schedules an overlapping appointment (a lost race on create\nreturns `409 slot_taken`).\n",
        "tags": [
          "Availability"
        ],
        "security": [
          {
            "OAuth2": [
              "availability:read"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "parameters": [
          {
            "$ref": "#/components/parameters/AvailabilityServiceIds"
          },
          {
            "$ref": "#/components/parameters/AvailabilityTeamMemberId"
          },
          {
            "name": "date_from",
            "in": "query",
            "required": true,
            "description": "First date of the range (inclusive), `YYYY-MM-DD`, in the Location's calendar.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "date_to",
            "in": "query",
            "required": true,
            "description": "Last date of the range (inclusive), `YYYY-MM-DD`. Must not be earlier than `date_from`; the range covers at most 7 calendar days inclusive, i.e. `date_to` is at most 6 days after `date_from`; otherwise `422 validation_failed` with `errors[0].pointer = date_to`, `source = query` and `code = invalid_value`.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Free slots of the requested services within the range.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Availability"
                },
                "example": {
                  "object": "availability",
                  "slots": [
                    {
                      "team_member_id": 321,
                      "starts_at": "2026-07-24T11:30:00+01:00",
                      "duration_seconds": 3600
                    },
                    {
                      "team_member_id": 322,
                      "starts_at": "2026-07-24T11:30:00+01:00",
                      "duration_seconds": 2700
                    },
                    {
                      "team_member_id": 321,
                      "starts_at": "2026-07-24T12:30:00+01:00",
                      "duration_seconds": 3600
                    }
                  ]
                }
              }
            },
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}/availability/dates": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        }
      ],
      "get": {
        "operationId": "getAvailabilityDates",
        "summary": "Search dates with free slots",
        "description": "Returns the dates within a range of up to 92 days on which the given services have at\nleast one free slot, optionally narrowed to one Team Member: the dates for a booking\ncalendar. Free time follows the same rules as `getAvailability`; take the slots of a\nchosen date from `getAvailability`. Dates are sorted ascending.\n\n- Only services with online booking enabled in the Location are searched. Without\n  `team_member_id` the search covers Team Members open for online booking.\n  A working Team Member currently hidden from online booking yields `200` with an\n  empty result, including when passed explicitly. An explicit id does not bypass\n  the Team Member's current visibility setting.\n- The Location's technical Team Member setting is separate from the Team Member's\n  online visibility. If a technical Team Member is configured, an incompatible\n  explicit `team_member_id` returns `200` with an empty result. Without the parameter,\n  the existing technical Team Member setting applies. An explicit matching id or\n  an omitted parameter can return availability only if that technical Team Member\n  is currently visible for online booking and the acting user's rights permit it.\n- Days before today in the Location's time zone have no free time.\n- Package services are planned: a package in `service_ids[]` fails with\n  `422 validation_failed` and `errors[0].code = unsupported_service_type`.\n- Visibility follows the acting user's rights in the Digital schedule: a Team Member\n  outside the user's allowed Team Members (own appointments or own position) yields\n  an empty result, and without `team_member_id` only allowed Team Members are searched.\n",
        "tags": [
          "Availability"
        ],
        "security": [
          {
            "OAuth2": [
              "availability:read"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "parameters": [
          {
            "$ref": "#/components/parameters/AvailabilityServiceIds"
          },
          {
            "$ref": "#/components/parameters/AvailabilityTeamMemberId"
          },
          {
            "name": "date_from",
            "in": "query",
            "required": true,
            "description": "First date of the range (inclusive), `YYYY-MM-DD`, in the Location's calendar.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "date_to",
            "in": "query",
            "required": true,
            "description": "Last date of the range (inclusive), `YYYY-MM-DD`. Must not be earlier than `date_from`; the range covers at most 92 calendar days inclusive, i.e. `date_to` is at most 91 days after `date_from`; otherwise `422 validation_failed` with `errors[0].pointer = date_to`, `source = query` and `code = invalid_value`.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Dates with free slots of the requested services within the range.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AvailabilityDates"
                },
                "example": {
                  "object": "availability_dates",
                  "dates": [
                    "2026-07-24",
                    "2026-07-25",
                    "2026-07-28"
                  ]
                }
              }
            },
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}/resources": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        }
      ],
      "get": {
        "operationId": "listResources",
        "summary": "List resources",
        "description": "Returns the bookable resources of the Location (rooms, chairs, equipment) with their\ninstances. Pass instance ids as `resource_instance_ids` when creating an appointment\nfor services that require a resource. Resource management (create/update/delete) is\nnot part of the preview scope. Deleted resources and instances are not returned;\n`instances` is sorted by `id` and is an empty array for a resource without instances.\n\n\nCursor-paginated list. Default ordering: `id` ascending. Cursors use the `cursor` query parameter, expire after one hour, and are bound to the credential, tenant, list, and filters. Expired, malformed, foreign, or re-filtered cursors fail with `422 validation_failed` using field codes `expired_cursor`, `invalid_cursor`, `foreign_cursor`, or `filter_changed`.",
        "tags": [
          "Resources"
        ],
        "security": [
          {
            "OAuth2": [
              "locations:read"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of resources.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResourceList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "id": 41,
                      "object": "resource",
                      "title": "Massage room",
                      "instances": [
                        {
                          "id": 411,
                          "object": "resource_instance",
                          "title": "Room 1"
                        },
                        {
                          "id": 412,
                          "object": "resource_instance",
                          "title": "Room 2"
                        }
                      ]
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null
                }
              }
            },
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}/appointments": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        }
      ],
      "post": {
        "operationId": "createAppointment",
        "summary": "Create an appointment",
        "description": "Creates an appointment for a client with a Team Member at a chosen start time.\n\n- **A client is optional.** Pass `client_id` of an existing client, an inline `client` object resolved attach-only by normalized phone without `clients:write`, or neither for a clientless appointment.\n- With a client the `201` response carries `visit_id > 0`; a clientless appointment has `visit_id: null`. Payment and visit operations are keyed by `appointment_id`, not `visit_id`.\n- Slot conflicts are checked server-side: if a parallel request takes the slot first,\n  the call fails with `409 slot_taken` — pick a new slot from availability and retry\n  with a **new** `Idempotency-Key`.\n- Requires `Idempotency-Key`; a retry of the same request returns the original\n  result instead of recording a duplicate appointment.\n\n- For a package service, pass `components[{package_component_id, team_member_id}]`; the `201` response returns all created appointments plus their shared `visit_id`. Package availability is planned.\n- Inline client resolution does not reveal whether a client was found or created.\n",
        "tags": [
          "Appointments"
        ],
        "security": [
          {
            "OAuth2": [
              "appointments:create"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "planned",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AppointmentCreate"
              },
              "examples": {
                "withExistingClient": {
                  "summary": "Book for an existing client",
                  "value": {
                    "client_id": 789,
                    "team_member_id": 321,
                    "service_ids": [
                      100
                    ],
                    "starts_at": "2026-07-24T11:30:00+01:00"
                  }
                },
                "withInlineClient": {
                  "summary": "Book with an inline client",
                  "value": {
                    "client": {
                      "name": "Demo Client",
                      "phone": "+351210000175"
                    },
                    "team_member_id": 321,
                    "service_ids": [
                      100
                    ],
                    "starts_at": "2026-07-24T11:30:00+01:00",
                    "comment": "First visit"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The created appointment.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "Location": {
                "$ref": "#/components/headers/Location"
              },
              "ETag": {
                "$ref": "#/components/headers/ETag"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Appointment"
                    },
                    {
                      "$ref": "#/components/schemas/AppointmentCreateResponse"
                    }
                  ]
                },
                "examples": {
                  "appointment": {
                    "$ref": "#/components/examples/AppointmentExample"
                  },
                  "package": {
                    "summary": "Package appointment result",
                    "value": {
                      "object": "appointment_create_result",
                      "visit_id": 5001,
                      "appointments": []
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "description": "The requested slot was taken by a parallel appointment creation (`slot_taken`), or the `Idempotency-Key` conflicts with an earlier request (`idempotency_key_reused`, `idempotency_request_in_progress`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "examples": {
                  "slot_taken": {
                    "summary": "Slot lost to a parallel appointment creation",
                    "value": {
                      "type": "https://developer.alteg.io/problems/slot-taken",
                      "title": "Time slot is no longer available",
                      "status": 409,
                      "detail": "The requested time slot was taken by another appointment request.",
                      "instance": "urn:altegio:request:req_ap1x",
                      "code": "slot_taken"
                    }
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      },
      "get": {
        "operationId": "listAppointments",
        "summary": "List appointments",
        "description": "Returns the appointments of the Location as a cursor-paginated list, newest window\nfirst by start time with a stable tie-breaker. Client contact data inside\n`include[]=client` uses redacted contact fields without `clients:read_contact`.\n\nCancelled appointments are included; filter them out on the `status` field. There is no\nstatus query parameter in the first iteration.\n\n\nCursor-paginated list. Default ordering: starts_at desc, id tie-breaker. Cursors use the `cursor` query parameter, expire after one hour, and are bound to the credential, tenant, list, and filters. Expired, malformed, foreign, or re-filtered cursors fail with `422 validation_failed` using field codes `expired_cursor`, `invalid_cursor`, `foreign_cursor`, or `filter_changed`.",
        "tags": [
          "Appointments"
        ],
        "security": [
          {
            "OAuth2": [
              "appointments:read"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "parameters": [
          {
            "name": "starts_at_from",
            "in": "query",
            "required": false,
            "description": "Only appointments starting at or after this RFC 3339 datetime.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "starts_at_to",
            "in": "query",
            "required": false,
            "description": "Only appointments starting before this RFC 3339 datetime.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "team_member_id",
            "in": "query",
            "required": false,
            "description": "Only appointments of this Team Member.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "client_id",
            "in": "query",
            "required": false,
            "description": "Only appointments of this client.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "$ref": "#/components/parameters/IncludeAppointment"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of appointments.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppointmentList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "id": 12345,
                      "object": "appointment",
                      "location_id": 4321,
                      "client_id": 789,
                      "visit_id": 5001,
                      "team_member_id": 321,
                      "service_ids": [
                        100
                      ],
                      "resource_instance_ids": [],
                      "status": "waiting",
                      "starts_at": "2026-07-24T11:30:00+01:00",
                      "ends_at": "2026-07-24T12:30:00+01:00",
                      "duration_seconds": 3600,
                      "is_paid": false,
                      "comment": null,
                      "cancelled_at": null,
                      "cancellation_reason": null,
                      "created_at": "2026-07-20T09:57:15Z",
                      "updated_at": "2026-07-20T09:57:15Z"
                    }
                  ],
                  "has_more": true,
                  "next_cursor": "cur_appt_01J3K6Y8Q4W5E9R2T7A1B0C3D4"
                }
              }
            },
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}/appointments/{appointment_id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        },
        {
          "$ref": "#/components/parameters/AppointmentId"
        }
      ],
      "get": {
        "operationId": "getAppointment",
        "summary": "Get an appointment",
        "description": "Returns a single appointment. `visit_id` links to the billing visit (it is `null`\nonly on appointments created without a client). Re-read the appointment to obtain a\nfresh `visit_id` — visit grouping may change when the appointments of the day are edited. The\nresponse carries an `ETag` header for a subsequent `PATCH`.\n",
        "tags": [
          "Appointments"
        ],
        "security": [
          {
            "OAuth2": [
              "appointments:read"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "parameters": [
          {
            "$ref": "#/components/parameters/IncludeAppointment"
          }
        ],
        "responses": {
          "200": {
            "description": "The appointment.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Appointment"
                },
                "examples": {
                  "appointment": {
                    "$ref": "#/components/examples/AppointmentExample"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      },
      "patch": {
        "operationId": "updateAppointment",
        "summary": "Update (reschedule) an appointment",
        "description": "Edits or reschedules an appointment with a merge-patch body: start time, Team Member,\nservices, duration, comment. The appointment status is **not** editable here — use the\n`status` command. Cancellation is a separate `cancel` command.\n\n`If-Match` is required: appointments are the most contended resource (a human and an\nagent often edit the same one), and a stale version fails with `412 stale_version`\ninstead of silently overwriting someone's change.\n",
        "tags": [
          "Appointments"
        ],
        "security": [
          {
            "OAuth2": [
              "appointments:write"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "planned",
        "parameters": [
          {
            "$ref": "#/components/parameters/IfMatch"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/merge-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/AppointmentUpdate"
              },
              "example": {
                "starts_at": "2026-07-24T15:00:00+01:00",
                "team_member_id": 322
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated appointment.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "ETag": {
                "$ref": "#/components/headers/ETag"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Appointment"
                },
                "examples": {
                  "appointment": {
                    "$ref": "#/components/examples/AppointmentExample"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "412": {
            "$ref": "#/components/responses/PreconditionFailed"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "428": {
            "$ref": "#/components/responses/PreconditionRequired"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}/appointments/{appointment_id}/cancel": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        },
        {
          "$ref": "#/components/parameters/AppointmentId"
        }
      ],
      "post": {
        "operationId": "cancelAppointment",
        "summary": "Cancel an appointment",
        "description": "Cancels an appointment as a command: the response is the appointment with\n`status: \"cancelled\"` and `cancelled_at` set. Optionally stores a `reason` and\nwhether to notify the client.\n\nRequires `Idempotency-Key`. Cancelling an already cancelled appointment with the same\nkey is a no-op returning the same result.\n\nA cancelled appointment stays readable: `getAppointment` returns it with\n`status: \"cancelled\"` rather than `404`, and `listAppointments` keeps returning it, so a\nclient synchronising the journal sees the cancellation instead of silently losing the row.\nFilter on the `status` field to hide them. In a visit built from several appointments,\ncancelling one does not cancel the visit: the remaining appointments and any payments\nalready recorded stay, and `amount_to_pay_minor` is recomputed when the visit is read.\n",
        "tags": [
          "Appointments"
        ],
        "security": [
          {
            "OAuth2": [
              "appointments:write"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "planned",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AppointmentCancelRequest"
              },
              "example": {
                "reason": "client_request",
                "notify_client": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The cancelled appointment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Appointment"
                },
                "example": {
                  "id": 12345,
                  "object": "appointment",
                  "location_id": 4321,
                  "client_id": 789,
                  "visit_id": 5001,
                  "team_member_id": 321,
                  "service_ids": [
                    100
                  ],
                  "resource_instance_ids": [],
                  "status": "cancelled",
                  "starts_at": "2026-07-24T11:30:00+01:00",
                  "ends_at": "2026-07-24T12:30:00+01:00",
                  "duration_seconds": 3600,
                  "is_paid": false,
                  "comment": null,
                  "cancelled_at": "2026-07-22T05:15:00Z",
                  "cancellation_reason": "client_request",
                  "created_at": "2026-07-20T09:57:15Z",
                  "updated_at": "2026-07-22T05:15:00Z"
                }
              }
            },
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyConflict"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}/appointments/{appointment_id}/status": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        },
        {
          "$ref": "#/components/parameters/AppointmentId"
        }
      ],
      "post": {
        "operationId": "setAppointmentStatus",
        "summary": "Set appointment status",
        "description": "Moves an appointment through its status lifecycle: `waiting` → `confirmed` →\n`arrived` / `no_show`. Marking a past visit as `arrived` finalizes it when nothing\nis left to pay (a fully paid or free visit).\n\nRequires `Idempotency-Key`. Setting the status the appointment already has is a\nno-op returning the current state.\n\n\nThe appointment identifies the visit; the submitted status is applied to the whole visit and all of its appointments. The response shows the resulting appointment status. An appointment created without a client has no visit (`visit_id` is `null`), so the status applies to that appointment alone - there is nothing to widen to.",
        "tags": [
          "Appointments"
        ],
        "security": [
          {
            "OAuth2": [
              "appointments:write"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "planned",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AppointmentStatusRequest"
              },
              "example": {
                "status": "arrived"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The appointment with the new status.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Appointment"
                },
                "example": {
                  "id": 12345,
                  "object": "appointment",
                  "location_id": 4321,
                  "client_id": 789,
                  "visit_id": 5001,
                  "team_member_id": 321,
                  "service_ids": [
                    100
                  ],
                  "resource_instance_ids": [],
                  "status": "arrived",
                  "starts_at": "2026-07-24T11:30:00+01:00",
                  "ends_at": "2026-07-24T12:30:00+01:00",
                  "duration_seconds": 3600,
                  "is_paid": true,
                  "comment": null,
                  "cancelled_at": null,
                  "cancellation_reason": null,
                  "created_at": "2026-07-20T09:57:15Z",
                  "updated_at": "2026-07-24T13:05:00Z"
                }
              }
            },
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyConflict"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}/payment_methods": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        }
      ],
      "get": {
        "operationId": "listPaymentMethods",
        "summary": "List payment methods",
        "description": "Returns the payment methods configured for the Location - what the business accepts and how\neach method settles. This is the only source of `payment_method_id` for `createPayment`.\n\nIt does not say whether a method can pay a particular visit: read `visit.payment_methods`\nfor that, or `searchLoyaltyInstrument` for a gift card or membership held by number. Both\nreturn `ApplicablePaymentMethod`, a different shape from this one.\n\nCursor-paginated list. Default ordering: name, id tie-breaker. Cursors use the `cursor` query parameter, expire after one hour, and are bound to the credential, tenant, list, and filters. Expired, malformed, foreign, or re-filtered cursors fail with `422 validation_failed` using field codes `expired_cursor`, `invalid_cursor`, `foreign_cursor`, or `filter_changed`.",
        "tags": [
          "Payments"
        ],
        "security": [
          {
            "OAuth2": [
              "checkout:read"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "planned",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of payment methods.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentMethodList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "id": 71,
                      "object": "payment_method",
                      "slug": "card",
                      "name": "Bank card",
                      "default_account_id": 12,
                      "fee_rate": 1.5,
                      "card_brands": [
                        {
                          "id": 1,
                          "title": "Visa"
                        },
                        {
                          "id": 2,
                          "title": "Mastercard"
                        }
                      ],
                      "installments": []
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null
                }
              }
            },
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}/accounts": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        }
      ],
      "get": {
        "operationId": "listAccounts",
        "summary": "List accounts",
        "description": "Returns the cash/settlement accounts of the Location. Use an account's `id` as\n`account_id` in `createPayment` — either as the target of an `account` payment or as\nan override of a payment method's default account.\n\n\nCursor-paginated list. Default ordering: title, id tie-breaker. Cursors use the `cursor` query parameter, expire after one hour, and are bound to the credential, tenant, list, and filters. Expired, malformed, foreign, or re-filtered cursors fail with `422 validation_failed` using field codes `expired_cursor`, `invalid_cursor`, `foreign_cursor`, or `filter_changed`.",
        "tags": [
          "Payments"
        ],
        "security": [
          {
            "OAuth2": [
              "finance:read"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "planned",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of accounts.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "id": 12,
                      "object": "account",
                      "title": "Main cash desk",
                      "type_slug": "cash",
                      "is_acquiring": false
                    },
                    {
                      "id": 13,
                      "object": "account",
                      "title": "Acquiring",
                      "type_slug": "cashless",
                      "is_acquiring": true
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null
                }
              }
            },
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}/products": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        }
      ],
      "get": {
        "operationId": "listProducts",
        "summary": "List products",
        "description": "Returns the minimal product catalog fields available in P0: `id`, `title`,\n`price_minor`, and `unit`. Inventory levels, balances, cost, and standalone product\nsales are not part of the preview scope.\n\nCursor-paginated list. Default ordering: title, id tie-breaker. Cursors use the `cursor` query parameter, expire after one hour, and are bound to the credential, tenant, list, and filters. Expired, malformed, foreign, or re-filtered cursors fail with `422 validation_failed` using field codes `expired_cursor`, `invalid_cursor`, `foreign_cursor`, or `filter_changed`.",
        "tags": [
          "Products"
        ],
        "security": [
          {
            "OAuth2": [
              "products:read"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "planned",
        "parameters": [
          {
            "$ref": "#/components/parameters/Query"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductList"
                }
              }
            },
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "412": {
            "$ref": "#/components/responses/PreconditionFailed"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "428": {
            "$ref": "#/components/responses/PreconditionRequired"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}/appointments/{appointment_id}/payment_methods/search": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        },
        {
          "$ref": "#/components/parameters/AppointmentId"
        }
      ],
      "get": {
        "operationId": "searchLoyaltyInstrument",
        "summary": "Find a gift card or membership by number",
        "description": "Looks up a gift card or membership by its number and reports whether it can pay the visit\nresolved from `appointment_id`.\n\nThis is for instruments the client does not hold in Altegio: a gift card received as a\npresent, or a membership bought at another location of the chain. Instruments already\nattached to the client come back from `getVisit` in `payment_methods` and need no search.\nResults carry the same applicability fields, so both are passed to `createPayment` the\nsame way.\n\n**Anti-enumeration:** unknown, foreign-tenant, expired, and not-applicable numbers share one\nclient-visible outcome — empty result or `422 instrument_not_applicable` — and never distinct\ncodes that would reveal whether a number exists elsewhere. This search and number-bearing\n`createPayment` attempts share a per-credential, per-Location rate limit (`429` +\n`Retry-After`).",
        "tags": [
          "Payments"
        ],
        "security": [
          {
            "OAuth2": [
              "loyalty:read"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "planned",
        "parameters": [
          {
            "$ref": "#/components/parameters/Number"
          },
          {
            "$ref": "#/components/parameters/LoyaltyInstrumentType"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApplicablePaymentMethodList"
                }
              }
            },
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "412": {
            "$ref": "#/components/responses/PreconditionFailed"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "428": {
            "$ref": "#/components/responses/PreconditionRequired"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}/appointments/{appointment_id}/visit": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        },
        {
          "$ref": "#/components/parameters/AppointmentId"
        }
      ],
      "get": {
        "operationId": "getVisit",
        "summary": "Get the visit for an appointment",
        "description": "Returns the billing state resolved from `appointment_id`: service and products, payment methods applicable to this visit, payments from money and loyalty sources, and `amount_to_pay_minor`. `visit_id` remains a response field but is not a path key because appointments without a client may not have a visit id while still being payable. The first call may materialize the billing document; repeated calls resolve to the same document.",
        "tags": [
          "Visits"
        ],
        "security": [
          {
            "OAuth2": [
              "appointments:read"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "planned",
        "parameters": [
          {
            "$ref": "#/components/parameters/IncludeVisit"
          }
        ],
        "responses": {
          "200": {
            "description": "The visit.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Visit"
                },
                "examples": {
                  "visit": {
                    "$ref": "#/components/examples/VisitExample"
                  }
                }
              }
            },
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}/appointments/{appointment_id}/visit/items": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        },
        {
          "$ref": "#/components/parameters/AppointmentId"
        }
      ],
      "post": {
        "operationId": "addVisitItem",
        "summary": "Add a product line to the appointment's visit",
        "description": "Adds one product line to the visit resolved from `appointment_id` — the \"came for a haircut,\nbought shampoo, one receipt\" case.\n\nEach call appends a single line and never replaces the existing ones, so a client that does not\nknow about lines added elsewhere cannot remove them. Service lines are derived from the\nappointment itself and cannot be created here. Adding a line increases `amount_to_pay_minor`\nand changes the visit ETag. Inventory levels are not checked — the product catalog and inventory\nare outside this contract. Requires `Idempotency-Key`; a retry returns the visit as it stood\nafter the first call instead of adding the line twice.",
        "tags": [
          "Visits"
        ],
        "security": [
          {
            "OAuth2": [
              "inventory:sell"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "planned",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VisitItemCreate"
              },
              "examples": {
                "product": {
                  "summary": "Add one product to the visit",
                  "value": {
                    "product_id": 4417,
                    "quantity": 1
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The updated visit, including the new line.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Visit"
                },
                "examples": {
                  "visit": {
                    "$ref": "#/components/examples/VisitExample"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "description": "The line cannot be added. Stable codes: `visit_already_settled` (the visit is fully paid, so adding a line would leave a settled visit with an unpaid remainder), `idempotency_key_reused`, `idempotency_request_in_progress`.\n",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}/appointments/{appointment_id}/payments": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        },
        {
          "$ref": "#/components/parameters/AppointmentId"
        }
      ],
      "post": {
        "operationId": "createPayment",
        "summary": "Record a payment on the appointment's visit",
        "description": "Records a money, Client Account, loyalty, gift card, membership, or referral-program payment against the visit resolved from `appointment_id`. This records that payment was received (cash, card terminal, cashless, or a loyalty instrument) — Altegio does not move funds through a payment provider on this call. `amount_minor` must not exceed `amount_to_pay_minor`; for `membership`, `amount_minor` is `0` and coverage is reported through `covers_items`. Gift card and membership addressed by `number` use the same anti-enumeration policy as `searchLoyaltyInstrument` (`422 instrument_not_applicable`, shared rate limit). Requires `Idempotency-Key`; a retry returns the original payment instead of recording it twice. A free visit (`amount_to_pay_minor` is `0`) needs no payment; finalize it through `setAppointmentStatus`.",
        "tags": [
          "Payments"
        ],
        "security": [
          {
            "OAuth2": [
              "checkout:capture"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "planned",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PaymentCreate"
              },
              "examples": {
                "cardViaMethod": {
                  "summary": "Card payment via a configured method",
                  "value": {
                    "type": "payment_method",
                    "payment_method_id": 71,
                    "account_id": 13,
                    "amount_minor": 250000,
                    "card_brand_id": 1
                  }
                },
                "directToAccount": {
                  "summary": "Direct payment to an account",
                  "value": {
                    "type": "account",
                    "account_id": 12,
                    "amount_minor": 100000
                  }
                },
                "membershipByNumber": {
                  "summary": "Spend a membership session (no amount - sessions, not money)",
                  "value": {
                    "type": "membership",
                    "number": "472671"
                  }
                },
                "membershipWithoutCode": {
                  "summary": "Spend a membership that carries no code",
                  "value": {
                    "type": "membership",
                    "membership_id": 5298007
                  }
                },
                "depositPartial": {
                  "summary": "Part of the amount from a Client Account",
                  "value": {
                    "type": "deposit",
                    "deposit_id": 862771,
                    "amount_minor": 900
                  }
                },
                "referralProgram": {
                  "summary": "Apply one of the referral programs the client is eligible for",
                  "value": {
                    "type": "referral_program",
                    "referral_program_id": 30411,
                    "referrer_phone": "+5511999999999",
                    "amount_minor": 900
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The registered payment.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "Location": {
                "$ref": "#/components/headers/Location"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payment"
                },
                "examples": {
                  "payment": {
                    "$ref": "#/components/examples/PaymentExample"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyConflict"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "description": "Validation failed, amount exceeds unpaid remainder (`exceeds_unpaid`), or a number-addressed loyalty instrument is not usable (`instrument_not_applicable`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "examples": {
                  "exceeds_unpaid": {
                    "summary": "Amount exceeds the unpaid remainder",
                    "value": {
                      "type": "https://developer.alteg.io/problems/exceeds-unpaid",
                      "title": "Payment exceeds unpaid amount",
                      "status": 422,
                      "detail": "The payment amount is greater than the remaining unpaid amount of the visit.",
                      "instance": "urn:altegio:request:req_v2x7",
                      "code": "exceeds_unpaid"
                    }
                  },
                  "instrument_not_applicable": {
                    "summary": "Loyalty instrument not usable for this visit",
                    "value": {
                      "type": "https://developer.alteg.io/problems/instrument-not-applicable",
                      "title": "Instrument not applicable",
                      "status": 422,
                      "detail": "The gift card or membership cannot be applied to this visit.",
                      "instance": "urn:altegio:request:req_v2x8",
                      "code": "instrument_not_applicable"
                    }
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/locations/{location_id}/appointments/{appointment_id}/payments/{payment_id}/cancel": {
      "parameters": [
        {
          "$ref": "#/components/parameters/LocationId"
        },
        {
          "$ref": "#/components/parameters/PaymentId"
        },
        {
          "$ref": "#/components/parameters/AppointmentId"
        }
      ],
      "post": {
        "operationId": "cancelPayment",
        "summary": "Cancel a recorded payment",
        "description": "Locally reverses one payment action in full for the visit resolved from `appointment_id`.\nPartial reversal is not part of the contract. This is a local cancellation of posting in\nAltegio, not a payment-provider refund. Requires `Idempotency-Key`.\n\nNo step-up confirmation is part of this preview contract. Refund authorization is the\nexplicit `checkout:cancel` scope plus the subject's finance permission, with idempotency\nand audit on every call. A future human-confirmation flow will be added only with a\ncomplete challenge contract.\n",
        "tags": [
          "Payments"
        ],
        "security": [
          {
            "OAuth2": [
              "checkout:cancel"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "planned",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "The payment after local reversal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payment"
                },
                "example": {
                  "id": "t9001",
                  "object": "payment",
                  "visit_id": 5001,
                  "type": "payment_method",
                  "payment_method_id": 71,
                  "account_id": 13,
                  "amount_minor": 250000,
                  "fee_minor": 2500,
                  "currency": "EUR",
                  "card_brand_id": 1,
                  "installment_count": null,
                  "status": "refunded",
                  "covers_items": [],
                  "refund": {
                    "id": "t9001",
                    "object": "refund",
                    "payment_id": "t9001",
                    "amount_minor": 250000,
                    "created_at": "2026-07-24T14:10:00Z"
                  },
                  "created_at": "2026-07-24T13:00:00Z"
                }
              }
            },
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyConflict"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/developers/{developer_id}/marketplace_apps": {
      "parameters": [
        {
          "$ref": "#/components/parameters/DeveloperId"
        }
      ],
      "get": {
        "operationId": "listMarketplaceApps",
        "summary": "List marketplace applications",
        "description": "Returns the V3 marketplace applications of the developer account. Applications built for the previous\nmarketplace API are not listed here.\n\nThe caller must be a member of developer account `developer_id`; another account, or an application that does not belong to this account, responds with `404`.\n\nCursor-paginated list. Default ordering: `id` ascending. Cursors use the `cursor` query parameter, expire after one hour, and are bound to the credential, list, and filters. Expired, malformed, foreign, or re-filtered cursors fail with `422 validation_failed` using field codes `expired_cursor`, `invalid_cursor`, `foreign_cursor`, or `filter_changed`.",
        "tags": [
          "Apps"
        ],
        "security": [
          {
            "OAuth2": [
              "marketplace_apps:read"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of marketplace applications.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MarketplaceAppList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "id": 48213,
                      "object": "marketplace_app",
                      "title": "Smart Reminders",
                      "description": "Appointment reminders by SMS and WhatsApp.",
                      "capabilities": [
                        "api",
                        "page"
                      ],
                      "scopes": [
                        "appointments:read",
                        "clients:read",
                        "services:read"
                      ],
                      "webhook_url": "https://your-app.example/altegio/webhooks",
                      "setup_url": "https://your-app.example/altegio/setup",
                      "setup_mode": "tab",
                      "install_url": "https://app.alteg.io/marketplace/install/48213",
                      "oauth_client": {
                        "client_id": "ag_client_a7f3c2e15b9d4e8a9c216f0d3b7e4a18",
                        "secret_issued_at": "2026-11-05T09:05:00Z"
                      },
                      "readiness": {
                        "is_ready": true,
                        "reasons": []
                      },
                      "publication_status": "draft",
                      "recommendations": [],
                      "created_at": "2026-11-05T09:00:00Z"
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      },
      "post": {
        "operationId": "createMarketplaceApp",
        "summary": "Create a marketplace application",
        "description": "Creates a V3 marketplace application together with its OAuth client.\n\nThe new application has no scopes (`scopes: []`, no API access) and no publication card. Its OAuth client has\nno secret yet: `oauth_client.secret_issued_at` is `null`, and `POST /oauth/token` answers `invalid_client` until\nthe secret is issued in the Developer Hub, where it is shown exactly once. The category of the marketplace card\nis chosen later in the publication.\n\nThe caller must be a member of developer account `developer_id`; another account, or an application that does not belong to this account, responds with `404`.",
        "tags": [
          "Apps"
        ],
        "security": [
          {
            "OAuth2": [
              "marketplace_apps:write"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MarketplaceAppCreate"
              },
              "example": {
                "title": "Smart Reminders",
                "description": "Appointment reminders by SMS and WhatsApp.",
                "capabilities": [
                  "api",
                  "page"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The created marketplace application.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "Location": {
                "$ref": "#/components/headers/Location"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MarketplaceApp"
                },
                "example": {
                  "id": 48213,
                  "object": "marketplace_app",
                  "title": "Smart Reminders",
                  "description": "Appointment reminders by SMS and WhatsApp.",
                  "capabilities": [
                    "api",
                    "page"
                  ],
                  "scopes": [],
                  "webhook_url": null,
                  "setup_url": null,
                  "setup_mode": "tab",
                  "install_url": "https://app.alteg.io/marketplace/install/48213",
                  "oauth_client": {
                    "client_id": "ag_client_a7f3c2e15b9d4e8a9c216f0d3b7e4a18",
                    "secret_issued_at": null
                  },
                  "readiness": {
                    "is_ready": false,
                    "reasons": [
                      "webhook_url_missing"
                    ]
                  },
                  "publication_status": "none",
                  "recommendations": [],
                  "created_at": "2026-11-05T09:00:00Z"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/developers/{developer_id}/marketplace_apps/{marketplace_app_id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/DeveloperId"
        },
        {
          "$ref": "#/components/parameters/MarketplaceAppId"
        }
      ],
      "get": {
        "operationId": "getMarketplaceApp",
        "summary": "Get a marketplace application",
        "description": "Returns the marketplace application card: its scopes, webhook and setup addresses, install link, OAuth\nclient without the secret, readiness, publication status, and hints for the overview screen.\n\nThe caller must be a member of developer account `developer_id`; another account, or an application that does not belong to this account, responds with `404`.",
        "tags": [
          "Apps"
        ],
        "security": [
          {
            "OAuth2": [
              "marketplace_apps:read"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "responses": {
          "200": {
            "description": "The marketplace application.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MarketplaceApp"
                },
                "example": {
                  "id": 48213,
                  "object": "marketplace_app",
                  "title": "Smart Reminders",
                  "description": "Appointment reminders by SMS and WhatsApp.",
                  "capabilities": [
                    "api",
                    "page"
                  ],
                  "scopes": [
                    "appointments:read",
                    "clients:read",
                    "services:read"
                  ],
                  "webhook_url": "https://your-app.example/altegio/webhooks",
                  "setup_url": "https://your-app.example/altegio/setup",
                  "setup_mode": "tab",
                  "install_url": "https://app.alteg.io/marketplace/install/48213",
                  "oauth_client": {
                    "client_id": "ag_client_a7f3c2e15b9d4e8a9c216f0d3b7e4a18",
                    "secret_issued_at": "2026-11-05T09:05:00Z"
                  },
                  "readiness": {
                    "is_ready": true,
                    "reasons": []
                  },
                  "publication_status": "draft",
                  "recommendations": [
                    {
                      "code": "interfaces_disabled",
                      "capability": "page"
                    }
                  ],
                  "created_at": "2026-11-05T09:00:00Z"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      },
      "patch": {
        "operationId": "updateMarketplaceApp",
        "summary": "Update a marketplace application",
        "description": "Partially updates the application with a merge-patch body: details, capabilities, the setup page and the\nwebhook address. Scopes are not part of this body; replace them with `PUT …/scopes`.\n\nThe caller must be a member of developer account `developer_id`; another account, or an application that does not belong to this account, responds with `404`.",
        "tags": [
          "Apps"
        ],
        "security": [
          {
            "OAuth2": [
              "marketplace_apps:write"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "requestBody": {
          "required": true,
          "content": {
            "application/merge-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/MarketplaceAppUpdate"
              },
              "example": {
                "setup_url": "https://your-app.example/altegio/setup",
                "setup_mode": "tab",
                "webhook_url": "https://your-app.example/altegio/webhooks"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated marketplace application.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MarketplaceApp"
                },
                "example": {
                  "id": 48213,
                  "object": "marketplace_app",
                  "title": "Smart Reminders",
                  "description": "Appointment reminders by SMS and WhatsApp.",
                  "capabilities": [
                    "api",
                    "page"
                  ],
                  "scopes": [
                    "appointments:read",
                    "clients:read",
                    "services:read"
                  ],
                  "webhook_url": "https://your-app.example/altegio/webhooks",
                  "setup_url": "https://your-app.example/altegio/setup",
                  "setup_mode": "tab",
                  "install_url": "https://app.alteg.io/marketplace/install/48213",
                  "oauth_client": {
                    "client_id": "ag_client_a7f3c2e15b9d4e8a9c216f0d3b7e4a18",
                    "secret_issued_at": "2026-11-05T09:05:00Z"
                  },
                  "readiness": {
                    "is_ready": true,
                    "reasons": []
                  },
                  "publication_status": "draft",
                  "recommendations": [],
                  "created_at": "2026-11-05T09:00:00Z"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/developers/{developer_id}/marketplace_apps/{marketplace_app_id}/scopes": {
      "parameters": [
        {
          "$ref": "#/components/parameters/DeveloperId"
        },
        {
          "$ref": "#/components/parameters/MarketplaceAppId"
        }
      ],
      "put": {
        "operationId": "updateMarketplaceAppScopes",
        "summary": "Replace the scopes of a marketplace application",
        "description": "Replaces the full set of scopes the application requests at installation. An empty array means \"no API\naccess\": the application can still be installed, but its installation tokens are refused with `invalid_grant`.\n\nNarrowing takes effect at once: the removed scopes are revoked from every live installation. Widening does not\nreach live installations: a Location receives the new scopes when the business installs the application again.\n\nAllowed values are the codes from `GET /marketplace_app_scopes`. A scope an application cannot hold (for example\n`chain_access:manage` or `marketplace_apps:read`) fails with `422 validation_failed` and field code\n`unsupported_scope`; an unknown code fails with field code `invalid_value`.\n\nThe caller must be a member of developer account `developer_id`; another account, or an application that does not belong to this account, responds with `404`.",
        "tags": [
          "Apps"
        ],
        "security": [
          {
            "OAuth2": [
              "marketplace_apps:write"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MarketplaceAppScopesUpdate"
              },
              "example": {
                "scopes": [
                  "appointments:read",
                  "clients:read",
                  "services:read"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The marketplace application with the new scopes.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MarketplaceApp"
                },
                "example": {
                  "id": 48213,
                  "object": "marketplace_app",
                  "title": "Smart Reminders",
                  "description": "Appointment reminders by SMS and WhatsApp.",
                  "capabilities": [
                    "api",
                    "page"
                  ],
                  "scopes": [
                    "appointments:read",
                    "clients:read",
                    "services:read"
                  ],
                  "webhook_url": "https://your-app.example/altegio/webhooks",
                  "setup_url": "https://your-app.example/altegio/setup",
                  "setup_mode": "tab",
                  "install_url": "https://app.alteg.io/marketplace/install/48213",
                  "oauth_client": {
                    "client_id": "ag_client_a7f3c2e15b9d4e8a9c216f0d3b7e4a18",
                    "secret_issued_at": "2026-11-05T09:05:00Z"
                  },
                  "readiness": {
                    "is_ready": true,
                    "reasons": []
                  },
                  "publication_status": "draft",
                  "recommendations": [],
                  "created_at": "2026-11-05T09:00:00Z"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "description": "Validation failed (`validation_failed`). A scope the application cannot hold is reported as `unsupported_scope` at `/scopes/{index}`.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "https://developer.alteg.io/problems/validation-error",
                  "title": "Request validation failed",
                  "status": 422,
                  "detail": "One or more fields are invalid.",
                  "instance": "urn:altegio:request:req_422m",
                  "code": "validation_failed",
                  "errors": [
                    {
                      "code": "unsupported_scope",
                      "source": "body",
                      "pointer": "/scopes/1",
                      "message": "chain_access:manage is not available to a marketplace application."
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/marketplace_app_scopes": {
      "get": {
        "operationId": "getMarketplaceAppScopeCatalog",
        "summary": "Get the scope catalog for marketplace applications",
        "description": "Returns the Location scopes a marketplace application may request, grouped the same way as the API key\ncatalog. Titles, hints and notes are localized strings, not translation keys. Scopes that are never granted to an\napplication (chain scopes, `marketplace_apps:*`, scopes that hand out access to people) are not listed.\n\nThe scopes an application has selected are the `scopes` field of the application.",
        "tags": [
          "Apps"
        ],
        "security": [
          {
            "OAuth2": [
              "marketplace_apps:read"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "responses": {
          "200": {
            "description": "The scope catalog.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MarketplaceAppScopeCatalog"
                },
                "example": {
                  "object": "scope_catalog",
                  "groups": [
                    {
                      "code": "appointments",
                      "title": "Appointments",
                      "hint": "Calendar, appointment cards, reschedules and cancellations.",
                      "marks": [],
                      "scopes": [
                        {
                          "code": "appointments:read",
                          "title": "View appointments",
                          "note": null,
                          "operation_type": "read",
                          "marks": [],
                          "implies": []
                        },
                        {
                          "code": "appointments:create",
                          "title": "Create appointments",
                          "note": null,
                          "operation_type": "write",
                          "marks": [
                            "data_change"
                          ],
                          "implies": []
                        },
                        {
                          "code": "appointments:write",
                          "title": "Edit appointments",
                          "note": null,
                          "operation_type": "write",
                          "marks": [
                            "data_change"
                          ],
                          "implies": [
                            "appointments:read"
                          ]
                        }
                      ]
                    },
                    {
                      "code": "clients",
                      "title": "Clients",
                      "hint": "Client cards, tags, comments and files.",
                      "marks": [],
                      "scopes": [
                        {
                          "code": "clients:read",
                          "title": "View clients",
                          "note": "Without phone numbers and email",
                          "operation_type": "read",
                          "marks": [],
                          "implies": []
                        },
                        {
                          "code": "clients:read_contact",
                          "title": "Phone numbers and email",
                          "note": "Together with \"View clients\"",
                          "operation_type": "read",
                          "marks": [
                            "personal_data"
                          ],
                          "implies": []
                        }
                      ]
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/developers/{developer_id}/marketplace_apps/{marketplace_app_id}/publication": {
      "parameters": [
        {
          "$ref": "#/components/parameters/DeveloperId"
        },
        {
          "$ref": "#/components/parameters/MarketplaceAppId"
        }
      ],
      "post": {
        "operationId": "createMarketplaceAppPublication",
        "summary": "Create the publication card",
        "description": "Creates the marketplace card of the application with its first successful save. The body is the first saved\nsection of the card and accepts the same fields as `PATCH`. An empty or invalid body fails with `422` and\ncreates nothing; when the card already exists the call fails with `409 conflict`.\n\nField errors in `errors[]`: `slug_taken` at `/slug`; `unsupported_category` at `/category_id` for the\n`telephony` category, which V3 applications cannot use; `invalid_value` for an unknown or inactive category and other\ninvalid values.\n\nTranslations of the card are edited in the Developer Hub in this preview.\n\nThe caller must be a member of developer account `developer_id`; another account, or an application that does not belong to this account, responds with `404`.",
        "tags": [
          "Publication"
        ],
        "security": [
          {
            "OAuth2": [
              "marketplace_apps:write"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MarketplaceAppPublicationCreate"
              },
              "example": {
                "slug": "smartreminders",
                "category_id": 10,
                "country_ids": [
                  43,
                  55
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The created publication card.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "Location": {
                "$ref": "#/components/headers/Location"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MarketplaceAppPublication"
                },
                "example": {
                  "object": "publication",
                  "marketplace_app_id": 48213,
                  "status": "draft",
                  "logo_url": null,
                  "slug": "smartreminders",
                  "website_url": "https://smart-tools.example",
                  "category_id": 10,
                  "functionalities": [],
                  "country_ids": [
                    43,
                    55
                  ],
                  "monetization_type": "paid",
                  "price": "19 EUR per month",
                  "trial_days": 14,
                  "moderator_connect_instruction": "Install the app, open Settings and connect your WhatsApp number.",
                  "moderator_payment_instruction": null,
                  "readiness": {
                    "is_ready": false,
                    "sections": [
                      {
                        "code": "details",
                        "status": "ok",
                        "issues": []
                      },
                      {
                        "code": "description_en",
                        "status": "fix",
                        "issues": [
                          {
                            "field": "short_description",
                            "locale_id": 2,
                            "message": "From 3 to 70 characters."
                          }
                        ]
                      },
                      {
                        "code": "translations",
                        "status": "blocks",
                        "issues": [
                          {
                            "field": null,
                            "locale_id": 35,
                            "message": "Required language is missing: Portuguese for Portugal."
                          }
                        ]
                      },
                      {
                        "code": "connection",
                        "status": "ok",
                        "issues": []
                      },
                      {
                        "code": "developer_profile",
                        "status": "ok",
                        "issues": []
                      }
                    ]
                  },
                  "moderation_started_at": null,
                  "moderated_at": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "description": "A publication card already exists for this application (`conflict`); change it with `PATCH`.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "https://developer.alteg.io/problems/conflict",
                  "title": "Conflict",
                  "status": 409,
                  "detail": "The publication card of this application already exists.",
                  "instance": "urn:altegio:request:req_409p",
                  "code": "conflict"
                }
              }
            }
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "description": "Validation failed (`validation_failed`); field-level details are in `errors[]`.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "https://developer.alteg.io/problems/validation-error",
                  "title": "Request validation failed",
                  "status": 422,
                  "detail": "One or more fields are invalid.",
                  "instance": "urn:altegio:request:req_422p",
                  "code": "validation_failed",
                  "errors": [
                    {
                      "code": "slug_taken",
                      "source": "body",
                      "pointer": "/slug",
                      "message": "This identifier is already used by another application."
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      },
      "get": {
        "operationId": "getMarketplaceAppPublication",
        "summary": "Get the publication card",
        "description": "Returns the marketplace card of the application with its moderation status and readiness for submission.\nBefore the card is created (`publication_status: none` on the application) the call responds with `404`.\n\nThe caller must be a member of developer account `developer_id`; another account, or an application that does not belong to this account, responds with `404`.",
        "tags": [
          "Publication"
        ],
        "security": [
          {
            "OAuth2": [
              "marketplace_apps:read"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "responses": {
          "200": {
            "description": "The publication card.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MarketplaceAppPublication"
                },
                "example": {
                  "object": "publication",
                  "marketplace_app_id": 48213,
                  "status": "draft",
                  "logo_url": null,
                  "slug": "smartreminders",
                  "website_url": "https://smart-tools.example",
                  "category_id": 10,
                  "functionalities": [],
                  "country_ids": [
                    43,
                    55
                  ],
                  "monetization_type": "paid",
                  "price": "19 EUR per month",
                  "trial_days": 14,
                  "moderator_connect_instruction": "Install the app, open Settings and connect your WhatsApp number.",
                  "moderator_payment_instruction": null,
                  "readiness": {
                    "is_ready": false,
                    "sections": [
                      {
                        "code": "details",
                        "status": "ok",
                        "issues": []
                      },
                      {
                        "code": "description_en",
                        "status": "fix",
                        "issues": [
                          {
                            "field": "short_description",
                            "locale_id": 2,
                            "message": "From 3 to 70 characters."
                          }
                        ]
                      },
                      {
                        "code": "translations",
                        "status": "blocks",
                        "issues": [
                          {
                            "field": null,
                            "locale_id": 35,
                            "message": "Required language is missing: Portuguese for Portugal."
                          }
                        ]
                      },
                      {
                        "code": "connection",
                        "status": "ok",
                        "issues": []
                      },
                      {
                        "code": "developer_profile",
                        "status": "ok",
                        "issues": []
                      }
                    ]
                  },
                  "moderation_started_at": null,
                  "moderated_at": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      },
      "patch": {
        "operationId": "updateMarketplaceAppPublication",
        "summary": "Update the publication card",
        "description": "Partially updates the marketplace card with a merge-patch body. The card can be edited on moderation and\nafter publication; the moderator sees the current version. Only `country_ids` become read-only once the card has\nbeen submitted.\n\nField errors in `errors[]`: `slug_taken` at `/slug`; `field_immutable` at `/country_ids` after the card was\nsubmitted for moderation; `unsupported_category` at `/category_id` for the `telephony`\ncategory, which V3 applications cannot use; `invalid_value` for an unknown or inactive category and other\ninvalid values.\n\nThe caller must be a member of developer account `developer_id`; another account, or an application that does not belong to this account, responds with `404`.",
        "tags": [
          "Publication"
        ],
        "security": [
          {
            "OAuth2": [
              "marketplace_apps:write"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "requestBody": {
          "required": true,
          "content": {
            "application/merge-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/MarketplaceAppPublicationUpdate"
              },
              "example": {
                "monetization_type": "paid",
                "price": "19 EUR per month",
                "trial_days": 14
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated publication card.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MarketplaceAppPublication"
                },
                "example": {
                  "object": "publication",
                  "marketplace_app_id": 48213,
                  "status": "draft",
                  "logo_url": null,
                  "slug": "smartreminders",
                  "website_url": "https://smart-tools.example",
                  "category_id": 10,
                  "functionalities": [],
                  "country_ids": [
                    43,
                    55
                  ],
                  "monetization_type": "paid",
                  "price": "19 EUR per month",
                  "trial_days": 14,
                  "moderator_connect_instruction": "Install the app, open Settings and connect your WhatsApp number.",
                  "moderator_payment_instruction": null,
                  "readiness": {
                    "is_ready": false,
                    "sections": [
                      {
                        "code": "details",
                        "status": "ok",
                        "issues": []
                      },
                      {
                        "code": "description_en",
                        "status": "fix",
                        "issues": [
                          {
                            "field": "short_description",
                            "locale_id": 2,
                            "message": "From 3 to 70 characters."
                          }
                        ]
                      },
                      {
                        "code": "translations",
                        "status": "blocks",
                        "issues": [
                          {
                            "field": null,
                            "locale_id": 35,
                            "message": "Required language is missing: Portuguese for Portugal."
                          }
                        ]
                      },
                      {
                        "code": "connection",
                        "status": "ok",
                        "issues": []
                      },
                      {
                        "code": "developer_profile",
                        "status": "ok",
                        "issues": []
                      }
                    ]
                  },
                  "moderation_started_at": null,
                  "moderated_at": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "description": "Validation failed (`validation_failed`); field-level details are in `errors[]`.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "https://developer.alteg.io/problems/validation-error",
                  "title": "Request validation failed",
                  "status": 422,
                  "detail": "One or more fields are invalid.",
                  "instance": "urn:altegio:request:req_422p",
                  "code": "validation_failed",
                  "errors": [
                    {
                      "code": "slug_taken",
                      "source": "body",
                      "pointer": "/slug",
                      "message": "This identifier is already used by another application."
                    },
                    {
                      "code": "field_immutable",
                      "source": "body",
                      "pointer": "/country_ids",
                      "message": "Countries cannot change after the publication was submitted for moderation."
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/developers/{developer_id}/marketplace_apps/{marketplace_app_id}/publication/submit": {
      "parameters": [
        {
          "$ref": "#/components/parameters/DeveloperId"
        },
        {
          "$ref": "#/components/parameters/MarketplaceAppId"
        }
      ],
      "post": {
        "operationId": "submitMarketplaceAppPublication",
        "summary": "Submit the publication for moderation",
        "description": "Sends the card to moderation and returns it with `status: moderation`. The card must be complete: the English\ndescription, every language required by the selected countries, an active category and the developer profile.\nAn incomplete card fails with `422 validation_failed` without `errors[]`, because the call has no body: the\nblocking items are the issues in `readiness.sections` of the card. A card that is already on moderation fails\nwith `409 conflict`.\n\nThe caller must be a member of developer account `developer_id`; another account, or an application that does not belong to this account, responds with `404`.",
        "tags": [
          "Publication"
        ],
        "security": [
          {
            "OAuth2": [
              "marketplace_apps:write"
            ]
          },
          {
            "ApiKey": []
          }
        ],
        "x-altegio-status": "preview",
        "responses": {
          "200": {
            "description": "The publication card on moderation.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MarketplaceAppPublication"
                },
                "example": {
                  "object": "publication",
                  "marketplace_app_id": 48213,
                  "status": "moderation",
                  "logo_url": null,
                  "slug": "smartreminders",
                  "website_url": "https://smart-tools.example",
                  "category_id": 10,
                  "functionalities": [],
                  "country_ids": [
                    43,
                    55
                  ],
                  "monetization_type": "paid",
                  "price": "19 EUR per month",
                  "trial_days": 14,
                  "moderator_connect_instruction": "Install the app, open Settings and connect your WhatsApp number.",
                  "moderator_payment_instruction": null,
                  "readiness": {
                    "is_ready": true,
                    "sections": [
                      {
                        "code": "details",
                        "status": "ok",
                        "issues": []
                      },
                      {
                        "code": "description_en",
                        "status": "ok",
                        "issues": []
                      },
                      {
                        "code": "translations",
                        "status": "ok",
                        "issues": []
                      },
                      {
                        "code": "connection",
                        "status": "ok",
                        "issues": []
                      },
                      {
                        "code": "developer_profile",
                        "status": "ok",
                        "issues": []
                      }
                    ]
                  },
                  "moderation_started_at": "2026-11-21T10:00:00Z",
                  "moderated_at": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "description": "The publication is already on moderation (`conflict`).",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "https://developer.alteg.io/problems/conflict",
                  "title": "Conflict",
                  "status": 409,
                  "detail": "The publication is already on moderation.",
                  "instance": "urn:altegio:request:req_409s",
                  "code": "conflict"
                }
              }
            }
          },
          "422": {
            "description": "The card is not ready for moderation (`validation_failed`, no `errors[]`); the blocking items are in `readiness.sections` of the card.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "https://developer.alteg.io/problems/validation-error",
                  "title": "Request validation failed",
                  "status": 422,
                  "detail": "The publication is not ready for moderation; see readiness of the card.",
                  "instance": "urn:altegio:request:req_422s",
                  "code": "validation_failed"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/marketplace_apps/{marketplace_app_id}/installations": {
      "parameters": [
        {
          "$ref": "#/components/parameters/MarketplaceAppId"
        }
      ],
      "get": {
        "operationId": "listMarketplaceAppInstallations",
        "summary": "List installations of your application",
        "description": "Returns the installations of your application. Use it to reconcile state when a webhook was lost. Deleted\ninstallations are not returned.\n\nCall it with the **application token**: `POST /oauth/token` with `grant_type=client_credentials` and no `location_id`. The `marketplace_app_id` in the path must be the application the token was issued to; any other id responds with `404`. No scope is required.\n\nCursor-paginated list. Default ordering: `id` ascending. Cursors use the `cursor` query parameter, expire after one hour, and are bound to the credential, list, and filters. Expired, malformed, foreign, or re-filtered cursors fail with `422 validation_failed` using field codes `expired_cursor`, `invalid_cursor`, `foreign_cursor`, or `filter_changed`.",
        "tags": [
          "Installations"
        ],
        "security": [
          {
            "OAuth2": []
          }
        ],
        "x-altegio-status": "preview",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "$ref": "#/components/parameters/InstallationStatus"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of installations.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MarketplaceAppInstallationList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "id": 9001,
                      "object": "installation",
                      "marketplace_app_id": 48213,
                      "location_id": 90211,
                      "status": "active",
                      "installed_at": "2026-11-20T09:12:00Z",
                      "scopes": [
                        "appointments:read",
                        "clients:read"
                      ]
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/marketplace_apps/{marketplace_app_id}/installations/{location_id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/MarketplaceAppId"
        },
        {
          "$ref": "#/components/parameters/InstallationLocationId"
        }
      ],
      "get": {
        "operationId": "getMarketplaceAppInstallation",
        "summary": "Get the installation in a Location",
        "description": "Returns the installation of your application in the Location: `pending` while the business finishes setup on\nyour page, `active` after you activated it, `frozen` while the application is unpaid. Without an installation in\nthis Location the call fails with `404 installation_not_found`.\n\nCall it with the **application token**: `POST /oauth/token` with `grant_type=client_credentials` and no `location_id`. The `marketplace_app_id` in the path must be the application the token was issued to; any other id responds with `404`. No scope is required.",
        "tags": [
          "Installations"
        ],
        "security": [
          {
            "OAuth2": []
          }
        ],
        "x-altegio-status": "preview",
        "responses": {
          "200": {
            "description": "The installation.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MarketplaceAppInstallation"
                },
                "example": {
                  "id": 9001,
                  "object": "installation",
                  "marketplace_app_id": 48213,
                  "location_id": 90211,
                  "status": "active",
                  "installed_at": "2026-11-20T09:12:00Z",
                  "scopes": [
                    "appointments:read",
                    "clients:read"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/InstallationNotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      },
      "delete": {
        "operationId": "deleteMarketplaceAppInstallation",
        "summary": "Uninstall your application from a Location",
        "description": "Uninstalls your application from the Location, exactly as when the business removes it: the scopes are revoked,\ninstallation tokens for the Location stop working, and `installation.deleted` is sent. Recorded payments stay in history. A repeated\ncall fails with `404 installation_not_found`.\n\nCall it with the **application token**: `POST /oauth/token` with `grant_type=client_credentials` and no `location_id`. The `marketplace_app_id` in the path must be the application the token was issued to; any other id responds with `404`. No scope is required.",
        "tags": [
          "Installations"
        ],
        "security": [
          {
            "OAuth2": []
          }
        ],
        "x-altegio-status": "preview",
        "responses": {
          "204": {
            "description": "The installation has been deleted.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/InstallationNotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/marketplace_apps/{marketplace_app_id}/installations/{location_id}/activate": {
      "parameters": [
        {
          "$ref": "#/components/parameters/MarketplaceAppId"
        },
        {
          "$ref": "#/components/parameters/InstallationLocationId"
        }
      ],
      "post": {
        "operationId": "activateMarketplaceAppInstallation",
        "summary": "Activate a pending installation",
        "description": "Confirms that the business finished setup on your page (`setup_url`) and turns a `pending` installation\n`active`. Only then the installation receives its scopes, `installation.created` is sent, and a trial of a paid\napplication starts. Installation tokens for the Location are issued from this moment.\n\nAn installation that stays `pending` for 12 hours is deleted. A repeated call on an activated installation returns\nit unchanged without a second webhook. Without an installation in this Location, including an expired `pending`\none, the call fails with `404 installation_not_found`.\n\nApplications without `setup_url` are activated at installation and never need this call.\n\nCall it with the **application token**: `POST /oauth/token` with `grant_type=client_credentials` and no `location_id`. The `marketplace_app_id` in the path must be the application the token was issued to; any other id responds with `404`. No scope is required.",
        "tags": [
          "Installations"
        ],
        "security": [
          {
            "OAuth2": []
          }
        ],
        "x-altegio-status": "preview",
        "responses": {
          "200": {
            "description": "The active installation.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MarketplaceAppInstallation"
                },
                "example": {
                  "id": 9001,
                  "object": "installation",
                  "marketplace_app_id": 48213,
                  "location_id": 90211,
                  "status": "active",
                  "installed_at": "2026-11-20T09:12:00Z",
                  "scopes": [
                    "appointments:read",
                    "clients:read"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/InstallationNotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/marketplace_apps/{marketplace_app_id}/installations/{location_id}/payments": {
      "parameters": [
        {
          "$ref": "#/components/parameters/MarketplaceAppId"
        },
        {
          "$ref": "#/components/parameters/InstallationLocationId"
        }
      ],
      "post": {
        "operationId": "createMarketplaceAppInstallationPayment",
        "summary": "Report a payment for an installation",
        "description": "For applications that bill the business themselves: reports that the business paid for the application in\nthis Location. A `frozen` installation is unfrozen and `installation.unfrozen` is sent. The installation is frozen\nagain by the scheduler when the paid period ends.\n\nA repeat with the same fields returns `200` with the payment recorded first, so a retry after a lost response is\nsafe. Amounts are integer minor units of `currency` (ISO 4217); for `BHD`, `JOD` and `KWD` they must be a\nmultiple of 10. Applications billed by Altegio fail with\n`403 permission_denied`; without an installation in this Location the call fails with\n`404 installation_not_found`.\n\nCall it with the **application token**: `POST /oauth/token` with `grant_type=client_credentials` and no `location_id`. The `marketplace_app_id` in the path must be the application the token was issued to; any other id responds with `404`. No scope is required.",
        "tags": [
          "Installations"
        ],
        "security": [
          {
            "OAuth2": []
          }
        ],
        "x-altegio-status": "preview",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MarketplaceAppInstallationPaymentCreate"
              },
              "example": {
                "amount_minor": 1990,
                "currency": "EUR",
                "paid_at": "2026-12-01T10:00:00Z",
                "period_from": "2026-12-01T00:00:00Z",
                "period_to": "2026-12-31T23:59:59Z"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The same payment was already recorded; it is returned unchanged.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MarketplaceAppInstallationPayment"
                },
                "example": {
                  "id": 91204,
                  "object": "installation_payment",
                  "marketplace_app_id": 48213,
                  "location_id": 90211,
                  "amount_minor": 1990,
                  "currency": "EUR",
                  "paid_at": "2026-12-01T10:00:00Z",
                  "period_from": "2026-12-01T00:00:00Z",
                  "period_to": "2026-12-31T23:59:59Z",
                  "refunded_at": null
                }
              }
            }
          },
          "201": {
            "description": "The recorded payment.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MarketplaceAppInstallationPayment"
                },
                "example": {
                  "id": 91204,
                  "object": "installation_payment",
                  "marketplace_app_id": 48213,
                  "location_id": 90211,
                  "amount_minor": 1990,
                  "currency": "EUR",
                  "paid_at": "2026-12-01T10:00:00Z",
                  "period_from": "2026-12-01T00:00:00Z",
                  "period_to": "2026-12-31T23:59:59Z",
                  "refunded_at": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The application is billed by Altegio, so payments are not reported by the developer (`permission_denied`).",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "https://developer.alteg.io/problems/permission-denied",
                  "title": "Permission denied",
                  "status": 403,
                  "detail": "This application is billed by Altegio; payments are reported by the Altegio checkout.",
                  "instance": "urn:altegio:request:req_403p",
                  "code": "permission_denied"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/InstallationNotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "description": "Validation failed (`validation_failed`); field-level details are in `errors[]`. An amount that does not fit two decimals is `invalid_value` at `/amount_minor`.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "https://developer.alteg.io/problems/validation-error",
                  "title": "Request validation failed",
                  "status": 422,
                  "detail": "One or more fields are invalid.",
                  "instance": "urn:altegio:request:req_422y",
                  "code": "validation_failed",
                  "errors": [
                    {
                      "code": "invalid_value",
                      "source": "body",
                      "pointer": "/amount_minor",
                      "message": "A KWD amount must be a multiple of 10 minor units."
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    },
    "/marketplace_apps/{marketplace_app_id}/installations/{location_id}/payments/{payment_id}/refund": {
      "parameters": [
        {
          "$ref": "#/components/parameters/MarketplaceAppId"
        },
        {
          "$ref": "#/components/parameters/InstallationLocationId"
        },
        {
          "$ref": "#/components/parameters/InstallationPaymentId"
        }
      ],
      "post": {
        "operationId": "refundMarketplaceAppInstallationPayment",
        "summary": "Refund a reported payment",
        "description": "Marks a payment you reported as refunded and returns it with `refunded_at`. The payment is found by\n`payment_id` among the payments of your application in this Location, so a refund also works after the\ninstallation was deleted. A repeated call returns the payment unchanged. The refund does not freeze the\ninstallation at once; the scheduler freezes it when no paid period remains.\n\nA payment that does not exist for your application in this Location fails with `404 resource_not_found`; a payment\nmade through the Altegio checkout fails with `403 permission_denied`.\n\nCall it with the **application token**: `POST /oauth/token` with `grant_type=client_credentials` and no `location_id`. The `marketplace_app_id` in the path must be the application the token was issued to; any other id responds with `404`. No scope is required.",
        "tags": [
          "Installations"
        ],
        "security": [
          {
            "OAuth2": []
          }
        ],
        "x-altegio-status": "preview",
        "responses": {
          "200": {
            "description": "The refunded payment.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MarketplaceAppInstallationPayment"
                },
                "example": {
                  "id": 91204,
                  "object": "installation_payment",
                  "marketplace_app_id": 48213,
                  "location_id": 90211,
                  "amount_minor": 1990,
                  "currency": "EUR",
                  "paid_at": "2026-12-01T10:00:00Z",
                  "period_from": "2026-12-01T00:00:00Z",
                  "period_to": "2026-12-31T23:59:59Z",
                  "refunded_at": "2026-12-03T08:15:00Z"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The payment was made through the Altegio checkout and is refunded there (`permission_denied`).",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "https://developer.alteg.io/problems/permission-denied",
                  "title": "Permission denied",
                  "status": 403,
                  "detail": "This payment was made through the Altegio checkout.",
                  "instance": "urn:altegio:request:req_403r",
                  "code": "permission_denied"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "406": {
            "$ref": "#/components/responses/NotAcceptable"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/DependencyUnavailable"
          }
        }
      }
    }
  },
  "webhooks": {
    "installation.created": {
      "post": {
        "operationId": "installationCreatedWebhook",
        "summary": "Installation created",
        "description": "Sent when an installation becomes `active`: after your `activate` call, or at installation for an application without `setup_url`. Request an installation token for the Location from this moment.\n\nSigned by the Standard Webhooks scheme with the webhook secret of the application. Answer with any `2xx`; any other status or a timeout is retried for up to 24 hours with the same `webhook-id`.",
        "tags": [
          "Installations"
        ],
        "security": [],
        "x-altegio-status": "preview",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookId"
          },
          {
            "$ref": "#/components/parameters/WebhookTimestamp"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MarketplaceAppInstallationEvent"
              },
              "example": {
                "type": "installation.created",
                "created_at": "2026-11-20T09:12:00Z",
                "data": {
                  "marketplace_app_id": 48213,
                  "location_id": 90211
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Delivery acknowledged."
          }
        }
      }
    },
    "installation.deleted": {
      "post": {
        "operationId": "installationDeletedWebhook",
        "summary": "Installation deleted",
        "description": "Sent when the application is uninstalled from the Location, by the business or by your `DELETE` call. Installation tokens for the Location stop working.\n\nSigned by the Standard Webhooks scheme with the webhook secret of the application. Answer with any `2xx`; any other status or a timeout is retried for up to 24 hours with the same `webhook-id`.",
        "tags": [
          "Installations"
        ],
        "security": [],
        "x-altegio-status": "preview",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookId"
          },
          {
            "$ref": "#/components/parameters/WebhookTimestamp"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MarketplaceAppInstallationEvent"
              },
              "example": {
                "type": "installation.deleted",
                "created_at": "2026-11-20T09:12:00Z",
                "data": {
                  "marketplace_app_id": 48213,
                  "location_id": 90211
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Delivery acknowledged."
          }
        }
      }
    },
    "installation.frozen": {
      "post": {
        "operationId": "installationFrozenWebhook",
        "summary": "Installation frozen",
        "description": "Sent when the installation is frozen because the paid period ended. Installation tokens for the Location stop working until the installation is unfrozen; the application token still reaches the installation.\n\nSigned by the Standard Webhooks scheme with the webhook secret of the application. Answer with any `2xx`; any other status or a timeout is retried for up to 24 hours with the same `webhook-id`.",
        "tags": [
          "Installations"
        ],
        "security": [],
        "x-altegio-status": "preview",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookId"
          },
          {
            "$ref": "#/components/parameters/WebhookTimestamp"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MarketplaceAppInstallationEvent"
              },
              "example": {
                "type": "installation.frozen",
                "created_at": "2026-11-20T09:12:00Z",
                "data": {
                  "marketplace_app_id": 48213,
                  "location_id": 90211
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Delivery acknowledged."
          }
        }
      }
    },
    "installation.unfrozen": {
      "post": {
        "operationId": "installationUnfrozenWebhook",
        "summary": "Installation unfrozen",
        "description": "Sent when a frozen installation works again after a payment through the Altegio checkout or a payment you reported.\n\nSigned by the Standard Webhooks scheme with the webhook secret of the application. Answer with any `2xx`; any other status or a timeout is retried for up to 24 hours with the same `webhook-id`.",
        "tags": [
          "Installations"
        ],
        "security": [],
        "x-altegio-status": "preview",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookId"
          },
          {
            "$ref": "#/components/parameters/WebhookTimestamp"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MarketplaceAppInstallationEvent"
              },
              "example": {
                "type": "installation.unfrozen",
                "created_at": "2026-11-20T09:12:00Z",
                "data": {
                  "marketplace_app_id": 48213,
                  "location_id": 90211
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Delivery acknowledged."
          }
        }
      }
    },
    "installation.paid": {
      "post": {
        "operationId": "installationPaidWebhook",
        "summary": "Installation paid",
        "description": "Sent for applications billed by Altegio when the business pays through the Altegio checkout, renewals included.\n\nSigned by the Standard Webhooks scheme with the webhook secret of the application. Answer with any `2xx`; any other status or a timeout is retried for up to 24 hours with the same `webhook-id`.",
        "tags": [
          "Installations"
        ],
        "security": [],
        "x-altegio-status": "preview",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookId"
          },
          {
            "$ref": "#/components/parameters/WebhookTimestamp"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MarketplaceAppInstallationEvent"
              },
              "example": {
                "type": "installation.paid",
                "created_at": "2026-11-20T09:12:00Z",
                "data": {
                  "marketplace_app_id": 48213,
                  "location_id": 90211
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Delivery acknowledged."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "OAuth2": {
        "type": "oauth2",
        "description": "OAuth 2.0 with **opaque** Bearer tokens (access tokens live one hour). User-facing\napplications and agent hosts use Authorization Code + PKCE with a rotating refresh token.\nThe Client Credentials flow with an explicit `location_id` is for marketplace\napplications and is planned for the second delivery; without `location_id` it issues an\napplication token for the application's own installation routes, with no scopes. There\nis no public password grant.\nSee the Authorization section of the API description for full walkthroughs.\n\n\nScopes marked `Planned:` are listed in discovery like any other scope, except\n`locations:create` and `team_members:manage_access`; a token may already be issued with\nthem and starts working when the operation ships. A grant `X:write` includes\n`X:read`; `read_contact` and action-scopes (`create`, `capture`, `cancel`, `sell`,\n`schedule`, `manage_access`) are never implied. A scope is never refused for arriving without a\ncompanion: a credential may hold `clients:read_contact` alone, it simply opens nothing,\nbecause contact fields live inside the client and appointment reads that their own scopes\ngate.",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://api.alteg.io/oauth/authorize",
            "tokenUrl": "https://api.alteg.io/oauth/token",
            "refreshUrl": "https://api.alteg.io/oauth/token",
            "scopes": {
              "locations:read": "View location info and resources",
              "locations:write": "Manage location settings",
              "services:read": "View services and service categories",
              "services:write": "Manage services and service categories",
              "team_members:read": "View team members, their schedules, service links and positions",
              "team_members:write": "Add, update and dismiss team members; manage service links and positions",
              "team_members:schedule": "Manage the working schedules of team members",
              "clients:read": "View clients without contact details",
              "clients:read_contact": "View client phone numbers and email",
              "clients:write": "Manage clients",
              "availability:read": "View bookable time slots",
              "appointments:read": "View appointments",
              "locations:create": "Planned: create locations",
              "team_members:manage_access": "Planned: manage team member system access and roles",
              "appointments:create": "Planned: create appointments",
              "appointments:write": "Planned: edit, cancel and change the status of appointments",
              "checkout:read": "Planned: view payment methods and the billing state of a visit",
              "checkout:capture": "Planned: record payments",
              "checkout:cancel": "Planned: cancel recorded payments locally",
              "inventory:sell": "Planned: add products to a visit",
              "products:read": "Planned: view the product catalog",
              "finance:read": "Planned: view cash registers and financial accounts",
              "loyalty:read": "Planned: view loyalty instruments",
              "analytics:read": "Planned: view analytics",
              "analytics:write": "Planned: manage saved analytics reports",
              "audit:read": "Planned: view audit logs",
              "checkout:refund": "Planned: refund payments",
              "client_accounts:read": "Planned: view client accounts",
              "client_accounts:write": "Planned: open and top up client accounts",
              "events:read": "Planned: view group events",
              "events:write": "Planned: edit group events",
              "finance:write": "Planned: manage finances",
              "fiscalization:configure": "Planned: configure fiscal settings",
              "fiscalization:operate": "Planned: issue fiscal documents",
              "fiscalization:read": "Planned: view fiscal operations",
              "inventory:operate": "Planned: run stock operations",
              "inventory:read": "Planned: view inventory",
              "loyalty:issue": "Planned: issue loyalty cards",
              "loyalty:transact": "Planned: add and deduct loyalty points",
              "notifications:configure": "Planned: configure templates and channels",
              "notifications:read": "Planned: view message log",
              "notifications:send": "Planned: send messages to clients",
              "online_booking:configure": "Planned: edit online booking settings",
              "online_booking:read": "Planned: view online booking settings",
              "payment_policies:apply": "Planned: apply a payment policy to an appointment",
              "payment_policies:configure": "Planned: configure payment policy rules of a location",
              "payment_policies:read": "Planned: view payment policies",
              "payroll:adjust": "Planned: create and adjust accruals",
              "payroll:configure": "Planned: configure pay schemes",
              "payroll:pay": "Planned: pay out accruals",
              "payroll:read": "Planned: view payroll",
              "products:write": "Planned: manage product cards",
              "reviews:manage": "Planned: reply to, hide and delete reviews",
              "reviews:read": "Planned: view reviews",
              "webhooks:manage": "Planned: manage webhook subscriptions",
              "chain_analytics:read": "Planned: view chain analytics",
              "chain_client_accounts:configure": "Planned: configure client account types of a chain",
              "chain_client_accounts:read": "Planned: view chain client accounts",
              "chain_clients:read": "Planned: view chain clients",
              "chain_clients:read_contact": "Planned: view chain client phone numbers and email",
              "chain_custom_fields:configure": "Planned: configure chain fields",
              "chain_loyalty:configure": "Planned: configure chain loyalty programs",
              "chain_loyalty:read": "Planned: view chain loyalty",
              "chain_loyalty:transact": "Planned: add and deduct chain loyalty points",
              "chain_payroll:read": "Planned: view chain payroll",
              "chain_products:read": "Planned: view chain products",
              "chain_products:write": "Planned: edit chain products",
              "chain_services:read": "Planned: view chain services",
              "chain_services:write": "Planned: edit chain services",
              "chain_structure:manage": "Planned: manage chain structure",
              "chain_team_members:read": "Planned: view chain team members",
              "chain_team_members:write": "Planned: edit chain team members",
              "marketplace_apps:read": "Planned: view your marketplace applications and their publication cards",
              "marketplace_apps:write": "Planned: create and edit your marketplace applications and their publication cards"
            }
          },
          "clientCredentials": {
            "tokenUrl": "https://api.alteg.io/oauth/token",
            "scopes": {
              "locations:read": "Planned: view location info and resources",
              "locations:write": "Planned: manage location settings",
              "services:read": "Planned: view services and service categories",
              "services:write": "Planned: manage services and service categories",
              "team_members:read": "Planned: view team members, their schedules, service links and positions",
              "team_members:write": "Planned: add, update and dismiss team members; manage service links and positions",
              "team_members:schedule": "Planned: manage the working schedules of team members",
              "clients:read": "Planned: view clients without contact details",
              "clients:read_contact": "Planned: view client phone numbers and email",
              "clients:write": "Planned: manage clients",
              "availability:read": "Planned: view bookable time slots",
              "appointments:read": "Planned: view appointments",
              "appointments:create": "Planned: create appointments",
              "appointments:write": "Planned: edit, cancel and change the status of appointments",
              "checkout:read": "Planned: view payment methods and the billing state of a visit",
              "checkout:capture": "Planned: record payments",
              "checkout:cancel": "Planned: cancel recorded payments locally",
              "inventory:sell": "Planned: add products to a visit",
              "products:read": "Planned: view the product catalog",
              "finance:read": "Planned: view cash registers and financial accounts",
              "loyalty:read": "Planned: view loyalty instruments"
            }
          }
        }
      },
      "ApiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "An API key created by a Business User in the Developer Hub (`ag_key_…`, shown once,\nexpires within a year). The key itself is the Bearer credential — no token exchange. It\nacts on behalf of its author: grants on the chosen Locations and chains plus the author's\ncurrent business permissions, checked on every request. The author revokes it in the\nportal; revocation takes effect within seconds. Scopes that hand out access to\npeople are never available to it.\n"
      }
    },
    "parameters": {
      "LocationId": {
        "name": "location_id",
        "in": "path",
        "required": true,
        "description": "Identifier of the Location. Verified against the credential on every call — a Location the credential cannot access responds with `404`.",
        "schema": {
          "type": "integer"
        }
      },
      "ServiceId": {
        "name": "service_id",
        "in": "path",
        "required": true,
        "description": "Identifier of the service.",
        "schema": {
          "type": "integer"
        }
      },
      "ServiceCategoryId": {
        "name": "service_category_id",
        "in": "path",
        "required": true,
        "description": "Identifier of the service category.",
        "schema": {
          "type": "integer"
        }
      },
      "TeamMemberId": {
        "name": "team_member_id",
        "in": "path",
        "required": true,
        "description": "Identifier of the Team Member.",
        "schema": {
          "type": "integer"
        }
      },
      "PositionId": {
        "name": "position_id",
        "in": "path",
        "required": true,
        "description": "Identifier of the position.",
        "schema": {
          "type": "integer"
        }
      },
      "ClientId": {
        "name": "client_id",
        "in": "path",
        "required": true,
        "description": "Identifier of the client.",
        "schema": {
          "type": "integer"
        }
      },
      "AppointmentId": {
        "name": "appointment_id",
        "in": "path",
        "required": true,
        "description": "Identifier of the appointment.",
        "schema": {
          "type": "integer"
        }
      },
      "PaymentId": {
        "name": "payment_id",
        "in": "path",
        "required": true,
        "description": "Opaque payment id: `t<number>` for money transactions, `l<number>` for loyalty/Client Account operations. Stable between requests.",
        "schema": {
          "type": "string"
        }
      },
      "AvailabilityServiceIds": {
        "name": "service_ids[]",
        "in": "query",
        "required": true,
        "description": "Services the appointment will consist of, 1 to 10 ids. An unknown, deleted or foreign id, a service with online booking disabled in the Location, or more than 10 ids fails with `422 validation_failed`, `errors[0].pointer = service_ids[]`, `source = query` and `code = invalid_value`; a package service fails the same way with `code = unsupported_service_type`.",
        "style": "form",
        "explode": true,
        "schema": {
          "type": "array",
          "minItems": 1,
          "maxItems": 10,
          "items": {
            "type": "integer"
          }
        }
      },
      "AvailabilityTeamMemberId": {
        "name": "team_member_id",
        "in": "query",
        "required": false,
        "description": "Restrict the search to one Team Member. An id that is not a working Team Member of the Location (unknown, deleted or dismissed) fails with `422 validation_failed`, `errors[0].pointer = team_member_id`, `source = query` and `code = invalid_value`. A working Team Member currently hidden from online booking returns `200` with empty slots or dates, including when explicitly requested; it does not fail with `422`. An explicit id does not bypass the current online visibility setting. The Location's technical Team Member setting is separate from that visibility: an incompatible explicit id returns `200` with an empty result. When omitted, the existing technical Team Member setting applies. A matching explicit id and an omitted parameter both require that technical Team Member to be currently visible for online booking and permitted by the acting user's Team Member permissions.",
        "schema": {
          "type": "integer"
        }
      },
      "DeveloperId": {
        "name": "developer_id",
        "in": "path",
        "required": true,
        "description": "Identifier of the developer account. The caller must be a member of it; another account responds with `404`.",
        "schema": {
          "type": "integer"
        }
      },
      "MarketplaceAppId": {
        "name": "marketplace_app_id",
        "in": "path",
        "required": true,
        "description": "Identifier of the marketplace application.",
        "schema": {
          "type": "integer"
        }
      },
      "InstallationLocationId": {
        "name": "location_id",
        "in": "path",
        "required": true,
        "description": "Identifier of the Location your application is installed in. Together with `marketplace_app_id` it addresses the installation; a Location without an installation of the application responds with `404 installation_not_found`.",
        "schema": {
          "type": "integer"
        }
      },
      "InstallationPaymentId": {
        "name": "payment_id",
        "in": "path",
        "required": true,
        "description": "Identifier of a payment you reported with `POST …/payments`.",
        "schema": {
          "type": "integer"
        }
      },
      "InstallationStatus": {
        "name": "status",
        "in": "query",
        "required": false,
        "description": "Return only installations in this status.",
        "schema": {
          "type": "string",
          "enum": [
            "active",
            "frozen",
            "pending"
          ]
        }
      },
      "WebhookId": {
        "name": "webhook-id",
        "in": "header",
        "required": true,
        "description": "Unique id of the event. Retries of the same event keep it; drop an event whose id you have already processed.",
        "schema": {
          "type": "string"
        }
      },
      "WebhookTimestamp": {
        "name": "webhook-timestamp",
        "in": "header",
        "required": true,
        "description": "Unix time in seconds when this delivery attempt was signed. Reject deliveries older than 5 minutes.",
        "schema": {
          "type": "integer"
        }
      },
      "WebhookSignature": {
        "name": "webhook-signature",
        "in": "header",
        "required": true,
        "description": "`v1,` followed by base64 of HMAC-SHA256 over `{webhook-id}.{webhook-timestamp}.{body}`, keyed with the webhook secret of the application.",
        "schema": {
          "type": "string"
        }
      },
      "Limit": {
        "name": "limit",
        "in": "query",
        "required": false,
        "description": "Page size for cursor pagination. Default is 25; maximum is 100. Values outside 1..100 or non-integers fail with `422 validation_failed`; the value is never clamped.",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100,
          "default": 25
        }
      },
      "Cursor": {
        "name": "cursor",
        "in": "query",
        "required": false,
        "description": "Opaque cursor from `next_cursor`. An empty value is the same as omitting the parameter and returns the first page. Cursors expire one hour after the response that issued them (every page issues a fresh cursor) and are bound to credential, tenant, list, filters, and ordering; for OAuth the credential is the user's authorization, so a cursor survives a token refresh; a row whose ordering column changed between pages may be skipped or returned twice, and a row created while you page may be missing from this pass if it sorts before the current position (start a new pass to pick it up); expired, malformed, foreign, or re-filtered cursors fail with `422 validation_failed` using field codes `expired_cursor`, `invalid_cursor` (also a cursor whose number of key values does not match the list's ordering), `foreign_cursor` (another credential or tenant), or `filter_changed` (another list, ordering, or filters).",
        "schema": {
          "type": "string"
        }
      },
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": true,
        "description": "Client-generated unique key for this logical request (UUID recommended). A retry with the same key and body returns the original result; the same key with a different body fails with `409 idempotency_key_reused`. Keys are retained at least 24 hours and are scoped to credential, Location, and operation; after expiry the value may be reused for a new logical request.",
        "schema": {
          "type": "string",
          "maxLength": 255
        }
      },
      "IfMatch": {
        "name": "If-Match",
        "in": "header",
        "required": true,
        "description": "`ETag` value of the resource version the change is based on. A stale value fails with `412 stale_version`; a missing header fails with `428 precondition_required`.",
        "schema": {
          "type": "string"
        }
      },
      "IncludeAppointment": {
        "name": "include[]",
        "in": "query",
        "required": false,
        "description": "Relations to include, one level deep; each adds a new field next to its id. Including `client` never bypasses PII rules — contact fields are `null` and listed in `redacted_fields` without `clients:read_contact`. Unknown values fail with `422`.",
        "style": "form",
        "explode": true,
        "schema": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "client",
              "team_member"
            ]
          }
        }
      },
      "IncludeService": {
        "name": "include[]",
        "in": "query",
        "required": false,
        "description": "Relations to include, one level deep. `team_members` adds the `team_members` field: the duration, price and online booking setting of each Team Member from `team_member_ids`. Unknown values fail with `422`.",
        "style": "form",
        "explode": true,
        "schema": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "team_members"
            ]
          }
        }
      },
      "IncludeVisit": {
        "name": "include[]",
        "in": "query",
        "required": false,
        "description": "Relations to include, one level deep; each adds a new field next to its id. Including `client` never bypasses PII rules — contact fields are `null` and listed in `redacted_fields` without `clients:read_contact`. Unknown values fail with `422`.",
        "style": "form",
        "explode": true,
        "schema": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "client"
            ]
          }
        }
      },
      "CountryId": {
        "name": "country_id",
        "in": "query",
        "required": false,
        "description": "Country dictionary identifier used to filter cities.",
        "schema": {
          "type": "integer"
        }
      },
      "Query": {
        "name": "query",
        "in": "query",
        "required": false,
        "description": "Search query.",
        "schema": {
          "type": "string"
        }
      },
      "Number": {
        "name": "number",
        "in": "query",
        "required": false,
        "description": "Loyalty instrument number to search.",
        "schema": {
          "type": "string"
        }
      },
      "LoyaltyInstrumentType": {
        "name": "type",
        "in": "query",
        "required": false,
        "description": "Loyalty instrument type.",
        "schema": {
          "type": "string",
          "enum": [
            "gift_card",
            "membership"
          ]
        }
      }
    },
    "headers": {
      "ETag": {
        "description": "Version tag of the returned resource. Send it back in `If-Match` on the next `PATCH` or `DELETE`.",
        "schema": {
          "type": "string"
        }
      },
      "Location": {
        "description": "URL of the created resource.",
        "schema": {
          "type": "string"
        }
      },
      "RateLimitPolicy": {
        "description": "Most constrained policy applied to the request, as `<limit>;w=<window in seconds>`.",
        "schema": {
          "type": "string"
        },
        "example": "10;w=60"
      },
      "RateLimitRemaining": {
        "description": "Requests left in the most constrained policy window that applies to this request.",
        "schema": {
          "type": "integer",
          "format": "int32",
          "minimum": 0
        }
      },
      "RateLimitReset": {
        "description": "On `429`, seconds until the most constrained policy frees up; it equals `Retry-After` there.\nOn a successful response it reports the **length** of that policy's window rather than the\ntime left in the current one, so treat it as the window size, not as a countdown — the\ncounter to pace against is `RateLimit-Remaining`.",
        "schema": {
          "type": "integer",
          "format": "int32",
          "minimum": 0
        }
      },
      "RetryAfter": {
        "description": "Seconds to wait before retrying.",
        "schema": {
          "type": "integer",
          "format": "int32",
          "minimum": 0
        }
      },
      "XRequestId": {
        "description": "Request identifier for support and log correlation.",
        "schema": {
          "type": "string"
        }
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "The request has no valid Bearer credential (`invalid_token`).",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            },
            "example": {
              "type": "https://developer.alteg.io/problems/invalid-token",
              "title": "Invalid or expired token",
              "status": 401,
              "detail": "The access token is missing, expired, or revoked.",
              "instance": "urn:altegio:request:req_401x",
              "code": "invalid_token"
            }
          }
        },
        "headers": {
          "WWW-Authenticate": {
            "description": "Bearer challenge with the URL of the protected resource metadata (RFC 9728 §5.1),\nwhere the client finds the authorization server.\n",
            "schema": {
              "type": "string"
            },
            "example": "Bearer resource_metadata=\"https://api.alteg.io/.well-known/oauth-protected-resource/api/v3\""
          },
          "X-Request-Id": {
            "$ref": "#/components/headers/XRequestId"
          }
        }
      },
      "Forbidden": {
        "description": "The token lacks the required scope (`missing_scope`), the scope is present but the token subject lacks the business permission (`permission_denied`), or the Location has no active license (`subscription_inactive`).",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            },
            "examples": {
              "missing_scope": {
                "summary": "Token scope is insufficient",
                "value": {
                  "type": "https://developer.alteg.io/problems/missing-scope",
                  "title": "Missing scope",
                  "status": 403,
                  "detail": "The access token does not carry the scope required by this operation.",
                  "instance": "urn:altegio:request:req_403a",
                  "code": "missing_scope"
                }
              },
              "permission_denied": {
                "summary": "Subject lacks the business permission",
                "value": {
                  "type": "https://developer.alteg.io/problems/permission-denied",
                  "title": "Permission denied",
                  "status": 403,
                  "detail": "The token subject does not have the required permission in this location.",
                  "instance": "urn:altegio:request:req_403b",
                  "code": "permission_denied"
                }
              },
              "subscription_inactive": {
                "summary": "Location license is not active",
                "value": {
                  "type": "https://developer.alteg.io/problems/subscription-inactive",
                  "title": "Subscription inactive",
                  "status": 403,
                  "detail": "The location has no active license. Ask its owner to renew it.",
                  "instance": "urn:altegio:request:req_403c",
                  "code": "subscription_inactive"
                }
              }
            }
          }
        },
        "headers": {
          "WWW-Authenticate": {
            "description": "Only on `missing_scope`: Bearer challenge with `error=\"insufficient_scope\"`, the scope the\noperation requires and the URL of the protected resource metadata (RFC 6750 §3.1, RFC 9728 §5.1).\n",
            "schema": {
              "type": "string"
            },
            "example": "Bearer error=\"insufficient_scope\", scope=\"team_members:read\", resource_metadata=\"https://api.alteg.io/.well-known/oauth-protected-resource/api/v3\""
          },
          "X-Request-Id": {
            "$ref": "#/components/headers/XRequestId"
          }
        }
      },
      "NotAcceptable": {
        "description": "Requested `Accept` media type cannot be satisfied (`not_acceptable`).",
        "headers": {
          "X-Request-Id": {
            "$ref": "#/components/headers/XRequestId"
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            },
            "example": {
              "type": "https://developer.alteg.io/problems/not-acceptable",
              "title": "Not acceptable",
              "status": 406,
              "detail": "Use Accept application/json for resources and application/problem+json for errors.",
              "instance": "urn:altegio:request:req_406x",
              "code": "not_acceptable"
            }
          }
        }
      },
      "NotFound": {
        "description": "The resource does not exist or is hidden by tenant policy. Prefer a resource-specific\ncode (`appointment_not_found`, `location_not_found`, …). Routing/gate/unknown-path 404s\nuse the generic `resource_not_found` (same shape, so \"no pin\" and \"missing\" are not distinguished).\n",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            },
            "examples": {
              "resource_not_found": {
                "summary": "Generic 404 (routing / gate / hidden)",
                "value": {
                  "type": "https://developer.alteg.io/problems/resource-not-found",
                  "title": "Resource not found",
                  "status": 404,
                  "detail": "The requested resource was not found.",
                  "instance": "urn:altegio:request:req_404a",
                  "code": "resource_not_found"
                }
              },
              "appointment_not_found": {
                "summary": "Resource-specific 404",
                "value": {
                  "type": "https://developer.alteg.io/problems/appointment-not-found",
                  "title": "Appointment not found",
                  "status": 404,
                  "detail": "The requested resource does not exist in this location.",
                  "instance": "urn:altegio:request:req_404b",
                  "code": "appointment_not_found"
                }
              }
            }
          }
        },
        "headers": {
          "X-Request-Id": {
            "$ref": "#/components/headers/XRequestId"
          }
        }
      },
      "IdempotencyConflict": {
        "description": "The `Idempotency-Key` was already used with a different body (`idempotency_key_reused`), or the first request with this key is still running (`idempotency_request_in_progress`, retry after `Retry-After`).",
        "headers": {
          "Retry-After": {
            "$ref": "#/components/headers/RetryAfter"
          },
          "X-Request-Id": {
            "$ref": "#/components/headers/XRequestId"
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            },
            "examples": {
              "idempotency_key_reused": {
                "summary": "Same key, different body",
                "value": {
                  "type": "https://developer.alteg.io/problems/idempotency-key-reused",
                  "title": "Idempotency key reused",
                  "status": 409,
                  "detail": "This Idempotency-Key was already used with a different request body.",
                  "instance": "urn:altegio:request:req_409a",
                  "code": "idempotency_key_reused"
                }
              },
              "idempotency_request_in_progress": {
                "summary": "First request still in progress",
                "value": {
                  "type": "https://developer.alteg.io/problems/idempotency-request-in-progress",
                  "title": "Request in progress",
                  "status": 409,
                  "detail": "A request with this Idempotency-Key is still being processed. Retry later with the same key.",
                  "instance": "urn:altegio:request:req_409b",
                  "code": "idempotency_request_in_progress"
                }
              }
            }
          }
        }
      },
      "PreconditionFailed": {
        "description": "The `If-Match` version is stale — the resource was changed by another writer (`stale_version`). Re-read the resource and retry deliberately.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            },
            "example": {
              "type": "https://developer.alteg.io/problems/stale-version",
              "title": "Resource version is stale",
              "status": 412,
              "detail": "The resource was modified after the version supplied in If-Match. Re-read it and retry.",
              "instance": "urn:altegio:request:req_412x",
              "code": "stale_version"
            }
          }
        },
        "headers": {
          "X-Request-Id": {
            "$ref": "#/components/headers/XRequestId"
          }
        }
      },
      "ValidationFailed": {
        "description": "Semantic validation failed (`validation_failed`); field-level details are in `errors[]`. Merge-patch violations use `field_not_nullable` / `field_immutable`.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            },
            "example": {
              "type": "https://developer.alteg.io/problems/validation-error",
              "title": "Request validation failed",
              "status": 422,
              "detail": "One or more fields are invalid.",
              "instance": "urn:altegio:request:req_422x",
              "code": "validation_failed",
              "errors": [
                {
                  "code": "invalid_datetime",
                  "pointer": "/starts_at",
                  "message": "starts_at must be a valid RFC 3339 datetime.",
                  "source": "body"
                }
              ]
            }
          }
        },
        "headers": {
          "X-Request-Id": {
            "$ref": "#/components/headers/XRequestId"
          }
        }
      },
      "PreconditionRequired": {
        "description": "The required `If-Match` header is missing (`precondition_required`).",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            },
            "example": {
              "type": "https://developer.alteg.io/problems/precondition-required",
              "title": "Precondition required",
              "status": 428,
              "detail": "This operation requires the If-Match header with the last seen ETag.",
              "instance": "urn:altegio:request:req_428x",
              "code": "precondition_required"
            }
          }
        },
        "headers": {
          "X-Request-Id": {
            "$ref": "#/components/headers/XRequestId"
          }
        }
      },
      "RateLimited": {
        "description": "Rate limit exceeded (`rate_limit_exceeded`). Retry after `Retry-After`.",
        "headers": {
          "Retry-After": {
            "$ref": "#/components/headers/RetryAfter"
          },
          "RateLimit-Remaining": {
            "$ref": "#/components/headers/RateLimitRemaining"
          },
          "RateLimit-Reset": {
            "$ref": "#/components/headers/RateLimitReset"
          },
          "RateLimit-Policy": {
            "$ref": "#/components/headers/RateLimitPolicy"
          },
          "X-Request-Id": {
            "$ref": "#/components/headers/XRequestId"
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            },
            "example": {
              "type": "https://developer.alteg.io/problems/rate-limit-exceeded",
              "title": "Rate limit exceeded",
              "status": 429,
              "detail": "Too many requests. Retry after the interval in Retry-After.",
              "instance": "urn:altegio:request:req_429x",
              "code": "rate_limit_exceeded"
            }
          }
        }
      },
      "DependencyUnavailable": {
        "description": "A dependency required for safe processing (e.g. the idempotency store) is unavailable; the write was **not** performed (`dependency_unavailable`). Retry with the same `Idempotency-Key` after a backoff.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            },
            "example": {
              "type": "https://developer.alteg.io/problems/dependency-unavailable",
              "title": "Dependency unavailable",
              "status": 503,
              "detail": "A required dependency is unavailable. The operation was not performed.",
              "instance": "urn:altegio:request:req_503x",
              "code": "dependency_unavailable"
            }
          }
        },
        "headers": {
          "X-Request-Id": {
            "$ref": "#/components/headers/XRequestId"
          }
        }
      },
      "BadRequest": {
        "description": "Client error without a more specific registered code (`bad_request` — status default for\nbare 400 and unknown 4xx), or protocol/syntax failure (`malformed_request` — broken JSON /\nunparseable body only; must be thrown explicitly, never used as a synonym for every 400).\nSemantic field validation is `422 validation_failed`, not 400.\n",
        "headers": {
          "X-Request-Id": {
            "$ref": "#/components/headers/XRequestId"
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            },
            "examples": {
              "bad_request": {
                "summary": "Generic client reject (status default)",
                "value": {
                  "type": "https://developer.alteg.io/problems/bad-request",
                  "title": "Bad request",
                  "status": 400,
                  "detail": "The request could not be processed.",
                  "instance": "urn:altegio:request:req_400a",
                  "code": "bad_request"
                }
              },
              "malformed_request": {
                "summary": "Broken JSON / protocol only",
                "value": {
                  "type": "https://developer.alteg.io/problems/malformed-request",
                  "title": "Malformed request",
                  "status": 400,
                  "detail": "The request body is not valid JSON.",
                  "instance": "urn:altegio:request:req_400b",
                  "code": "malformed_request"
                }
              }
            }
          }
        }
      },
      "UnsupportedMediaType": {
        "description": "Unsupported request media type.",
        "headers": {
          "X-Request-Id": {
            "$ref": "#/components/headers/XRequestId"
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            },
            "example": {
              "type": "https://developer.alteg.io/problems/unsupported-media-type",
              "title": "Unsupported media type",
              "status": 415,
              "detail": "Use application/json or application/merge-patch+json as documented.",
              "instance": "urn:altegio:request:req_415x",
              "code": "unsupported_media_type"
            }
          }
        }
      },
      "Conflict": {
        "description": "Domain conflict (`slot_taken`, `duplicate_location`, `last_location_owner`), idempotency conflict, or generic `conflict` when no more specific registered code applies.",
        "headers": {
          "X-Request-Id": {
            "$ref": "#/components/headers/XRequestId"
          },
          "Retry-After": {
            "$ref": "#/components/headers/RetryAfter"
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            },
            "example": {
              "type": "https://developer.alteg.io/problems/conflict",
              "title": "Conflict",
              "status": 409,
              "detail": "The requested change conflicts with current resource state.",
              "instance": "urn:altegio:request:req_409x",
              "code": "conflict"
            }
          }
        }
      },
      "InternalError": {
        "description": "Unexpected server error (`internal_error`).",
        "headers": {
          "X-Request-Id": {
            "$ref": "#/components/headers/XRequestId"
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            },
            "example": {
              "type": "https://developer.alteg.io/problems/internal-error",
              "title": "Internal error",
              "status": 500,
              "detail": "An unexpected error occurred.",
              "instance": "urn:altegio:request:req_500x",
              "code": "internal_error"
            }
          }
        }
      },
      "InstallationNotFound": {
        "description": "Your application has no installation in this Location (`installation_not_found`), including a deleted installation and an expired `pending` one.",
        "headers": {
          "X-Request-Id": {
            "$ref": "#/components/headers/XRequestId"
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            },
            "example": {
              "type": "https://developer.alteg.io/problems/installation-not-found",
              "title": "Installation not found",
              "status": 404,
              "detail": "The application is not installed in this location.",
              "instance": "urn:altegio:request:req_404i",
              "code": "installation_not_found"
            }
          }
        }
      }
    },
    "examples": {
      "LocationExample": {
        "summary": "A Location",
        "value": {
          "id": 4321,
          "object": "location",
          "name": "Demo Beauty Studio Lisbon",
          "description": null,
          "business_type_id": 1,
          "address": "Av. da Liberdade 100, Lisbon",
          "coordinates": {
            "latitude": 38.7223,
            "longitude": -9.1393
          },
          "phones": [
            "+351210000000"
          ],
          "site": "https://demo.example.com",
          "timezone": "Europe/Lisbon",
          "currency": "EUR",
          "created_at": "2025-01-15T10:00:00Z",
          "city_id": 6201,
          "country_code": "PT"
        }
      },
      "ServiceExample": {
        "summary": "A service",
        "value": {
          "id": 100,
          "object": "service",
          "type": "simple",
          "name": "Men's haircut",
          "online_booking_name": "Haircut for men",
          "online_booking_description": "Wash, cut and styling.",
          "category_id": 205,
          "chain_id": null,
          "duration_seconds": 3600,
          "weight": 2,
          "currency": "EUR",
          "online_booking_enabled": true,
          "team_member_ids": [
            321,
            322
          ],
          "package": null,
          "created_at": "2026-07-01T08:00:00Z",
          "price_min_minor": 250000,
          "price_max_minor": 300000
        }
      },
      "ServicePackageExample": {
        "summary": "A service package",
        "value": {
          "id": 200,
          "object": "service",
          "type": "package",
          "package": {
            "exec_order": "sequential",
            "pricing_type": "sum",
            "price_discount_percent": 10,
            "status": "ready",
            "components": [
              {
                "id": 77,
                "service_id": 1501,
                "position": 1
              },
              {
                "id": 78,
                "service_id": 1502,
                "position": 2
              }
            ]
          },
          "name": "Spa day",
          "online_booking_name": "Spa day",
          "online_booking_description": null,
          "category_id": 205,
          "chain_id": null,
          "duration_seconds": 7200,
          "weight": 1,
          "currency": "EUR",
          "online_booking_enabled": true,
          "team_member_ids": [
            321
          ],
          "created_at": "2026-07-01T08:00:00Z",
          "price_min_minor": 500000,
          "price_max_minor": 500000
        }
      },
      "ServiceIncludedTeamMembersExample": {
        "summary": "A service with include[]=team_members",
        "value": {
          "id": 100,
          "object": "service",
          "type": "simple",
          "name": "Men's haircut",
          "online_booking_name": "Haircut for men",
          "online_booking_description": "Wash, cut and styling.",
          "category_id": 205,
          "chain_id": null,
          "duration_seconds": 3600,
          "weight": 2,
          "currency": "EUR",
          "online_booking_enabled": true,
          "team_member_ids": [
            321,
            322
          ],
          "team_members": [
            {
              "team_member_id": 321,
              "duration_seconds": null,
              "price_min_minor": null,
              "price_max_minor": null,
              "online_booking_enabled": true
            },
            {
              "team_member_id": 322,
              "duration_seconds": 2700,
              "price_min_minor": 300000,
              "price_max_minor": 300000,
              "online_booking_enabled": false
            }
          ],
          "package": null,
          "created_at": "2026-07-01T08:00:00Z",
          "price_min_minor": 250000,
          "price_max_minor": 300000
        }
      },
      "TeamMemberExample": {
        "summary": "A Team Member",
        "value": {
          "id": 321,
          "object": "team_member",
          "name": "Aigerim Bekova",
          "specialization": "Hairdresser",
          "avatar_url": "https://assets.alteg.io/masters/norm/4/48/48c3c5a1b0e1e8d_20260601093015.png",
          "position_id": 15,
          "online_booking_enabled": true,
          "dismissal_date": null,
          "created_at": "2026-06-01T08:00:00Z"
        }
      },
      "ClientExample": {
        "summary": "A client (contact fields visible)",
        "value": {
          "id": 789,
          "object": "client",
          "name": "Demo",
          "surname": "Client",
          "patronymic": null,
          "phone": "+351210000175",
          "additional_phone": null,
          "email": "demo.client@example.com",
          "comment": null,
          "card_number": null,
          "gender": null,
          "importance": null,
          "birth_day": 12,
          "birth_month": 4,
          "birth_year": 1990,
          "discount_percent": 5,
          "visits_count": 12,
          "first_visit_at": "2025-11-02T10:00:00+00:00",
          "last_visit_at": "2026-07-09T11:30:00+01:00",
          "sold_amount_minor": 1250000,
          "currency": "EUR",
          "created_at": "2025-11-02T09:57:15Z",
          "updated_at": "2026-07-09T09:57:15Z",
          "redacted_fields": []
        }
      },
      "ClientRedactedExample": {
        "summary": "A client without contact access and without the surname or comment permissions",
        "value": {
          "id": 789,
          "object": "client",
          "name": "Demo",
          "surname": null,
          "patronymic": null,
          "phone": null,
          "additional_phone": null,
          "email": null,
          "comment": null,
          "card_number": null,
          "gender": null,
          "importance": null,
          "birth_day": 12,
          "birth_month": 4,
          "birth_year": 1990,
          "discount_percent": 5,
          "visits_count": 12,
          "first_visit_at": "2025-11-02T10:00:00+00:00",
          "last_visit_at": "2026-07-09T11:30:00+01:00",
          "sold_amount_minor": 1250000,
          "currency": "EUR",
          "created_at": "2025-11-02T09:57:15Z",
          "updated_at": "2026-07-09T09:57:15Z",
          "redacted_fields": [
            "surname",
            "patronymic",
            "phone",
            "additional_phone",
            "email",
            "comment"
          ]
        }
      },
      "AppointmentExample": {
        "summary": "An appointment",
        "value": {
          "id": 12345,
          "object": "appointment",
          "location_id": 4321,
          "client_id": 789,
          "visit_id": 5001,
          "team_member_id": 321,
          "service_ids": [
            100
          ],
          "resource_instance_ids": [],
          "status": "waiting",
          "starts_at": "2026-07-24T11:30:00+01:00",
          "ends_at": "2026-07-24T12:30:00+01:00",
          "duration_seconds": 3600,
          "is_paid": false,
          "comment": null,
          "cancelled_at": null,
          "cancellation_reason": null,
          "created_at": "2026-07-20T09:57:15Z",
          "updated_at": "2026-07-20T09:57:15Z"
        }
      },
      "VisitExample": {
        "summary": "A visit with one paid service",
        "value": {
          "id": 5001,
          "object": "visit",
          "location_id": 4321,
          "appointment_ids": [
            12345
          ],
          "status": "arrived",
          "items": [
            {
              "id": 8101,
              "object": "visit_item",
              "type": "service",
              "service_id": 100,
              "title": "Men's haircut",
              "quantity": 1,
              "price_minor": 250000,
              "amount_minor": 250000
            }
          ],
          "payments": [
            {
              "id": "t9001",
              "object": "payment",
              "visit_id": 5001,
              "type": "payment_method",
              "payment_method_id": 71,
              "account_id": 13,
              "amount_minor": 250000,
              "fee_minor": 2500,
              "currency": "EUR",
              "card_brand_id": 1,
              "installment_count": null,
              "status": "completed",
              "covers_items": [],
              "refund": null,
              "created_at": "2026-07-24T13:00:00Z"
            }
          ],
          "currency": "EUR",
          "created_at": "2026-07-24T11:30:00Z",
          "updated_at": "2026-07-24T13:00:00Z",
          "amount_to_pay_minor": 0,
          "payment_methods": [
            {
              "id": 71,
              "object": "applicable_payment_method",
              "type": "payment_method",
              "name": "Bank card",
              "payment_method_id": 71,
              "account_id": 13,
              "number": null,
              "is_applicable": true,
              "applicable_amount_minor": 250000,
              "is_partial_allowed": true
            }
          ]
        }
      },
      "PaymentExample": {
        "summary": "A registered payment",
        "value": {
          "id": "t9001",
          "object": "payment",
          "visit_id": 5001,
          "type": "payment_method",
          "payment_method_id": 71,
          "account_id": 13,
          "amount_minor": 250000,
          "fee_minor": 2500,
          "currency": "EUR",
          "card_brand_id": 1,
          "installment_count": null,
          "status": "completed",
          "covers_items": [],
          "refund": null,
          "created_at": "2026-07-24T13:00:00Z"
        }
      }
    },
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "Error body (RFC 9457 hybrid), always served as `application/problem+json`. Branch on the stable `code`, never on human-readable text.",
        "properties": {
          "type": {
            "type": "string",
            "description": "Stable URL identifying the problem type; links to documentation."
          },
          "title": {
            "type": "string",
            "description": "Human-readable summary of the problem type."
          },
          "status": {
            "type": "integer",
            "description": "HTTP status code of this response."
          },
          "detail": {
            "type": "string",
            "description": "Human-readable explanation of this occurrence."
          },
          "instance": {
            "type": "string",
            "description": "Request identifier for support and log correlation."
          },
          "code": {
            "type": "string",
            "description": "Stable machine-readable reason code."
          },
          "errors": {
            "type": "array",
            "description": "Field-level issues, present when the problem is attributable to a request input (validation, `field_not_nullable`, `field_immutable`, `permission_denied` on a field, `unsupported_media_type` on a header).",
            "items": {
              "$ref": "#/components/schemas/ProblemFieldError"
            }
          }
        },
        "required": [
          "type",
          "title",
          "status",
          "code",
          "instance"
        ],
        "additionalProperties": false
      },
      "ProblemFieldError": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Stable machine-readable reason for this field."
          },
          "pointer": {
            "type": "string",
            "description": "JSON Pointer for `body`; parameter name for `query`, `path`, or `header`."
          },
          "message": {
            "type": "string",
            "description": "Human-readable explanation."
          },
          "source": {
            "type": "string",
            "enum": [
              "body",
              "query",
              "path",
              "header"
            ],
            "description": "Where the invalid value came from."
          }
        },
        "required": [
          "code",
          "source",
          "pointer",
          "message"
        ],
        "additionalProperties": false
      },
      "ListEnvelope": {
        "type": "object",
        "description": "Common list envelope. `data` holds the page items; pass `next_cursor` as the `cursor` query parameter to fetch the next page while `has_more` is `true`.",
        "properties": {
          "object": {
            "type": "string",
            "enum": [
              "list"
            ]
          },
          "has_more": {
            "type": "boolean",
            "description": "Whether more items exist beyond this page."
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "Opaque cursor for the next page; `null` on the last page."
          }
        },
        "required": [
          "object",
          "has_more",
          "next_cursor"
        ]
      },
      "OAuthAuthorizationServerMetadata": {
        "type": "object",
        "description": "OAuth 2.0 authorization server metadata (RFC 8414).",
        "properties": {
          "issuer": {
            "type": "string"
          },
          "authorization_endpoint": {
            "type": "string"
          },
          "token_endpoint": {
            "type": "string"
          },
          "revocation_endpoint": {
            "type": "string"
          },
          "registration_endpoint": {
            "type": "string"
          },
          "client_id_metadata_document_supported": {
            "type": "boolean",
            "description": "Whether a `client_id` may be an HTTPS URL pointing to a client metadata document (CIMD). Clients that support the URL form only attempt it when this is `true`."
          },
          "authorization_response_iss_parameter_supported": {
            "type": "boolean",
            "description": "Every authorization response, success or error, carries `iss` equal to `issuer` (RFC 9207). Clients compare it with the recorded `issuer` before redeeming the code."
          },
          "response_types_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "grant_types_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "code_challenge_methods_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "token_endpoint_auth_methods_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "scopes_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "issuer",
          "authorization_endpoint",
          "token_endpoint"
        ],
        "additionalProperties": false
      },
      "OAuthProtectedResourceMetadata": {
        "type": "object",
        "description": "OAuth 2.0 protected resource metadata (RFC 9728).",
        "properties": {
          "resource": {
            "type": "string",
            "description": "Resource identifier, also the audience of tokens accepted here."
          },
          "authorization_servers": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "scopes_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "bearer_methods_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "resource",
          "authorization_servers"
        ],
        "additionalProperties": false
      },
      "OAuthTokenRequest": {
        "description": "Token request (RFC 6749, form-encoded). `resource` selects REST vs MCP token audience (RFC 8707).",
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "grant_type": {
                "type": "string",
                "enum": [
                  "authorization_code"
                ]
              },
              "code": {
                "type": "string"
              },
              "redirect_uri": {
                "type": "string",
                "description": "Optional (OAuth 2.1 §10.2): PKCE already binds the code to the client. If sent, it\nmust equal the `redirect_uri` of the authorization request byte for byte.\n"
              },
              "code_verifier": {
                "type": "string"
              },
              "client_id": {
                "type": "string"
              },
              "client_secret": {
                "type": "string",
                "description": "Confidential clients using `client_secret_post` only."
              },
              "scope": {
                "type": "string"
              },
              "resource": {
                "type": "string",
                "format": "uri",
                "description": "RFC 8707 resource indicator: `https://api.alteg.io/api/v3` or an Altegio MCP\naddress under `https://mcp.alteg.io/pro` (an address ending in `/readonly` caps\nthe scopes at read-only). Compared case-insensitively on scheme and host and\nwithout a trailing slash. Every accepted address yields the same audience\n`https://api.alteg.io/api/v3`; on code exchange it must equal the `resource` of\nthe authorization request.\n"
              }
            },
            "required": [
              "grant_type",
              "code",
              "code_verifier",
              "client_id"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "grant_type": {
                "type": "string",
                "enum": [
                  "refresh_token"
                ]
              },
              "refresh_token": {
                "type": "string"
              },
              "client_id": {
                "type": "string"
              },
              "client_secret": {
                "type": "string",
                "description": "Confidential clients using `client_secret_post` only."
              },
              "scope": {
                "type": "string",
                "description": "Optional. Narrows the new access token within the scopes of the original consent.\nUnknown codes (such as `openid`) are ignored; known scopes outside the consent are\ndropped, and if none of the known scopes is granted the request fails with\n`invalid_scope` and the refresh token is not rotated. Omitted or no known scope:\nevery scope of the consent that is still granted.\n"
              },
              "resource": {
                "type": "string",
                "format": "uri",
                "description": "RFC 8707 resource indicator: `https://api.alteg.io/api/v3` or an Altegio MCP\naddress under `https://mcp.alteg.io/pro`. Compared case-insensitively on scheme\nand host and without a trailing slash. Every accepted address yields the same\naudience `https://api.alteg.io/api/v3`, so on refresh it may differ from the\naddress used at authorization. An address ending in `/readonly` narrows the new\naccess token to read scopes; the next refresh without it gets the full set again.\n"
              }
            },
            "required": [
              "grant_type",
              "refresh_token",
              "client_id"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "grant_type": {
                "type": "string",
                "enum": [
                  "client_credentials"
                ]
              },
              "location_id": {
                "type": "integer",
                "description": "The Location this token acts in. The server resolves the installation from the\nauthenticated OAuth client plus this Location, so one token is always bound to\nexactly one Location. Omit it to get an application token for the application's\nown installation routes.\n"
              },
              "scope": {
                "type": "string"
              },
              "resource": {
                "type": "string",
                "format": "uri",
                "description": "RFC 8707 resource indicator: `https://api.alteg.io/api/v3` or an Altegio MCP\naddress under `https://mcp.alteg.io/pro` (an address ending in `/readonly` caps\nthe scopes at read-only). Compared case-insensitively on scheme and host and\nwithout a trailing slash. Every accepted address yields the same audience\n`https://api.alteg.io/api/v3`; on code exchange it must equal the `resource` of\nthe authorization request.\n"
              }
            },
            "required": [
              "grant_type"
            ],
            "additionalProperties": false
          }
        ]
      },
      "OAuthTokenResponse": {
        "type": "object",
        "properties": {
          "access_token": {
            "type": "string",
            "description": "Opaque access token — never parse it."
          },
          "token_type": {
            "type": "string",
            "enum": [
              "Bearer"
            ]
          },
          "expires_in": {
            "type": "integer",
            "description": "Access token lifetime in seconds (3600)."
          },
          "refresh_token": {
            "type": "string",
            "description": "Rotating refresh token; only issued by the Authorization Code flow."
          },
          "scope": {
            "type": "string",
            "description": "Space-separated scopes carried by the token."
          }
        },
        "required": [
          "access_token",
          "token_type",
          "expires_in"
        ],
        "additionalProperties": false
      },
      "OAuthRevokeRequest": {
        "type": "object",
        "description": "Token revocation request (RFC 7009, form-encoded).",
        "properties": {
          "token": {
            "type": "string",
            "description": "The access or refresh token to revoke."
          },
          "token_type_hint": {
            "type": "string",
            "enum": [
              "access_token",
              "refresh_token"
            ],
            "description": "Optional RFC 7009 hint. Accepted and ignored: the token prefix (`ag_at_`, `ag_rt_`) defines the type."
          },
          "client_id": {
            "type": "string",
            "description": "Required for public clients. Confidential clients send it in HTTP Basic and omit this field."
          }
        },
        "required": [
          "token"
        ],
        "additionalProperties": false
      },
      "OAuthClientRegistrationRequest": {
        "type": "object",
        "description": "Dynamic Client Registration request (RFC 7591).",
        "properties": {
          "client_name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255,
            "description": "Human-readable OAuth client name shown on the consent screen."
          },
          "redirect_uris": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "format": "uri"
            },
            "description": "Redirect URIs, compared **exactly** — no wildcards, no subdomain substitution.\nTwo forms are accepted:\n\n- **Absolute HTTPS** for web-hosted callbacks: `https://app.example.com/oauth/callback`.\n- **Loopback for native and CLI clients** (RFC 8252): `http://127.0.0.1/callback`,\n  `http://[::1]/callback` or `http://localhost/callback`. The **port is dynamic** — it\n  is chosen at runtime and is ignored when matching, so a client does not have to\n  register every port it may bind. The literal IP is preferred; `localhost` is accepted\n  because widely used hosts cannot change it. Any other plain-HTTP host is rejected.\n",
            "maxItems": 10
          },
          "grant_types": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "authorization_code",
                "refresh_token"
              ]
            },
            "default": [
              "authorization_code"
            ]
          },
          "token_endpoint_auth_method": {
            "type": "string",
            "enum": [
              "none"
            ],
            "description": "`none` declares a public client (PKCE only, no secret). A request naming a secret-based method is not refused: the server answers with `none`, and a registered client never gets a secret (RFC 7591 §3.2.1)."
          },
          "scope": {
            "type": "string",
            "description": "Space-separated scopes requested by the client metadata."
          },
          "client_uri": {
            "type": "string",
            "format": "uri",
            "description": "Public client home page URI."
          },
          "logo_uri": {
            "type": "string",
            "format": "uri",
            "description": "Public logo URI for consent UI."
          }
        },
        "required": [
          "client_name",
          "redirect_uris"
        ]
      },
      "OAuthClientRegistrationResponse": {
        "type": "object",
        "description": "Registered client metadata. Public clients receive no `client_secret` and must use Authorization Code + PKCE.",
        "properties": {
          "client_id": {
            "type": "string"
          },
          "client_id_issued_at": {
            "type": "integer",
            "description": "Unix timestamp of registration."
          },
          "client_name": {
            "type": "string"
          },
          "redirect_uris": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri"
            }
          },
          "grant_types": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "authorization_code",
                "refresh_token"
              ]
            }
          },
          "token_endpoint_auth_method": {
            "type": "string",
            "enum": [
              "none"
            ]
          }
        },
        "required": [
          "client_id",
          "client_id_issued_at",
          "redirect_uris",
          "grant_types",
          "token_endpoint_auth_method"
        ],
        "additionalProperties": false
      },
      "OAuthError": {
        "type": "object",
        "description": "OAuth 2.0 error object (RFC 6749 / RFC 7591) — used only by `/oauth/*` endpoints.",
        "properties": {
          "error": {
            "type": "string",
            "description": "OAuth error code (`invalid_request`, `invalid_grant`, `invalid_client`, ...)."
          },
          "error_description": {
            "type": "string"
          }
        },
        "required": [
          "error"
        ],
        "additionalProperties": false
      },
      "User": {
        "type": "object",
        "description": "An Altegio user.",
        "properties": {
          "id": {
            "type": "integer",
            "description": "Altegio user id. Stable for the user and never reused."
          },
          "object": {
            "type": "string",
            "enum": [
              "user"
            ],
            "readOnly": true
          }
        },
        "required": [
          "id",
          "object"
        ],
        "additionalProperties": false
      },
      "AccessibleResource": {
        "type": "object",
        "description": "One resource the current token is granted, with the scopes granted on it.",
        "properties": {
          "object": {
            "type": "string",
            "enum": [
              "accessible_resource"
            ],
            "readOnly": true
          },
          "type": {
            "type": "string",
            "enum": [
              "chain",
              "location"
            ],
            "description": "The grant level. Chain-level (`chain_*`) scopes only ever apply to `chain` entries; unprefixed scopes only to `location` entries."
          },
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string",
            "description": "Name of the location or chain as the business entered it, so a client can tell the resources apart without reading each one."
          },
          "main_chain_id": {
            "type": [
              "integer",
              "null"
            ],
            "description": "The main chain of a location; `null` for a chain entry and for a location without a main chain. A location may belong to several chains, only the main one is reported, and it implies no grant on that chain."
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Scopes granted on this resource. Always a subset of the token scopes."
          }
        },
        "required": [
          "object",
          "type",
          "id",
          "name",
          "main_chain_id",
          "scopes"
        ],
        "additionalProperties": false
      },
      "AccessibleResourceList": {
        "type": "object",
        "properties": {
          "object": {
            "type": "string",
            "enum": [
              "list"
            ],
            "readOnly": true
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AccessibleResource"
            }
          }
        },
        "required": [
          "object",
          "data"
        ],
        "additionalProperties": false
      },
      "Location": {
        "type": "object",
        "description": "A business Location. `timezone`, `country_code`, and `currency` are server-controlled and read-only; `currency` applies to every money field of nested resources.",
        "properties": {
          "id": {
            "type": "integer",
            "readOnly": true
          },
          "object": {
            "type": "string",
            "enum": [
              "location"
            ],
            "readOnly": true
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "HTML fragment as entered in the Altegio editor; untrusted, sanitize it before rendering. `null` when empty."
          },
          "business_type_id": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Business category of the Location."
          },
          "address": {
            "type": [
              "string",
              "null"
            ]
          },
          "coordinates": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "latitude": {
                "type": "number"
              },
              "longitude": {
                "type": "number"
              }
            },
            "required": [
              "latitude",
              "longitude"
            ],
            "additionalProperties": false
          },
          "phones": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Business contact phone numbers in E.164 (`+` and digits, no separators). Numbers that cannot be parsed as E.164 are omitted."
          },
          "site": {
            "type": [
              "string",
              "null"
            ]
          },
          "timezone": {
            "type": "string",
            "readOnly": true,
            "description": "Canonical IANA timezone of the Location (e.g. `Europe/Lisbon`)."
          },
          "currency": {
            "type": "string",
            "readOnly": true,
            "description": "ISO 4217 currency of the Location. Server-controlled."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "readOnly": true,
            "description": "UTC; `null` when the creation date is not stored."
          },
          "city_id": {
            "type": "integer",
            "description": "City dictionary id."
          },
          "country_code": {
            "type": "string",
            "readOnly": true,
            "description": "ISO 3166-1 alpha-2 country code. Derived from city."
          }
        },
        "required": [
          "id",
          "object",
          "name",
          "timezone",
          "country_code",
          "currency",
          "city_id",
          "description",
          "business_type_id",
          "address",
          "coordinates",
          "phones",
          "site",
          "created_at"
        ]
      },
      "LocationUpdate": {
        "type": "object",
        "description": "Merge-patch body for a Location. `timezone`, `country_code`, and `currency` are read-only. `city_id` can only move within the same country.",
        "properties": {
          "name": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "business_type_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "address": {
            "type": [
              "string",
              "null"
            ]
          },
          "coordinates": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "latitude": {
                "type": "number"
              },
              "longitude": {
                "type": "number"
              }
            },
            "required": [
              "latitude",
              "longitude"
            ],
            "additionalProperties": false
          },
          "phones": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "site": {
            "type": [
              "string",
              "null"
            ]
          },
          "city_id": {
            "type": "integer",
            "description": "New city in the same country."
          },
          "language": {
            "type": "string",
            "description": "BCP 47 language tag."
          },
          "datetime_format": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "Service": {
        "type": "object",
        "description": "A bookable service of the Location.",
        "properties": {
          "id": {
            "type": "integer",
            "readOnly": true
          },
          "object": {
            "type": "string",
            "enum": [
              "service"
            ],
            "readOnly": true
          },
          "type": {
            "type": "string",
            "enum": [
              "simple",
              "package"
            ],
            "default": "simple",
            "description": "Service kind. Immutable after creation (`422 field_immutable`). A package service bundles several simple services of the same Location; it appears in the same list and is scheduled by the same `service_id`."
          },
          "package": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ServicePackage"
              },
              {
                "type": "null"
              }
            ],
            "description": "Package settings and components; `null` when `type` is `simple`."
          },
          "name": {
            "type": "string",
            "description": "Internal name shown to the business in Altegio, as the business entered it; not translated."
          },
          "online_booking_name": {
            "type": "string",
            "description": "Client-facing name shown in online booking, as the business entered it; equals `name` when no separate online booking name is set. Not translated."
          },
          "online_booking_description": {
            "type": [
              "string",
              "null"
            ],
            "description": "Description of the service for clients in online booking, as the business entered it in Altegio; plain text. `null` when there is none."
          },
          "category_id": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Service category (`listServiceCategories`); `null` when the category is not listed in this Location."
          },
          "chain_id": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true,
            "description": "Id of the chain that manages the service; `null` for a service of this Location alone. A chain service is edited in the chain: `updateService` fails with `422 field_immutable` on the fields the chain manages, `deleteService` with `409 conflict`."
          },
          "duration_seconds": {
            "type": "integer",
            "description": "Default duration of the service in seconds (the Location-wide default, `3600` when none is set). For a package, Altegio computes it from the components."
          },
          "weight": {
            "type": "integer",
            "readOnly": true,
            "description": "Display order the business set in Altegio (higher first). Lists are ordered by `id`; sort by `weight` on the client. A service created through `createService` gets `0`, like one created in Altegio."
          },
          "currency": {
            "type": "string",
            "readOnly": true,
            "description": "ISO 4217, server-controlled by the Location."
          },
          "online_booking_enabled": {
            "type": "boolean",
            "description": "The business's online booking setting for this service in the Location. It does not mean that free time is available; free slots come from the availability operations."
          },
          "team_member_ids": {
            "type": "array",
            "items": {
              "type": "integer"
            },
            "readOnly": true,
            "description": "Team Members providing this service. Read-only here; links are written through `updateTeamMemberServices`."
          },
          "team_members": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ServiceTeamMemberLink"
            },
            "readOnly": true,
            "description": "Settings of each Team Member from `team_member_ids` for this service. Present only when requested with `include[]=team_members`."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "readOnly": true,
            "description": "UTC; `null` when the creation date is not stored."
          },
          "price_min_minor": {
            "type": "integer",
            "description": "Base price of the service in this Location, integer minor units of the Location currency, as set by the business: a single price or the lower bound of a range; `0` for a free service and for an \"up to Y\" price. For a package, the package price stored in Altegio. Team Member prices by grade can differ."
          },
          "price_max_minor": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Upper bound of the base price, integer minor units of the Location currency. Equals `price_min_minor` for a single price; greater for a range from `price_min_minor` to this value, or for an \"up to Y\" price when `price_min_minor` is `0`; `0` for a free service (both bounds `0`); `null` for a \"from X\" price without an upper bound (`price_min_minor` above `0`)."
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "name",
          "online_booking_name",
          "online_booking_description",
          "category_id",
          "chain_id",
          "duration_seconds",
          "weight",
          "price_min_minor",
          "price_max_minor",
          "currency",
          "online_booking_enabled",
          "team_member_ids",
          "package",
          "created_at"
        ]
      },
      "ServiceTeamMemberLink": {
        "type": "object",
        "description": "Settings of a Team Member for the service, returned with `include[]=team_members`.",
        "properties": {
          "team_member_id": {
            "type": "integer"
          },
          "duration_seconds": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Own duration of the service for this Team Member in seconds, as set in Altegio; `null` when no own duration is set and the service `duration_seconds` applies. Always `null` for a package: the package `duration_seconds` applies; the exact window depends on who performs each component (`package.exec_order`) and comes from availability."
          },
          "price_min_minor": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Own price of this Team Member for the service, integer minor units of the Location currency: a single price or the lower bound of a range. For a simple service it comes from the Team Member's price grade, otherwise from the price set for their position. For a package it is the price Altegio computes for this Team Member from their own prices on the components and the package pricing; a package with a manual price has none. `null` when the Team Member has no own price and the service price applies."
          },
          "price_max_minor": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Upper bound of the Team Member's own price, integer minor units; equals `price_min_minor` for a single price; `null` for a \"from\" price or when the service price applies."
          },
          "online_booking_enabled": {
            "type": "boolean",
            "description": "Whether online booking of this service is enabled for this Team Member in Altegio. It does not mean that free time is available."
          }
        },
        "required": [
          "team_member_id",
          "duration_seconds",
          "price_min_minor",
          "price_max_minor",
          "online_booking_enabled"
        ],
        "additionalProperties": false
      },
      "TeamMemberServiceLink": {
        "type": "object",
        "description": "Service link seen from the Team Member side, with its per-link overrides.",
        "properties": {
          "service_id": {
            "type": "integer"
          },
          "duration_seconds": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Per-member duration override in seconds. `null` uses the service default."
          },
          "price_minor": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Per-member price override, integer minor units. `null` uses the service default."
          },
          "bill_of_materials_id": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Per-link technological card override; `null` uses the service default."
          },
          "is_bookable": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Per-link online scheduling flag override; `null` uses the service default."
          },
          "online_booking_enabled": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Per-link public scheduling availability override; `null` uses the service default."
          }
        },
        "required": [
          "service_id"
        ],
        "additionalProperties": false
      },
      "ServiceCreate": {
        "type": "object",
        "description": "Request body for `createService`. Use the schema selector to switch between the `simple` and `package` variants. In the right code panel, switch the example dropdown to view the corresponding curl payload.",
        "oneOf": [
          {
            "$ref": "#/components/schemas/SimpleServiceCreate"
          },
          {
            "$ref": "#/components/schemas/PackageServiceCreate"
          }
        ],
        "discriminator": {
          "propertyName": "type",
          "mapping": {
            "simple": "#/components/schemas/SimpleServiceCreate",
            "package": "#/components/schemas/PackageServiceCreate"
          }
        }
      },
      "SimpleServiceCreate": {
        "type": "object",
        "description": "A simple bookable service.",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "simple"
            ],
            "example": "simple",
            "description": "Service kind. Immutable after creation."
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 16000,
            "description": "Internal name shown to the business in Altegio. A link (a URL or any `word.word` without a space, such as `Dr.Lash`) fails with `422`, as do a blank name, a name of `0` alone, and characters outside the Basic Multilingual Plane (emoji)."
          },
          "online_booking_name": {
            "type": [
              "string",
              "null"
            ],
            "minLength": 1,
            "maxLength": 16000,
            "description": "Client-facing name for online booking. Omit it or send `null` to show `name`; an empty or blank string and `0` alone fail with `422`. A link (a URL or any `word.word` without a space, such as `Dr.Lash`) fails with `422`. Characters outside the Basic Multilingual Plane (emoji) fail with `422`."
          },
          "online_booking_description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 16000,
            "description": "Description of the service for clients in online booking. Plain text. A `<` must be followed by a space: Altegio treats any other `<` as the start of an HTML tag and drops everything up to the next `>`, or to the end of the text, so such a value fails with `422`. `null` or an empty string stores no description. Characters outside the Basic Multilingual Plane (emoji) fail with `422`."
          },
          "category_id": {
            "type": "integer",
            "description": "A category listed by `listServiceCategories` in this Location, other than a chain category. Any other id fails with `422 validation_failed` at `/category_id`."
          },
          "online_booking_enabled": {
            "type": "boolean",
            "default": true,
            "description": "Whether clients can book the service online."
          },
          "duration_seconds": {
            "type": "integer",
            "minimum": 0,
            "maximum": 86400,
            "multipleOf": 300,
            "description": "Duration in seconds, from `0` to `86400` in 5-minute steps; `0` for a service without a duration."
          },
          "price_min_minor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 99999999999999,
            "description": "Price, or the lower bound of a price range, in integer minor units of the Location currency; `0` for a free service."
          },
          "price_max_minor": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "maximum": 99999999999999,
            "description": "Upper bound of the price in integer minor units. Omit it for a single price (stored equal to `price_min_minor`); send `null` for a \"from X\" price without an upper bound. A value below `price_min_minor` fails with `422`."
          }
        },
        "required": [
          "type",
          "name",
          "category_id",
          "duration_seconds",
          "price_min_minor"
        ],
        "additionalProperties": false
      },
      "PackageServiceCreate": {
        "type": "object",
        "description": "A package of simple services of the same Location. Altegio computes its duration from the components and, unless `package.pricing_type` is `manual`, its price; `duration_seconds` is not accepted.",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "package"
            ],
            "example": "package",
            "description": "Service kind. Immutable after creation."
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 16000,
            "description": "Internal name shown to the business in Altegio. A link (a URL or any `word.word` without a space, such as `Dr.Lash`) fails with `422`, as do a blank name, a name of `0` alone, and characters outside the Basic Multilingual Plane (emoji)."
          },
          "online_booking_name": {
            "type": [
              "string",
              "null"
            ],
            "minLength": 1,
            "maxLength": 16000,
            "description": "Client-facing name for online booking. Omit it or send `null` to show `name`; an empty or blank string and `0` alone fail with `422`. A link (a URL or any `word.word` without a space, such as `Dr.Lash`) fails with `422`. Characters outside the Basic Multilingual Plane (emoji) fail with `422`."
          },
          "online_booking_description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 16000,
            "description": "Description of the package for clients in online booking. Plain text. A `<` must be followed by a space: Altegio treats any other `<` as the start of an HTML tag and drops everything up to the next `>`, or to the end of the text, so such a value fails with `422`. `null` or an empty string stores no description. Characters outside the Basic Multilingual Plane (emoji) fail with `422`."
          },
          "category_id": {
            "type": "integer",
            "description": "A category listed by `listServiceCategories` in this Location, other than a chain category. Any other id fails with `422 validation_failed` at `/category_id`."
          },
          "online_booking_enabled": {
            "type": "boolean",
            "default": true,
            "description": "Whether clients can book the package online."
          },
          "package": {
            "$ref": "#/components/schemas/ServicePackageCreate"
          },
          "price_min_minor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 99999999999999,
            "description": "Package price, or the lower bound of a price range, in integer minor units of the Location currency. Required when `package.pricing_type` is `manual`; with `sum` or `discount` Altegio computes the price and this field fails with `422`."
          },
          "price_max_minor": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "maximum": 99999999999999,
            "description": "Upper bound of the package price, only when `package.pricing_type` is `manual`, with the rules of a simple service. With `sum` or `discount` it fails with `422`."
          }
        },
        "required": [
          "type",
          "name",
          "category_id",
          "package"
        ],
        "additionalProperties": false
      },
      "ServiceUpdate": {
        "type": "object",
        "description": "Merge-patch body for a service; a missing field is left unchanged. `null` is accepted only by `online_booking_name`, `online_booking_description`, and `price_max_minor`; on any other field it fails with `422 field_not_nullable`. Read-only fields of `Service` (`id`, `object`, `chain_id`, `currency`, `weight`, `team_member_ids`, `team_members`, `created_at`) fail with `422 field_immutable`; unknown fields with `422 validation_failed` and field code `unknown_field`. Team Member links are written through `updateTeamMemberServices`; a package change also relinks the package (see `updateService`).",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "simple",
              "package"
            ],
            "description": "Immutable. The current value is accepted; another value fails with `422 field_immutable`."
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 16000,
            "description": "Internal name shown to the business in Altegio. A link (a URL or any `word.word` without a space, such as `Dr.Lash`) fails with `422`, as do a blank name, a name of `0` alone, and characters outside the Basic Multilingual Plane (emoji)."
          },
          "online_booking_name": {
            "type": [
              "string",
              "null"
            ],
            "minLength": 1,
            "maxLength": 16000,
            "description": "Client-facing name for online booking; `null` removes it, and online booking shows `name` again. An empty or blank string and `0` alone fail with `422`. A link (a URL or any `word.word` without a space, such as `Dr.Lash`) fails with `422`. Characters outside the Basic Multilingual Plane (emoji) fail with `422`."
          },
          "online_booking_description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 16000,
            "description": "Description for clients in online booking. Plain text. A `<` must be followed by a space: Altegio treats any other `<` as the start of an HTML tag and drops everything up to the next `>`, or to the end of the text, so such a value fails with `422`. `null` or an empty string removes the description. Characters outside the Basic Multilingual Plane (emoji) fail with `422`."
          },
          "category_id": {
            "type": "integer",
            "description": "A category listed by `listServiceCategories` in this Location, other than a chain category. Any other id fails with `422 validation_failed` at `/category_id`."
          },
          "online_booking_enabled": {
            "type": "boolean",
            "description": "Whether clients can book the service online. A change also switches online booking for every Team Member link of the service."
          },
          "duration_seconds": {
            "type": "integer",
            "minimum": 0,
            "maximum": 86400,
            "multipleOf": 300,
            "description": "Default duration in seconds, from `0` to `86400` in 5-minute steps. Set on a simple service; a package computes it from the components, and sending it for a package fails with `422 field_immutable`."
          },
          "price_min_minor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 99999999999999,
            "description": "Price, or the lower bound of a price range, in integer minor units of the Location currency. For a package, only when the resulting `package.pricing_type` is `manual`; sending the stored value passes."
          },
          "price_max_minor": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "maximum": 99999999999999,
            "description": "Upper bound of the price in integer minor units; `null` makes a \"from X\" price. A value below the resulting `price_min_minor` fails with `422`. For a package, only when the resulting `package.pricing_type` is `manual`; sending the stored value passes."
          },
          "package": {
            "$ref": "#/components/schemas/ServicePackageUpdate"
          }
        },
        "additionalProperties": false
      },
      "ServicePackage": {
        "type": "object",
        "description": "Package settings and components of a service with `type: package`.",
        "properties": {
          "exec_order": {
            "type": "string",
            "enum": [
              "sequential",
              "sequential_multi",
              "parallel"
            ],
            "description": "Order in which component services are performed."
          },
          "pricing_type": {
            "type": "string",
            "enum": [
              "sum",
              "manual",
              "discount"
            ],
            "description": "How the package price is set: `sum` — the sum of the component prices; `discount` — that sum less `price_discount_percent`; `manual` — set by the business."
          },
          "price_discount_percent": {
            "type": "number",
            "description": "Discount applied to the component sum; used only when `pricing_type` is `discount`, ignored otherwise."
          },
          "components": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ServicePackageComponent"
            },
            "description": "Component services in execution order (`position`); the same service can appear more than once. A `ready` package has 2 to 10 components, and a `not_configured` package can have fewer; the exception is a package whose component service was deleted (see `status`). Components whose service is no longer listed in this Location are omitted.",
            "maxItems": 10
          },
          "status": {
            "type": "string",
            "enum": [
              "not_configured",
              "ready"
            ],
            "readOnly": true,
            "description": "Read-only package configuration status. `not_configured` when the package has fewer than 2 components, when its components and the package differ in group-event mode, or when `exec_order` is not available to the Team Members of the components; a package created or updated in such a state is saved without an error. Deleting a component service updates only the duration, not the status or the price, so a `ready` package can list fewer than 2 components until a later change of `package` or of its price."
          }
        },
        "required": [
          "exec_order",
          "pricing_type",
          "price_discount_percent",
          "status",
          "components"
        ],
        "additionalProperties": false
      },
      "ServicePackageCreate": {
        "type": "object",
        "description": "Package settings sent when a package service is created.",
        "properties": {
          "exec_order": {
            "type": "string",
            "enum": [
              "sequential",
              "sequential_multi",
              "parallel"
            ],
            "description": "Order in which component services are performed."
          },
          "pricing_type": {
            "type": "string",
            "enum": [
              "sum",
              "manual",
              "discount"
            ],
            "description": "How the package price is set: `sum` — the sum of the component prices; `discount` — that sum less `price_discount_percent`; `manual` — `price_min_minor` and `price_max_minor` of the request."
          },
          "price_discount_percent": {
            "type": "number",
            "exclusiveMinimum": 0,
            "maximum": 100,
            "multipleOf": 0.01,
            "description": "Discount on the component sum, in percent with at most two decimal places. Required when `pricing_type` is `discount`; with another `pricing_type` it fails with `422`."
          },
          "components": {
            "type": "array",
            "minItems": 2,
            "maxItems": 10,
            "items": {
              "$ref": "#/components/schemas/ServicePackageComponentCreate"
            },
            "description": "Component services in execution order; the same service may appear more than once."
          }
        },
        "required": [
          "exec_order",
          "pricing_type",
          "components"
        ],
        "additionalProperties": false
      },
      "ServicePackageUpdate": {
        "type": "object",
        "description": "Merge-patch of the package settings, for package services only: a missing field is left unchanged, `null` fails with `422 field_not_nullable`. The rules of `ServicePackageCreate` apply to the resulting package: `price_discount_percent` only with a resulting `pricing_type` of `discount`, the service prices only with `manual`; sending a stored value passes. Switching to `manual` without a price keeps the stored price. `status` and the component fields `id` and `position` are read-only and fail with `422 field_immutable`; the order of a component is its place in `components`.",
        "properties": {
          "exec_order": {
            "type": "string",
            "enum": [
              "sequential",
              "sequential_multi",
              "parallel"
            ],
            "description": "Order in which component services are performed."
          },
          "pricing_type": {
            "type": "string",
            "enum": [
              "sum",
              "manual",
              "discount"
            ],
            "description": "How the package price is set: `sum` — the sum of the component prices; `discount` — that sum less `price_discount_percent`; `manual` — `price_min_minor` and `price_max_minor` of the service."
          },
          "price_discount_percent": {
            "type": "number",
            "minimum": 0,
            "maximum": 100,
            "multipleOf": 0.01,
            "description": "Discount on the component sum, in percent with at most two decimal places. Sending the stored value, including `0`, passes without changing it. A changed value is accepted only when the resulting `pricing_type` is `discount` and the percent is above `0`; otherwise it fails with `422 invalid_value` at `/package/price_discount_percent`."
          },
          "components": {
            "type": "array",
            "minItems": 2,
            "maxItems": 10,
            "items": {
              "$ref": "#/components/schemas/ServicePackageComponentCreate"
            },
            "description": "Replaces the whole component list, in execution order. Altegio recalculates the package duration and status and, with `sum` or `discount` pricing, the price."
          }
        },
        "additionalProperties": false
      },
      "ServicePackageComponent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "readOnly": true,
            "description": "Stable package-component identifier used by availability and package appointment creation."
          },
          "service_id": {
            "type": "integer",
            "description": "A `simple` service of the same Location."
          },
          "position": {
            "type": "integer",
            "readOnly": true,
            "description": "1-based order of the component, set by its place in `components` of the request."
          }
        },
        "required": [
          "id",
          "service_id",
          "position"
        ],
        "additionalProperties": false
      },
      "ServicePackageComponentCreate": {
        "type": "object",
        "description": "A package component; its order is its place in `components`.",
        "properties": {
          "service_id": {
            "type": "integer",
            "description": "A `simple` service listed by `listServices` in this Location, not a group-event service. Any other id fails with the same `422 validation_failed` at `/package/components/N/service_id`, whether the service belongs to another Location, is deleted, or does not exist."
          }
        },
        "required": [
          "service_id"
        ],
        "additionalProperties": false
      },
      "ServiceCategory": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "readOnly": true
          },
          "object": {
            "type": "string",
            "enum": [
              "service_category"
            ],
            "readOnly": true
          },
          "name": {
            "type": "string"
          },
          "chain_id": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true,
            "description": "Id of the chain that manages the category; `null` for a category of this Location alone. A chain category is not accepted by `createService` or `updateService`."
          },
          "weight": {
            "type": "integer",
            "description": "Display order the business set in Altegio (higher first). Lists are ordered by `id`; sort by `weight` on the client."
          }
        },
        "required": [
          "id",
          "object",
          "name",
          "chain_id",
          "weight"
        ]
      },
      "ServiceCategoryCreate": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 16000,
            "description": "Name of the category. Leading and trailing spaces are trimmed. A link (a URL or any `word.word` without a space), an empty name and characters outside the Basic Multilingual Plane (emoji) fail with `422`."
          },
          "weight": {
            "type": "integer",
            "minimum": 0,
            "maximum": 2147483647,
            "description": "Display order (higher first). Defaults to the highest `weight` among the services and categories of the Location plus one, but not more than `2147483647`."
          }
        },
        "required": [
          "name"
        ],
        "additionalProperties": false
      },
      "ServiceCategoryUpdate": {
        "type": "object",
        "description": "Merge-patch body for a service category. `null` on any field fails with `422 field_not_nullable`. Read-only fields of `ServiceCategory` (`id`, `object`, `chain_id`) fail with `422 field_immutable`; unknown fields with `422 validation_failed` and field code `unknown_field`.",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 16000,
            "description": "Name of the category. Leading and trailing spaces are trimmed. A link (a URL or any `word.word` without a space), an empty name and characters outside the Basic Multilingual Plane (emoji) fail with `422`. Immutable for a category managed by its chain."
          },
          "weight": {
            "type": "integer",
            "minimum": 0,
            "maximum": 2147483647,
            "description": "Display order (higher first)."
          }
        },
        "additionalProperties": false
      },
      "TeamMember": {
        "type": "object",
        "description": "A Team Member of the Location. Personal contact data of Team Members is not exposed in the preview scope.",
        "properties": {
          "id": {
            "type": "integer",
            "readOnly": true
          },
          "object": {
            "type": "string",
            "enum": [
              "team_member"
            ],
            "readOnly": true
          },
          "name": {
            "type": "string",
            "description": "Display name, HTML entities decoded."
          },
          "specialization": {
            "type": "string",
            "description": "Public profession label shown to clients (for example in online booking), HTML entities decoded."
          },
          "avatar_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "readOnly": true,
            "description": "Photo of the team member, up to 220×220 px (smaller when the uploaded photo is smaller); `null` when no photo is set."
          },
          "position_id": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Position from `listPositions`; `null` when the member has no position or the position is not listed by `listPositions`."
          },
          "online_booking_enabled": {
            "type": "boolean",
            "description": "The business's online booking setting for this team member in the Location. It does not mean that free time is available; free slots come from the availability operations."
          },
          "dismissal_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "readOnly": true,
            "description": "Last working day set by `dismissTeamMember`, `YYYY-MM-DD` in the Location timezone; `null` while employed."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "readOnly": true,
            "description": "UTC; `null` for legacy records without a creation date."
          }
        },
        "required": [
          "id",
          "object",
          "name",
          "specialization",
          "avatar_url",
          "position_id",
          "online_booking_enabled",
          "dismissal_date",
          "created_at"
        ]
      },
      "TeamMemberCreate": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "specialization": {
            "type": "string",
            "minLength": 1,
            "description": "Public profession label shown to clients (for example in online booking)."
          },
          "position_id": {
            "type": "integer"
          },
          "is_billable": {
            "type": "boolean",
            "default": false,
            "description": "Whether the new Team Member takes a paid seat in the Location's licence. Defaults to\n`false`, so a plain create never changes what the Location is charged: the member is\ncreated without schedule access and is not bookable. Send `true` to create a bookable\nmember and accept the licence charge — the create fails with `422` when the licence has\nno free paid seat. Locations on the older licensing model ignore this field."
          }
        },
        "required": [
          "name",
          "specialization"
        ],
        "additionalProperties": false
      },
      "TeamMemberUpdate": {
        "type": "object",
        "description": "Merge-patch body for a Team Member card. Service links are written through `updateTeamMemberServices`, dismissal through `dismissTeamMember`; neither is a field of the card.",
        "properties": {
          "name": {
            "type": "string"
          },
          "specialization": {
            "type": "string",
            "minLength": 1,
            "description": "Public profession label shown to clients (for example in online booking)."
          },
          "position_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "is_billable": {
            "type": "boolean",
            "description": "Moves the Team Member on or off a paid seat in the Location's licence, changing what the\nLocation is charged. Turning it on fails with `422` when the licence has no free paid\nseat; turning it off also drops schedule access, because a non-billable member cannot be\nbookable. Locations on the older licensing model ignore this field."
          }
        },
        "additionalProperties": false
      },
      "TeamMemberDismissRequest": {
        "type": "object",
        "description": "Body of the `dismissTeamMember` command.",
        "properties": {
          "dismissal_date": {
            "type": "string",
            "format": "date",
            "description": "Last working day, `YYYY-MM-DD` in the Location timezone. Defaults to today."
          },
          "reason": {
            "type": "string",
            "description": "Free-form dismissal reason stored on the Team Member."
          }
        },
        "additionalProperties": false
      },
      "TeamMemberServiceLinkPatch": {
        "type": "object",
        "description": "Per-link overrides for one service. Every field is optional; `null` falls back to the service default.",
        "properties": {
          "duration_seconds": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Per-member duration override in seconds."
          },
          "price_minor": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Per-member price override, integer minor units of the Location currency."
          },
          "bill_of_materials_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "is_bookable": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "online_booking_enabled": {
            "type": [
              "boolean",
              "null"
            ]
          }
        },
        "additionalProperties": false
      },
      "TeamMemberServicesPatch": {
        "type": "object",
        "description": "Merge-patch map keyed by `service_id`: the value creates or updates the link with its overrides, `null` unlinks the service. Services absent from the body are left unchanged. This is the only place where the Team Member ↔ service link is written.",
        "propertyNames": {
          "pattern": "^[1-9][0-9]*$"
        },
        "additionalProperties": {
          "oneOf": [
            {
              "$ref": "#/components/schemas/TeamMemberServiceLinkPatch"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "TeamMemberServiceLinkList": {
        "description": "All current service links of a Team Member.",
        "allOf": [
          {
            "$ref": "#/components/schemas/ListEnvelope"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/TeamMemberServiceLink"
                }
              }
            },
            "required": [
              "data"
            ]
          }
        ]
      },
      "WorkInterval": {
        "type": "object",
        "properties": {
          "from": {
            "type": "string",
            "pattern": "^([01][0-9]|2[0-3]):[0-5][0-9]$",
            "description": "Start of the working interval, wall-clock `HH:MM` in the Location timezone."
          },
          "to": {
            "type": "string",
            "pattern": "^(([01][0-9]|2[0-3]):[0-5][0-9]|24:00)$",
            "description": "End of the working interval, wall-clock `HH:MM` in the Location timezone. `24:00` denotes end of day, for shifts running until midnight."
          }
        },
        "required": [
          "from",
          "to"
        ],
        "additionalProperties": false
      },
      "ScheduleDay": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "format": "date"
          },
          "intervals": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkInterval"
            },
            "description": "Working intervals of the day; empty means a day off."
          }
        },
        "required": [
          "date",
          "intervals"
        ]
      },
      "ScheduleDayPatch": {
        "type": "object",
        "properties": {
          "intervals": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkInterval"
            }
          }
        },
        "required": [
          "intervals"
        ],
        "additionalProperties": false
      },
      "TeamMemberSchedulePatch": {
        "type": "object",
        "description": "Merge-patch map keyed by `YYYY-MM-DD` date. A present date replaces that day's working intervals; `null` clears the day. Dates absent from the body are unchanged.",
        "patternProperties": {
          "^[0-9]{4}-[0-9]{2}-[0-9]{2}$": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ScheduleDayPatch"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "additionalProperties": false
      },
      "Position": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "readOnly": true
          },
          "object": {
            "type": "string",
            "enum": [
              "position"
            ],
            "readOnly": true
          },
          "title": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "object",
          "title"
        ]
      },
      "PositionCreate": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string"
          }
        },
        "required": [
          "title"
        ],
        "additionalProperties": false
      },
      "PositionUpdate": {
        "type": "object",
        "description": "Merge-patch body for a position.",
        "properties": {
          "title": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "Client": {
        "type": "object",
        "description": "A client of the Location. Contact fields (`phone`, `additional_phone`, `email`) require `clients:read_contact` plus the contact permission of the token subject; `surname` and `patronymic` require the subject's permission to see client surnames; `comment` requires the subject's client card comment permission. A withheld field is returned as `null` and its name is listed in `redacted_fields` instead of exposing the value.",
        "properties": {
          "id": {
            "type": "integer",
            "readOnly": true
          },
          "object": {
            "type": "string",
            "enum": [
              "client"
            ],
            "readOnly": true
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name as entered in the client card (a business without the surname field often enters the full name here), HTML entities decoded; `null` when empty."
          },
          "surname": {
            "type": [
              "string",
              "null"
            ],
            "description": "Surname. `null` when empty, when the Location has the surname field turned off, or when withheld — see `redacted_fields`."
          },
          "patronymic": {
            "type": [
              "string",
              "null"
            ],
            "description": "Patronymic or middle name. `null` when empty, when the Location has the patronymic field turned off, or when withheld — see `redacted_fields`."
          },
          "phone": {
            "type": [
              "string",
              "null"
            ],
            "description": "Phone number in international format with a leading `+`. `null` when absent or withheld — see `redacted_fields`."
          },
          "additional_phone": {
            "type": [
              "string",
              "null"
            ],
            "description": "Additional phone number in international format with a leading `+`. Uses the same contact access as `phone`; `null` when absent or withheld."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Email address. `null` when absent or withheld — see `redacted_fields`."
          },
          "comment": {
            "type": [
              "string",
              "null"
            ],
            "description": "Comment from the client card, HTML entities decoded, available to partner frontends with the client card comment permission (`clients_card_comment_access`). Independent of contact access; `null` when empty or withheld — see `redacted_fields`."
          },
          "card_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "Card number as stored in the client card, HTML entities decoded; `null` when empty."
          },
          "gender": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "male",
              "female",
              null
            ],
            "description": "Gender stored in the client card; `null` when unspecified."
          },
          "importance": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "bronze",
              "silver",
              "gold",
              null
            ],
            "description": "Importance level stored in the client card; `null` when unspecified. This is not a recalculated loyalty tier."
          },
          "birth_day": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "maximum": 31,
            "description": "Stored day of birth; `null` when unknown or outside the range. Returned independently of the other birth parts without constructing a date."
          },
          "birth_month": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "maximum": 12,
            "description": "Stored month of birth; `null` when unknown or outside the range."
          },
          "birth_year": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "maximum": 9999,
            "description": "Stored year of birth; `null` when unknown or outside the range. No substitute year is invented."
          },
          "discount_percent": {
            "type": "number",
            "minimum": 0,
            "maximum": 100,
            "description": "Personal discount set in the client card, percent; `0` when none."
          },
          "visits_count": {
            "type": "integer",
            "readOnly": true,
            "description": "Number of visits the client attended (marked as arrived), as in the client base of the Location."
          },
          "first_visit_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "readOnly": true,
            "description": "Start of the first attended visit, Location-local offset; `null` without attended visits."
          },
          "last_visit_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "readOnly": true,
            "description": "Start of the latest attended visit, Location-local offset; `null` without attended visits."
          },
          "sold_amount_minor": {
            "type": "integer",
            "readOnly": true,
            "description": "Lifetime sold amount, as in the client base of the Location: services of attended appointments and goods sold to the client, plus the amount imported with the client. Integer minor units of `currency`."
          },
          "currency": {
            "type": "string",
            "readOnly": true,
            "description": "ISO 4217, server-controlled by the Location."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "readOnly": true,
            "description": "UTC; `null` for legacy records without a creation date."
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "readOnly": true,
            "description": "UTC. Last change of the client card; `null` for legacy records without a change date."
          },
          "redacted_fields": {
            "type": "array",
            "readOnly": true,
            "items": {
              "type": "string"
            },
            "description": "Names of fields withheld for this object: `phone`, `additional_phone` and `email` without contact access,\n`surname` and `patronymic` without the permission to see client surnames, and `comment`\nwithout the client card comment permission. A withheld\nfield is always returned as `null` — never as a masked, shortened or empty string, so\nan integration cannot write a mask back. An empty array means nothing was withheld\nand a `null` value simply means no value is stored.\n"
          }
        },
        "required": [
          "id",
          "object",
          "name",
          "surname",
          "patronymic",
          "phone",
          "additional_phone",
          "email",
          "comment",
          "card_number",
          "gender",
          "importance",
          "birth_day",
          "birth_month",
          "birth_year",
          "discount_percent",
          "visits_count",
          "first_visit_at",
          "last_visit_at",
          "sold_amount_minor",
          "currency",
          "created_at",
          "updated_at",
          "redacted_fields"
        ]
      },
      "ClientCreate": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "phone": {
            "type": "string",
            "description": "International format. Deduplicated within the Location (`422 phone_taken`)."
          },
          "surname": {
            "type": "string"
          },
          "patronymic": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "additional_phone": {
            "type": "string"
          },
          "birth_date": {
            "type": "string",
            "format": "date"
          },
          "comment": {
            "type": "string"
          },
          "discount": {
            "type": "number",
            "description": "Personal discount, percent."
          }
        },
        "required": [
          "name",
          "phone"
        ],
        "additionalProperties": false
      },
      "ClientUpdate": {
        "type": "object",
        "description": "Merge-patch body for a client. `null` clears a nullable field.",
        "properties": {
          "name": {
            "type": "string"
          },
          "phone": {
            "type": "string",
            "description": "`422 phone_taken` when owned by another client."
          },
          "surname": {
            "type": [
              "string",
              "null"
            ]
          },
          "patronymic": {
            "type": [
              "string",
              "null"
            ]
          },
          "email": {
            "type": [
              "string",
              "null"
            ]
          },
          "additional_phone": {
            "type": [
              "string",
              "null"
            ]
          },
          "birth_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "comment": {
            "type": [
              "string",
              "null"
            ]
          },
          "discount": {
            "type": [
              "number",
              "null"
            ]
          }
        },
        "additionalProperties": false
      },
      "AvailabilitySlot": {
        "type": "object",
        "description": "A free start time of one Team Member. Not addressable — slots have no id.",
        "properties": {
          "team_member_id": {
            "type": "integer"
          },
          "starts_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339 with the Location's local UTC offset; pass directly to `createAppointment`."
          },
          "duration_seconds": {
            "type": "integer",
            "description": "Duration of the requested services when this Team Member performs them, in seconds."
          }
        },
        "required": [
          "team_member_id",
          "starts_at",
          "duration_seconds"
        ]
      },
      "Resource": {
        "type": "object",
        "description": "A bookable resource of the Location with its instances.",
        "properties": {
          "id": {
            "type": "integer",
            "readOnly": true
          },
          "object": {
            "type": "string",
            "enum": [
              "resource"
            ],
            "readOnly": true
          },
          "title": {
            "type": "string"
          },
          "instances": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceInstance"
            }
          }
        },
        "required": [
          "id",
          "object",
          "title",
          "instances"
        ]
      },
      "ResourceInstance": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "object": {
            "type": "string",
            "enum": [
              "resource_instance"
            ]
          },
          "title": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "object",
          "title"
        ]
      },
      "AppointmentStatus": {
        "type": "string",
        "description": "Status of an appointment. `waiting` — scheduled, not yet confirmed; `confirmed` — confirmed by the client; `arrived` — the client attended (terminal \"done\" state); `no_show` — the client did not attend; `cancelled` — cancelled via the cancel command (never set through the status command).",
        "enum": [
          "waiting",
          "confirmed",
          "arrived",
          "no_show",
          "cancelled"
        ]
      },
      "Appointment": {
        "type": "object",
        "description": "A scheduled appointment. `visit_id` remains a response field and can be `null`; payment and visit operations are keyed by `appointment_id`.",
        "properties": {
          "id": {
            "type": "integer",
            "readOnly": true
          },
          "object": {
            "type": "string",
            "enum": [
              "appointment"
            ],
            "readOnly": true
          },
          "location_id": {
            "type": "integer",
            "readOnly": true
          },
          "client_id": {
            "type": [
              "integer",
              "null"
            ],
            "description": "`null` only on appointments without a client."
          },
          "visit_id": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true,
            "description": "Billing visit of this appointment."
          },
          "team_member_id": {
            "type": "integer"
          },
          "service_ids": {
            "type": "array",
            "items": {
              "type": "integer"
            }
          },
          "resource_instance_ids": {
            "type": "array",
            "items": {
              "type": "integer"
            },
            "description": "Resource instances occupied by the appointment."
          },
          "status": {
            "$ref": "#/components/schemas/AppointmentStatus"
          },
          "starts_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339 with the Location's local UTC offset."
          },
          "ends_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true,
            "description": "RFC 3339 with the Location's local UTC offset."
          },
          "duration_seconds": {
            "type": "integer"
          },
          "is_paid": {
            "type": "boolean",
            "readOnly": true,
            "description": "Whether the visit of this appointment is fully paid."
          },
          "comment": {
            "type": [
              "string",
              "null"
            ]
          },
          "cancelled_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "readOnly": true,
            "description": "UTC; set by the cancel command."
          },
          "cancellation_reason": {
            "type": [
              "string",
              "null"
            ],
            "readOnly": true
          },
          "client": {
            "description": "Present only when requested with `include[]=client`; `null` when `client_id` is `null`. PII rules apply.",
            "readOnly": true,
            "oneOf": [
              {
                "$ref": "#/components/schemas/Client"
              },
              {
                "type": "null"
              }
            ]
          },
          "team_member": {
            "description": "Present only when requested with `include[]=team_member`.",
            "readOnly": true,
            "$ref": "#/components/schemas/TeamMember"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true,
            "description": "UTC."
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true,
            "description": "UTC."
          }
        },
        "required": [
          "id",
          "object",
          "location_id",
          "team_member_id",
          "service_ids",
          "status",
          "starts_at",
          "duration_seconds"
        ]
      },
      "AppointmentInlineClient": {
        "type": "object",
        "description": "Inline client for `createAppointment`: attach-only resolver links an existing client by normalized phone without changing the client record, or creates a new client when none exists. It never restores a deleted client and the response does not reveal whether the client was found or created. No `clients:write` scope is required.",
        "properties": {
          "name": {
            "type": "string"
          },
          "phone": {
            "type": "string",
            "description": "International format."
          },
          "email": {
            "type": "string"
          }
        },
        "required": [
          "name",
          "phone"
        ],
        "additionalProperties": false
      },
      "AppointmentCreate": {
        "type": "object",
        "description": "Create an appointment. A client is optional; pass an existing `client_id`, inline `client` data for attach-only resolve-or-create by normalized phone, or neither for a clientless appointment. Package services pass `components[{package_component_id, team_member_id}]`.",
        "properties": {
          "client_id": {
            "type": "integer",
            "description": "An existing client of the Location."
          },
          "client": {
            "$ref": "#/components/schemas/AppointmentInlineClient"
          },
          "team_member_id": {
            "type": "integer"
          },
          "service_ids": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "integer"
            }
          },
          "resource_instance_ids": {
            "type": "array",
            "items": {
              "type": "integer"
            },
            "description": "Required by services that occupy a resource (`listResources`)."
          },
          "starts_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339 with the Location's local UTC offset (take it from availability)."
          },
          "duration_seconds": {
            "type": "integer",
            "description": "Optional override; defaults to the sum of service durations."
          },
          "comment": {
            "type": "string"
          },
          "components": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AppointmentPackageComponentCreate"
            },
            "description": "For package services, selected Team Member per package component."
          }
        },
        "required": [
          "team_member_id",
          "service_ids",
          "starts_at"
        ],
        "additionalProperties": false
      },
      "AppointmentUpdate": {
        "type": "object",
        "description": "Merge-patch body for reschedule/edit. The appointment status is changed through the `status` command; cancellation through the `cancel` command.",
        "properties": {
          "starts_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339 with the Location's local UTC offset."
          },
          "team_member_id": {
            "type": "integer"
          },
          "service_ids": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "integer"
            }
          },
          "resource_instance_ids": {
            "type": "array",
            "items": {
              "type": "integer"
            }
          },
          "duration_seconds": {
            "type": "integer"
          },
          "comment": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "additionalProperties": false
      },
      "AppointmentCancelRequest": {
        "type": "object",
        "properties": {
          "reason": {
            "type": "string",
            "description": "Free-form cancellation reason stored on the appointment."
          },
          "notify_client": {
            "type": "boolean",
            "description": "Whether to send the client a cancellation notification."
          }
        },
        "additionalProperties": false
      },
      "AppointmentStatusRequest": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "description": "Target status. `cancelled` cannot be set here — use the cancel command.",
            "enum": [
              "waiting",
              "confirmed",
              "arrived",
              "no_show"
            ]
          }
        },
        "required": [
          "status"
        ],
        "additionalProperties": false
      },
      "PaymentMethod": {
        "type": "object",
        "description": "A payment method configured for the Location - the cashier setup: what the business accepts\nand how it settles. Returned by `listPaymentMethods`, and it is the only source of\n`payment_method_id` for `createPayment`.\n\nThis schema does not describe whether the method can be used for a particular visit. For\nthat, read `visit.payment_methods` or search an instrument by number - both return\n`ApplicablePaymentMethod`.",
        "properties": {
          "id": {
            "type": "integer",
            "readOnly": true
          },
          "object": {
            "type": "string",
            "enum": [
              "payment_method"
            ],
            "readOnly": true
          },
          "slug": {
            "type": "string",
            "description": "Method kind (e.g. `cash`, `card`, `cashless`)."
          },
          "name": {
            "type": "string"
          },
          "default_account_id": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Account the method settles to unless overridden in the payment."
          },
          "fee_rate": {
            "type": [
              "number",
              "null"
            ],
            "description": "Acquiring fee, percent.",
            "x-altegio-assumption": "Fee percentage remains an open payment-method display question before freeze."
          },
          "card_brands": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CardBrand"
            }
          },
          "installments": {
            "type": "array",
            "items": {
              "type": "integer"
            },
            "description": "Available installment counts; empty when installments are not supported."
          }
        },
        "required": [
          "id",
          "object",
          "slug",
          "name"
        ],
        "additionalProperties": false
      },
      "ApplicablePaymentMethod": {
        "type": "object",
        "description": "A way to pay **this** visit, with applicability resolved against it: a configured method of\nthe Location, a cash account, one of the client's Client Accounts, or one of the client's loyalty\ninstruments. Returned inside `visit.payment_methods` and by `searchLoyaltyInstrument`.\n\nWhich identifier to send to `createPayment` follows `type`: `payment_method` uses\n`payment_method_id`, `account` uses `account_id`, and the loyalty types use their own\ninstrument id together with `number` where the instrument is addressed by number.",
        "properties": {
          "id": {
            "type": "integer",
            "readOnly": true,
            "description": "Identifier of the underlying method or instrument, in the space implied by `type`."
          },
          "object": {
            "type": "string",
            "enum": [
              "applicable_payment_method"
            ],
            "readOnly": true
          },
          "type": {
            "type": "string",
            "description": "Which kind of payment this is, and therefore which identifier `createPayment` expects.",
            "enum": [
              "payment_method",
              "account",
              "deposit",
              "loyalty_card",
              "loyalty_program",
              "gift_card",
              "membership",
              "referral_program"
            ]
          },
          "name": {
            "type": "string"
          },
          "payment_method_id": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true,
            "description": "Set when `type` is `payment_method`; pass it to `createPayment`."
          },
          "account_id": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true,
            "description": "Settlement account, when the type settles to one."
          },
          "number": {
            "type": [
              "string",
              "null"
            ],
            "description": "Instrument number, for gift cards and memberships addressed by number."
          },
          "is_applicable": {
            "type": "boolean",
            "readOnly": true,
            "description": "Whether this visit can be paid with it right now."
          },
          "applicable_amount_minor": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true,
            "description": "How much of this visit it can cover, in integer minor units. `0` for a membership, which covers sessions rather than money."
          },
          "is_partial_allowed": {
            "type": "boolean",
            "readOnly": true,
            "description": "Whether it may cover part of the amount, leaving a remainder for another payment."
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "name",
          "is_applicable"
        ],
        "additionalProperties": false
      },
      "CardBrand": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "title": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "title"
        ]
      },
      "Account": {
        "type": "object",
        "description": "A cash/settlement account of the Location.",
        "properties": {
          "id": {
            "type": "integer",
            "readOnly": true
          },
          "object": {
            "type": "string",
            "enum": [
              "account"
            ],
            "readOnly": true
          },
          "title": {
            "type": "string"
          },
          "type_slug": {
            "type": "string",
            "enum": [
              "cash",
              "cashless"
            ]
          },
          "is_acquiring": {
            "type": "boolean",
            "description": "Whether the account belongs to online acquiring."
          }
        },
        "required": [
          "id",
          "object",
          "title",
          "type_slug"
        ]
      },
      "VisitItem": {
        "type": "object",
        "description": "A line item of a visit.",
        "properties": {
          "id": {
            "type": "integer"
          },
          "object": {
            "type": "string",
            "enum": [
              "visit_item"
            ]
          },
          "type": {
            "type": "string",
            "enum": [
              "service",
              "product"
            ]
          },
          "service_id": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Set for `service` items."
          },
          "product_id": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Set for `product` items."
          },
          "title": {
            "type": "string"
          },
          "quantity": {
            "type": "integer"
          },
          "price_minor": {
            "type": "integer",
            "description": "Unit price in integer minor units."
          },
          "amount_minor": {
            "type": "integer",
            "description": "Line total in integer minor units."
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "title",
          "quantity",
          "price_minor",
          "amount_minor"
        ],
        "additionalProperties": false
      },
      "VisitItemCreate": {
        "type": "object",
        "description": "One product line to append to a visit. Service lines come from the appointment and cannot be created here.",
        "properties": {
          "product_id": {
            "type": "integer",
            "description": "Product identifier from `listProducts`."
          },
          "quantity": {
            "type": "integer",
            "minimum": 1,
            "default": 1
          },
          "price_minor": {
            "type": "integer",
            "description": "Unit price override in integer minor units. Omit to use the catalog price; overriding requires the discount permission and is rejected without it."
          }
        },
        "required": [
          "product_id"
        ],
        "additionalProperties": false
      },
      "Refund": {
        "type": "object",
        "description": "A full local reversal of a payment action. This is not a payment-provider refund contract.",
        "properties": {
          "id": {
            "type": "string",
            "readOnly": true
          },
          "object": {
            "type": "string",
            "enum": [
              "refund"
            ],
            "readOnly": true
          },
          "payment_id": {
            "type": "string",
            "readOnly": true
          },
          "amount_minor": {
            "type": "integer",
            "description": "Reversed amount in minor units."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true,
            "description": "UTC."
          }
        },
        "required": [
          "id",
          "object",
          "payment_id",
          "amount_minor"
        ],
        "additionalProperties": false
      },
      "Payment": {
        "type": "object",
        "description": "Opaque payment action registered against an appointment's visit. `id` is stable between requests: `t<number>` for money payments and `l<number>` for loyalty/Client Account operations.",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[tl][0-9]+$",
            "readOnly": true
          },
          "object": {
            "type": "string",
            "enum": [
              "payment"
            ],
            "readOnly": true
          },
          "visit_id": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true
          },
          "type": {
            "type": "string",
            "enum": [
              "payment_method",
              "account",
              "deposit",
              "loyalty_card",
              "loyalty_program",
              "gift_card",
              "membership",
              "referral_program",
              "membership_auto",
              "prepaid_hold"
            ],
            "description": "`membership_auto` and `prepaid_hold` are read-only and never accepted by PaymentCreate."
          },
          "amount_minor": {
            "type": "integer",
            "description": "Payment amount in minor units. For `membership`, this is `0`; covered items are listed in `covers_items`."
          },
          "fee_minor": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Acquiring fee represented inside the payment; it is not exposed as a separate payment."
          },
          "currency": {
            "type": "string",
            "readOnly": true,
            "description": "ISO 4217, server-controlled by the Location."
          },
          "account_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "payment_method_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "completed",
              "refunded"
            ]
          },
          "covers_items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PaymentCoversItem"
            }
          },
          "card_brand_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "installment_count": {
            "type": [
              "integer",
              "null"
            ]
          },
          "refund": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Refund"
              },
              {
                "type": "null"
              }
            ],
            "readOnly": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true,
            "description": "UTC."
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "amount_minor",
          "currency",
          "status",
          "created_at"
        ],
        "additionalProperties": false
      },
      "PaymentCreate": {
        "description": "Payment request. `type` selects the variant and therefore which identifier is expected;\nevery identifier comes from `visit.payment_methods` or `searchLoyaltyInstrument`, so a\nclient never has to guess one.\n\nInstruments that determine their own amount (`membership`, `loyalty_program`) take no\n`amount_minor`: a membership spends sessions and a loyalty program computes its own\ndiscount. `membership_auto` and `prepaid_hold` are read-only types and are not accepted.",
        "oneOf": [
          {
            "type": "object",
            "title": "payment_method",
            "description": "Cash, card terminal or cashless through a method configured for the Location.",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "payment_method"
                ]
              },
              "payment_method_id": {
                "type": "integer",
                "description": "From `listPaymentMethods`."
              },
              "amount_minor": {
                "type": "integer"
              },
              "account_id": {
                "type": "integer",
                "description": "Account the payment settles to."
              },
              "card_brand_id": {
                "type": "integer"
              },
              "installment_count": {
                "type": "integer"
              }
            },
            "required": [
              "type",
              "payment_method_id",
              "amount_minor",
              "account_id"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "title": "account",
            "description": "Straight to a cash or cashless account, without a configured method.",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "account"
                ]
              },
              "account_id": {
                "type": "integer"
              },
              "amount_minor": {
                "type": "integer"
              }
            },
            "required": [
              "type",
              "account_id",
              "amount_minor"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "title": "deposit",
            "description": "From a Client Account balance. A client may hold more than one Client Account, so the account is named explicitly with `deposit_id`.",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "deposit"
                ]
              },
              "deposit_id": {
                "type": "integer",
                "description": "From `visit.payment_methods`."
              },
              "amount_minor": {
                "type": "integer"
              }
            },
            "required": [
              "type",
              "deposit_id",
              "amount_minor"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "title": "loyalty_card",
            "description": "From the balance of a loyalty card. Clients commonly hold cards in several chains, so the card is named explicitly.",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "loyalty_card"
                ]
              },
              "loyalty_card_id": {
                "type": "integer",
                "description": "From `visit.payment_methods`."
              },
              "amount_minor": {
                "type": "integer"
              }
            },
            "required": [
              "type",
              "loyalty_card_id",
              "amount_minor"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "title": "loyalty_program",
            "description": "Applies a loyalty program to the visit. The program computes the amount, so none is sent. Both the card and the program are named because one card can carry several programs.",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "loyalty_program"
                ]
              },
              "loyalty_card_id": {
                "type": "integer"
              },
              "loyalty_program_id": {
                "type": "integer"
              }
            },
            "required": [
              "type",
              "loyalty_card_id",
              "loyalty_program_id"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "title": "gift_card",
            "description": "Pays with a gift card. Identify it by `number`, or by `gift_card_id` when the card carries no code.",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "gift_card"
                ]
              },
              "number": {
                "type": "string"
              },
              "gift_card_id": {
                "type": "integer",
                "description": "From `visit.payment_methods` or `searchLoyaltyInstrument`."
              },
              "amount_minor": {
                "type": "integer"
              }
            },
            "required": [
              "type",
              "amount_minor"
            ],
            "anyOf": [
              {
                "required": [
                  "number"
                ],
                "properties": {
                  "number": {
                    "type": "string"
                  }
                }
              },
              {
                "required": [
                  "gift_card_id"
                ],
                "properties": {
                  "gift_card_id": {
                    "type": "integer"
                  }
                }
              }
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "title": "membership",
            "description": "Spends a membership session. No `amount_minor` - sessions are spent, not money. Identify it by `number`, or by `membership_id` when the membership carries no code (an empty code is allowed by membership settings).",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "membership"
                ]
              },
              "number": {
                "type": "string"
              },
              "membership_id": {
                "type": "integer",
                "description": "From `visit.payment_methods` or `searchLoyaltyInstrument`."
              }
            },
            "required": [
              "type"
            ],
            "anyOf": [
              {
                "required": [
                  "number"
                ],
                "properties": {
                  "number": {
                    "type": "string"
                  }
                }
              },
              {
                "required": [
                  "membership_id"
                ],
                "properties": {
                  "membership_id": {
                    "type": "integer"
                  }
                }
              }
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "title": "referral_program",
            "description": "Applies a referral program. A client may be eligible under several referral programs from different chains, so the program is named alongside the referrer.",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "referral_program"
                ]
              },
              "referral_program_id": {
                "type": "integer",
                "description": "From `visit.payment_methods`."
              },
              "referrer_phone": {
                "type": "string"
              },
              "amount_minor": {
                "type": "integer"
              }
            },
            "required": [
              "type",
              "referral_program_id",
              "referrer_phone",
              "amount_minor"
            ],
            "additionalProperties": false
          }
        ],
        "discriminator": {
          "propertyName": "type"
        }
      },
      "Visit": {
        "type": "object",
        "description": "Billing state resolved from an appointment: service and products, applicable payment methods, payments from money and loyalty sources, and `amount_to_pay_minor`.",
        "properties": {
          "id": {
            "type": "integer",
            "readOnly": true
          },
          "object": {
            "type": "string",
            "enum": [
              "visit"
            ],
            "readOnly": true
          },
          "location_id": {
            "type": "integer",
            "readOnly": true
          },
          "appointment_ids": {
            "type": "array",
            "items": {
              "type": "integer"
            },
            "readOnly": true,
            "description": "Appointments grouped into this visit.",
            "x-altegio-assumption": "Exposing the appointment ids of a visit is a preview convenience pending the visit slice implementation. Must be resolved before contract freeze."
          },
          "status": {
            "type": "string",
            "enum": [
              "waiting",
              "confirmed",
              "arrived",
              "no_show"
            ],
            "description": "Status of the visit."
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/VisitItem"
            }
          },
          "payments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Payment"
            }
          },
          "currency": {
            "type": "string",
            "readOnly": true,
            "description": "ISO 4217, server-controlled by the Location."
          },
          "client": {
            "description": "Present only when requested with `include[]=client`; PII rules apply.",
            "readOnly": true,
            "$ref": "#/components/schemas/Client"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true,
            "description": "UTC."
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true,
            "description": "UTC."
          },
          "amount_to_pay_minor": {
            "type": "integer",
            "readOnly": true,
            "description": "Remaining unpaid amount in integer minor units. `0` means fully paid or free."
          },
          "payment_methods": {
            "type": "array",
            "description": "Ways to pay this visit, with applicability resolved against it and identifiers sufficient for `createPayment`. Only instruments attached to the client appear here; a gift card or membership held by number is found with `searchLoyaltyInstrument`.",
            "items": {
              "$ref": "#/components/schemas/ApplicablePaymentMethod"
            }
          }
        },
        "required": [
          "id",
          "object",
          "status",
          "items",
          "payment_methods",
          "payments",
          "amount_to_pay_minor",
          "currency"
        ]
      },
      "ServiceList": {
        "description": "Cursor-paginated list of services.",
        "allOf": [
          {
            "$ref": "#/components/schemas/ListEnvelope"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Service"
                }
              }
            },
            "required": [
              "data"
            ]
          }
        ]
      },
      "ServiceCategoryList": {
        "description": "Cursor-paginated list of service categories.",
        "allOf": [
          {
            "$ref": "#/components/schemas/ListEnvelope"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ServiceCategory"
                }
              }
            },
            "required": [
              "data"
            ]
          }
        ]
      },
      "TeamMemberList": {
        "description": "Cursor-paginated list of Team Members.",
        "allOf": [
          {
            "$ref": "#/components/schemas/ListEnvelope"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/TeamMember"
                }
              }
            },
            "required": [
              "data"
            ]
          }
        ]
      },
      "TeamMemberSchedule": {
        "type": "object",
        "description": "Configured working schedule of a Team Member — every day of the requested range in order.",
        "properties": {
          "object": {
            "type": "string",
            "enum": [
              "team_member_schedule"
            ]
          },
          "team_member_id": {
            "type": "integer"
          },
          "date_from": {
            "type": "string",
            "format": "date"
          },
          "date_to": {
            "type": "string",
            "format": "date"
          },
          "days": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ScheduleDay"
            }
          }
        },
        "required": [
          "object",
          "team_member_id",
          "date_from",
          "date_to",
          "days"
        ]
      },
      "PositionList": {
        "description": "Cursor-paginated list of positions.",
        "allOf": [
          {
            "$ref": "#/components/schemas/ListEnvelope"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Position"
                }
              }
            },
            "required": [
              "data"
            ]
          }
        ]
      },
      "ClientList": {
        "description": "Cursor-paginated list of clients.",
        "allOf": [
          {
            "$ref": "#/components/schemas/ListEnvelope"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Client"
                }
              }
            },
            "required": [
              "data"
            ]
          }
        ]
      },
      "Availability": {
        "type": "object",
        "description": "Free slots of the requested services within the range. Computed, not addressable.",
        "properties": {
          "object": {
            "type": "string",
            "enum": [
              "availability"
            ]
          },
          "slots": {
            "type": "array",
            "description": "Sorted by `starts_at`, then `team_member_id`.",
            "items": {
              "$ref": "#/components/schemas/AvailabilitySlot"
            }
          }
        },
        "required": [
          "object",
          "slots"
        ]
      },
      "AvailabilityDates": {
        "type": "object",
        "description": "Dates with at least one free slot of the requested services within the range. Computed, not addressable.",
        "properties": {
          "object": {
            "type": "string",
            "enum": [
              "availability_dates"
            ]
          },
          "dates": {
            "type": "array",
            "description": "Dates in the Location's calendar, `YYYY-MM-DD`, ascending.",
            "items": {
              "type": "string",
              "format": "date"
            }
          }
        },
        "required": [
          "object",
          "dates"
        ]
      },
      "ResourceList": {
        "description": "Cursor-paginated list of resources.",
        "allOf": [
          {
            "$ref": "#/components/schemas/ListEnvelope"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Resource"
                }
              }
            },
            "required": [
              "data"
            ]
          }
        ]
      },
      "AppointmentList": {
        "description": "Cursor-paginated list of appointments.",
        "allOf": [
          {
            "$ref": "#/components/schemas/ListEnvelope"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Appointment"
                }
              }
            },
            "required": [
              "data"
            ]
          }
        ]
      },
      "PaymentMethodList": {
        "description": "Cursor-paginated list of payment methods.",
        "allOf": [
          {
            "$ref": "#/components/schemas/ListEnvelope"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/PaymentMethod"
                }
              }
            },
            "required": [
              "data"
            ]
          }
        ]
      },
      "ApplicablePaymentMethodList": {
        "description": "Cursor-paginated list of ways to pay a specific visit.",
        "allOf": [
          {
            "$ref": "#/components/schemas/ListEnvelope"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ApplicablePaymentMethod"
                }
              }
            },
            "required": [
              "data"
            ]
          }
        ]
      },
      "AccountList": {
        "description": "Cursor-paginated list of accounts.",
        "allOf": [
          {
            "$ref": "#/components/schemas/ListEnvelope"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Account"
                }
              }
            },
            "required": [
              "data"
            ]
          }
        ]
      },
      "LocationCreate": {
        "type": "object",
        "description": "Create a Location. `country_code`, `timezone`, and `currency` are derived from `city_id` and not writable.",
        "properties": {
          "name": {
            "type": "string"
          },
          "city_id": {
            "type": "integer"
          },
          "business_type_id": {
            "type": "integer"
          },
          "language": {
            "type": "string",
            "description": "BCP 47 language tag."
          },
          "datetime_format": {
            "type": "string"
          }
        },
        "required": [
          "name",
          "city_id",
          "business_type_id",
          "language",
          "datetime_format"
        ],
        "additionalProperties": false
      },
      "LocationCreated": {
        "description": "The created Location plus its provisioning status.",
        "allOf": [
          {
            "$ref": "#/components/schemas/Location"
          },
          {
            "type": "object",
            "properties": {
              "provisioning_status": {
                "type": "string",
                "readOnly": true,
                "enum": [
                  "ready",
                  "pending"
                ],
                "description": "`ready` = base accounts and payment methods exist; `pending` = defaults are still being provisioned."
              }
            },
            "required": [
              "provisioning_status"
            ]
          }
        ]
      },
      "City": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "object": {
            "type": "string",
            "enum": [
              "city"
            ]
          },
          "country_id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "country_code": {
            "type": "string",
            "readOnly": true
          }
        },
        "required": [
          "id",
          "object",
          "country_id",
          "name",
          "country_code"
        ],
        "additionalProperties": false
      },
      "CityList": {
        "description": "Cursor-paginated list of cities.",
        "allOf": [
          {
            "$ref": "#/components/schemas/ListEnvelope"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/City"
                }
              }
            },
            "required": [
              "data"
            ]
          }
        ]
      },
      "BusinessType": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "object": {
            "type": "string",
            "enum": [
              "business_type"
            ]
          },
          "title": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "object",
          "title"
        ],
        "additionalProperties": false
      },
      "BusinessTypeList": {
        "description": "Cursor-paginated list of business types.",
        "allOf": [
          {
            "$ref": "#/components/schemas/ListEnvelope"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/BusinessType"
                }
              }
            },
            "required": [
              "data"
            ]
          }
        ]
      },
      "LocationAccessRole": {
        "type": "object",
        "description": "Public access role. Internal permission slugs are not exposed.",
        "properties": {
          "role_id": {
            "type": "integer"
          },
          "object": {
            "type": "string",
            "enum": [
              "location_access_role"
            ]
          },
          "title": {
            "type": "string"
          }
        },
        "required": [
          "role_id",
          "object",
          "title"
        ],
        "additionalProperties": false
      },
      "LocationAccessRoleList": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ListEnvelope"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/LocationAccessRole"
                }
              }
            },
            "required": [
              "data"
            ]
          }
        ]
      },
      "TeamMemberAccessInvitation": {
        "type": "object",
        "properties": {
          "sent_at": {
            "type": "string",
            "format": "date-time",
            "description": "UTC."
          },
          "expires_at": {
            "type": "string",
            "format": "date-time",
            "description": "UTC."
          }
        },
        "required": [
          "sent_at",
          "expires_at"
        ],
        "additionalProperties": false
      },
      "TeamMemberAccess": {
        "type": "object",
        "properties": {
          "object": {
            "type": "string",
            "enum": [
              "team_member_access"
            ]
          },
          "team_member_id": {
            "type": "integer"
          },
          "status": {
            "type": "string",
            "enum": [
              "none",
              "invited",
              "active"
            ]
          },
          "role_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "invitation": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/TeamMemberAccessInvitation"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "object",
          "team_member_id",
          "status",
          "role_id"
        ],
        "additionalProperties": false
      },
      "TeamMemberInvitationCreate": {
        "type": "object",
        "description": "Empty body for resend. Delivery contact cannot be overridden here — set write-only phone/email only on Team Member create (`access_invitation`).",
        "properties": {},
        "additionalProperties": false
      },
      "TeamMemberAccessUpdate": {
        "type": "object",
        "description": "Merge-patch body; only `role_id` can be changed.",
        "properties": {
          "role_id": {
            "type": "integer"
          }
        },
        "required": [
          "role_id"
        ],
        "additionalProperties": false
      },
      "Product": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "object": {
            "type": "string",
            "enum": [
              "product"
            ]
          },
          "title": {
            "type": "string"
          },
          "price_minor": {
            "type": "integer"
          },
          "unit": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "object",
          "title",
          "price_minor",
          "unit"
        ],
        "additionalProperties": false
      },
      "ProductList": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ListEnvelope"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Product"
                }
              }
            },
            "required": [
              "data"
            ]
          }
        ]
      },
      "PaymentCoversItem": {
        "type": "object",
        "properties": {
          "visit_item_id": {
            "type": "integer"
          },
          "amount_minor": {
            "type": "integer"
          }
        },
        "required": [
          "visit_item_id"
        ],
        "additionalProperties": false
      },
      "AppointmentPackageComponentCreate": {
        "type": "object",
        "properties": {
          "package_component_id": {
            "type": "integer"
          },
          "team_member_id": {
            "type": "integer"
          }
        },
        "required": [
          "package_component_id",
          "team_member_id"
        ],
        "additionalProperties": false
      },
      "AppointmentCreateResponse": {
        "type": "object",
        "description": "Create-appointment result. Simple services return one appointment; package services return every created component appointment plus the shared visit id.",
        "properties": {
          "object": {
            "type": "string",
            "enum": [
              "appointment_create_result"
            ]
          },
          "visit_id": {
            "type": [
              "integer",
              "null"
            ],
            "readOnly": true
          },
          "appointments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Appointment"
            }
          }
        },
        "required": [
          "object",
          "visit_id",
          "appointments"
        ],
        "additionalProperties": false
      },
      "MarketplaceAppCapability": {
        "type": "string",
        "description": "What the application does, as marked by the developer. Capabilities only drive hints in the Developer Hub; they grant no access.",
        "enum": [
          "api",
          "page",
          "calendar_extension",
          "team_member_oauth"
        ]
      },
      "MarketplaceApp": {
        "type": "object",
        "description": "A V3 marketplace application of a developer account.",
        "properties": {
          "id": {
            "type": "integer",
            "readOnly": true
          },
          "object": {
            "type": "string",
            "enum": [
              "marketplace_app"
            ],
            "readOnly": true
          },
          "title": {
            "type": "string",
            "minLength": 3,
            "maxLength": 255
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "capabilities": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MarketplaceAppCapability"
            }
          },
          "scopes": {
            "type": "array",
            "readOnly": true,
            "description": "Scopes the application requests at installation; `[]` means no API access. Replace them with `PUT …/scopes`.",
            "items": {
              "type": "string"
            }
          },
          "webhook_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "description": "HTTPS address that receives the installation webhooks."
          },
          "setup_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "description": "Your setup page. When it is set, a new installation stays `pending` until your backend calls\n`activate`; without it, an installation is `active` at once.\n\nThe business opens the page with three query parameters:\n\n- `location_ids`: the Locations being set up, ids in ascending order joined with commas;\n- `ts`: when the link was issued, Unix time in seconds;\n- `signature`: HMAC-SHA256 of the string `setup.{location_ids}.{ts}` in lowercase hex. The key is the\n  webhook secret without the `whsec_` prefix, decoded from base64: the same key that signs webhooks.\n\nBuild the string from the received values after URL decoding, compare the signatures in constant time\nand reject the link when `ts` differs from your clock by more than 5 minutes.\n\nTest vector: secret `whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw`, Locations 90211 and 90215, `ts`\n1795000000. The signed string is `setup.90211,90215.1795000000`, the signature is\n`5abd51bee1d8b90d065d067d19988111eda1737fa2979a81af27f13131202094`, and the link is\n`https://your-app.example/altegio/setup?location_ids=90211%2C90215&ts=1795000000&signature=5abd51bee1d8b90d065d067d19988111eda1737fa2979a81af27f13131202094`."
          },
          "setup_mode": {
            "type": "string",
            "enum": [
              "tab",
              "iframe"
            ],
            "description": "How the business opens `setup_url`, in a new browser tab or in an iframe on the Settings tab of the application."
          },
          "install_url": {
            "type": "string",
            "format": "uri",
            "readOnly": true,
            "description": "Link that opens the installation screen for a business."
          },
          "oauth_client": {
            "$ref": "#/components/schemas/MarketplaceAppOAuthClient"
          },
          "readiness": {
            "$ref": "#/components/schemas/MarketplaceAppReadiness"
          },
          "publication_status": {
            "type": "string",
            "readOnly": true,
            "enum": [
              "none",
              "draft",
              "moderation",
              "published"
            ],
            "description": "`none` until the publication card is created; then the `status` of the card."
          },
          "recommendations": {
            "type": "array",
            "readOnly": true,
            "items": {
              "$ref": "#/components/schemas/MarketplaceAppRecommendation"
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "readOnly": true
          }
        },
        "required": [
          "id",
          "object",
          "title",
          "description",
          "capabilities",
          "scopes",
          "webhook_url",
          "setup_url",
          "setup_mode",
          "install_url",
          "oauth_client",
          "readiness",
          "publication_status",
          "recommendations",
          "created_at"
        ]
      },
      "MarketplaceAppOAuthClient": {
        "type": "object",
        "readOnly": true,
        "description": "The OAuth client of the application. The secret is issued and shown only in the Developer Hub.",
        "properties": {
          "client_id": {
            "type": "string"
          },
          "secret_issued_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the client secret was last issued; `null` until the first issue, and `POST /oauth/token` answers `invalid_client` until then."
          }
        },
        "required": [
          "client_id",
          "secret_issued_at"
        ]
      },
      "MarketplaceAppReadiness": {
        "type": "object",
        "readOnly": true,
        "description": "Whether the application can be installed.",
        "properties": {
          "is_ready": {
            "type": "boolean",
            "description": "`true` when `reasons` is empty."
          },
          "reasons": {
            "type": "array",
            "description": "`webhook_url_missing`: `webhook_url` is not set.",
            "items": {
              "type": "string",
              "enum": [
                "webhook_url_missing"
              ]
            }
          }
        },
        "required": [
          "is_ready",
          "reasons"
        ]
      },
      "MarketplaceAppRecommendation": {
        "type": "object",
        "description": "A hint for the overview screen of the Developer Hub. New codes may appear; ignore codes you do not know.\n\n`interfaces_disabled`: the application declares the `page` or `calendar_extension` capability, but its\ninterface for that capability is turned off, so businesses do not see it in Altegio. `capability` names the\ncapability; there is one hint per such capability.",
        "properties": {
          "code": {
            "type": "string",
            "description": "Code of the hint, for example `interfaces_disabled`."
          },
          "capability": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/MarketplaceAppCapability"
              },
              {
                "type": "null"
              }
            ],
            "description": "The capability the hint is about, if any."
          }
        },
        "required": [
          "code",
          "capability"
        ]
      },
      "MarketplaceAppList": {
        "description": "Cursor-paginated list of marketplace applications.",
        "allOf": [
          {
            "$ref": "#/components/schemas/ListEnvelope"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/MarketplaceApp"
                }
              }
            },
            "required": [
              "data"
            ]
          }
        ]
      },
      "MarketplaceAppCreate": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "minLength": 3,
            "maxLength": 255
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "capabilities": {
            "type": "array",
            "description": "Defaults to `[]`.",
            "items": {
              "$ref": "#/components/schemas/MarketplaceAppCapability"
            }
          }
        },
        "required": [
          "title"
        ],
        "additionalProperties": false
      },
      "MarketplaceAppUpdate": {
        "type": "object",
        "description": "Merge-patch body for a marketplace application. `scopes` is not accepted here; use `PUT …/scopes`.",
        "properties": {
          "title": {
            "type": "string",
            "minLength": 3,
            "maxLength": 255
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "capabilities": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MarketplaceAppCapability"
            }
          },
          "setup_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "maxLength": 255,
            "description": "HTTPS address of your setup page, or `null` to install without it."
          },
          "setup_mode": {
            "type": "string",
            "enum": [
              "tab",
              "iframe"
            ]
          },
          "webhook_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "maxLength": 255,
            "description": "HTTPS address for the installation webhooks."
          }
        },
        "additionalProperties": false
      },
      "MarketplaceAppScopesUpdate": {
        "type": "object",
        "description": "The full set of scopes the application requests; `[]` means no API access.",
        "properties": {
          "scopes": {
            "type": "array",
            "uniqueItems": true,
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "scopes"
        ],
        "additionalProperties": false
      },
      "ScopeMark": {
        "type": "string",
        "description": "Badge of a scope or group on consent and installation screens: `data_change` changes business data, `personal_data` exposes personal data, `special`, `critical` and `sensitive` call for extra attention.",
        "enum": [
          "data_change",
          "special",
          "critical",
          "personal_data",
          "sensitive"
        ]
      },
      "MarketplaceAppScopeCatalog": {
        "type": "object",
        "properties": {
          "object": {
            "type": "string",
            "enum": [
              "scope_catalog"
            ]
          },
          "groups": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MarketplaceAppScopeCatalogGroup"
            }
          }
        },
        "required": [
          "object",
          "groups"
        ]
      },
      "MarketplaceAppScopeCatalogGroup": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "hint": {
            "type": [
              "string",
              "null"
            ]
          },
          "marks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ScopeMark"
            }
          },
          "scopes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MarketplaceAppScopeCatalogScope"
            }
          }
        },
        "required": [
          "code",
          "title",
          "hint",
          "marks",
          "scopes"
        ]
      },
      "MarketplaceAppScopeCatalogScope": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "note": {
            "type": [
              "string",
              "null"
            ]
          },
          "operation_type": {
            "type": "string",
            "enum": [
              "read",
              "write"
            ]
          },
          "marks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ScopeMark"
            }
          },
          "implies": {
            "type": "array",
            "description": "Scopes this scope includes. Only a `write` scope includes the `read` scope of its group.",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "code",
          "title",
          "note",
          "operation_type",
          "marks",
          "implies"
        ]
      },
      "MarketplaceAppFunctionality": {
        "type": "string",
        "description": "What a notification application does. Used only with the `notify` category.",
        "enum": [
          "campaigns",
          "service_sendings",
          "message_fallback",
          "approving",
          "returns",
          "rfm",
          "maps_reviews",
          "interceptor",
          "analytics",
          "tasks"
        ]
      },
      "MarketplaceAppMonetizationType": {
        "type": "string",
        "enum": [
          "free",
          "paid",
          "freemium"
        ]
      },
      "MarketplaceAppPublication": {
        "type": "object",
        "description": "The marketplace card of an application.",
        "properties": {
          "object": {
            "type": "string",
            "enum": [
              "publication"
            ],
            "readOnly": true
          },
          "marketplace_app_id": {
            "type": "integer",
            "readOnly": true
          },
          "status": {
            "type": "string",
            "readOnly": true,
            "enum": [
              "draft",
              "moderation",
              "published"
            ],
            "description": "`draft` until submitted, `moderation` after `submit` and when a moderator takes the card down, `published` after moderation."
          },
          "logo_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "description": "URL of the logo image uploaded in the Developer Hub."
          },
          "slug": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_]{3,200}$",
            "description": "Unique identifier of the card in marketplace links."
          },
          "website_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "category_id": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Marketplace category; `null` until chosen."
          },
          "functionalities": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MarketplaceAppFunctionality"
            }
          },
          "country_ids": {
            "type": "array",
            "description": "Countries where the card is shown. Read-only after the card was submitted.",
            "items": {
              "type": "integer"
            }
          },
          "monetization_type": {
            "$ref": "#/components/schemas/MarketplaceAppMonetizationType"
          },
          "price": {
            "type": [
              "string",
              "null"
            ],
            "description": "Price as free text shown on the card."
          },
          "trial_days": {
            "type": "integer",
            "minimum": 0
          },
          "moderator_connect_instruction": {
            "type": [
              "string",
              "null"
            ],
            "description": "How to connect the application, for the moderator."
          },
          "moderator_payment_instruction": {
            "type": [
              "string",
              "null"
            ],
            "description": "How payment for the application works, for the moderator."
          },
          "readiness": {
            "$ref": "#/components/schemas/MarketplaceAppPublicationReadiness"
          },
          "moderation_started_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "readOnly": true
          },
          "moderated_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "readOnly": true
          }
        },
        "required": [
          "object",
          "marketplace_app_id",
          "status",
          "logo_url",
          "slug",
          "website_url",
          "category_id",
          "functionalities",
          "country_ids",
          "monetization_type",
          "price",
          "trial_days",
          "moderator_connect_instruction",
          "moderator_payment_instruction",
          "readiness",
          "moderation_started_at",
          "moderated_at"
        ]
      },
      "MarketplaceAppPublicationReadiness": {
        "type": "object",
        "readOnly": true,
        "description": "Readiness of the card for `submit`, by section.",
        "properties": {
          "is_ready": {
            "type": "boolean",
            "description": "`true` when the content of the card passes the `submit` checks. A card already on moderation still answers `409` to `submit`."
          },
          "sections": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string",
                  "enum": [
                    "details",
                    "description_en",
                    "translations",
                    "connection",
                    "developer_profile"
                  ]
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "ok",
                    "fix",
                    "blocks"
                  ],
                  "description": "`ok` nothing to do, `fix` the section has issues to correct, `blocks` the section blocks submission."
                },
                "issues": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "field": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "description": "Name of the field with the issue: a field of this card in `details` and `connection`, a field of\nthe translation in `description_en` and `translations`, a field of the developer profile in\n`developer_profile`. `null` when the issue is about the whole item, like a missing language."
                      },
                      "locale_id": {
                        "type": [
                          "integer",
                          "null"
                        ],
                        "description": "Language of the translation in `description_en` and `translations`; `null` in other sections."
                      },
                      "message": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "field",
                      "locale_id",
                      "message"
                    ]
                  }
                }
              },
              "required": [
                "code",
                "status",
                "issues"
              ]
            }
          }
        },
        "required": [
          "is_ready",
          "sections"
        ]
      },
      "MarketplaceAppPublicationUpdate": {
        "type": "object",
        "description": "Merge-patch body for the publication card.",
        "properties": {
          "logo_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "maxLength": 255,
            "description": "URL of a logo image uploaded to Altegio in the Developer Hub; another address fails with `invalid_value`. `null` removes the logo."
          },
          "slug": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_]{3,200}$"
          },
          "website_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "maxLength": 255
          },
          "category_id": {
            "type": "integer",
            "description": "An active marketplace category."
          },
          "functionalities": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MarketplaceAppFunctionality"
            }
          },
          "country_ids": {
            "type": "array",
            "items": {
              "type": "integer"
            }
          },
          "monetization_type": {
            "$ref": "#/components/schemas/MarketplaceAppMonetizationType"
          },
          "price": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255
          },
          "trial_days": {
            "type": "integer",
            "minimum": 0
          },
          "moderator_connect_instruction": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 1000
          },
          "moderator_payment_instruction": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 1000
          }
        },
        "additionalProperties": false
      },
      "MarketplaceAppPublicationCreate": {
        "description": "The first saved section of the publication card; the same fields as the merge-patch body, at least one of them.",
        "allOf": [
          {
            "$ref": "#/components/schemas/MarketplaceAppPublicationUpdate"
          }
        ],
        "minProperties": 1
      },
      "MarketplaceAppInstallation": {
        "type": "object",
        "description": "Your application installed in a Location.",
        "properties": {
          "id": {
            "type": "integer"
          },
          "object": {
            "type": "string",
            "enum": [
              "installation"
            ]
          },
          "marketplace_app_id": {
            "type": "integer"
          },
          "location_id": {
            "type": "integer"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "frozen",
              "pending"
            ],
            "description": "`pending` until you call `activate`, `active` when working, `frozen` while the application is unpaid."
          },
          "installed_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the business installed the application, including a still `pending` installation."
          },
          "scopes": {
            "type": "array",
            "description": "Scopes the business approved at installation.",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "id",
          "object",
          "marketplace_app_id",
          "location_id",
          "status",
          "installed_at",
          "scopes"
        ]
      },
      "MarketplaceAppInstallationList": {
        "description": "Cursor-paginated list of installations.",
        "allOf": [
          {
            "$ref": "#/components/schemas/ListEnvelope"
          },
          {
            "type": "object",
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/MarketplaceAppInstallation"
                }
              }
            },
            "required": [
              "data"
            ]
          }
        ]
      },
      "MarketplaceAppInstallationPaymentCreate": {
        "type": "object",
        "description": "A payment the business made to you for the application in this Location.",
        "properties": {
          "amount_minor": {
            "type": "integer",
            "format": "int64",
            "minimum": 1,
            "description": "Amount in minor units of `currency`. For a currency with three decimals (`BHD`, `JOD`, `KWD`) the amount\nmust be a multiple of 10: payments are stored with two decimals, so another amount fails with\n`422 validation_failed` at `/amount_minor` and is not rounded."
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$",
            "description": "ISO 4217 currency code."
          },
          "paid_at": {
            "type": "string",
            "format": "date-time"
          },
          "period_from": {
            "type": "string",
            "format": "date-time",
            "description": "Start of the paid period."
          },
          "period_to": {
            "type": "string",
            "format": "date-time",
            "description": "End of the paid period."
          }
        },
        "required": [
          "amount_minor",
          "currency",
          "paid_at",
          "period_from",
          "period_to"
        ],
        "additionalProperties": false
      },
      "MarketplaceAppInstallationPayment": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "object": {
            "type": "string",
            "enum": [
              "installation_payment"
            ]
          },
          "marketplace_app_id": {
            "type": "integer"
          },
          "location_id": {
            "type": "integer"
          },
          "amount_minor": {
            "type": "integer",
            "format": "int64"
          },
          "currency": {
            "type": "string"
          },
          "paid_at": {
            "type": "string",
            "format": "date-time"
          },
          "period_from": {
            "type": "string",
            "format": "date-time"
          },
          "period_to": {
            "type": "string",
            "format": "date-time"
          },
          "refunded_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "object",
          "marketplace_app_id",
          "location_id",
          "amount_minor",
          "currency",
          "paid_at",
          "period_from",
          "period_to",
          "refunded_at"
        ]
      },
      "MarketplaceAppInstallationEvent": {
        "type": "object",
        "description": "Body of an installation webhook.",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "installation.created",
              "installation.deleted",
              "installation.frozen",
              "installation.unfrozen",
              "installation.paid"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the event happened."
          },
          "data": {
            "type": "object",
            "properties": {
              "marketplace_app_id": {
                "type": "integer"
              },
              "location_id": {
                "type": "integer"
              }
            },
            "required": [
              "marketplace_app_id",
              "location_id"
            ]
          }
        },
        "required": [
          "type",
          "created_at",
          "data"
        ]
      }
    }
  }
}