# List and search clients

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`.

Endpoint: GET /locations/{location_id}/clients
Version: 3.0.0-preview
Security: OAuth2, ApiKey

## Security:

  - `OAuth2` (unknown)
    oauth2 scopes: clients:read

  - `ApiKey` (unknown)
    http bearer

## Path parameters:

  - `location_id` (integer, required)
    Identifier of the Location. Verified against the credential on every call — a Location the credential cannot access responds with `404`.

## Query parameters:

  - `phone` (string)
    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`.

  - `email` (string)
    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`.

  - `query` (string)
    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`.

  - `limit` (integer)
    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.

  - `cursor` (string)
    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).

## Response 200:

  - `200` (unknown)
    A page of clients matching the search.

## Response 200 fields (application/json):

  - `object` (string, required)
    Enum: "list"

  - `has_more` (boolean, required)
    Whether more items exist beyond this page.

  - `next_cursor` (string | null, required)
    Opaque cursor for the next page; `null` on the last page.

  - `data` (array, required)

  - `data.id` (integer, required)

  - `data.object` (string, required)
    Enum: "client"

  - `data.name` (string | null, required)
    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.

  - `data.surname` (string | null, required)
    Surname. `null` when empty, when the Location has the surname field turned off, or when withheld — see `redacted_fields`.

  - `data.patronymic` (string | null, required)
    Patronymic or middle name. `null` when empty, when the Location has the patronymic field turned off, or when withheld — see `redacted_fields`.

  - `data.phone` (string | null, required)
    Phone number in international format with a leading `+`. `null` when absent or withheld — see `redacted_fields`.

  - `data.additional_phone` (string | null, required)
    Additional phone number in international format with a leading `+`. Uses the same contact access as `phone`; `null` when absent or withheld.

  - `data.email` (string | null, required)
    Email address. `null` when absent or withheld — see `redacted_fields`.

  - `data.comment` (string | null, required)
    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`.

  - `data.card_number` (string | null, required)
    Card number as stored in the client card, HTML entities decoded; `null` when empty.

  - `data.gender` (string | null, required)
    Gender stored in the client card; `null` when unspecified.
    Enum: "male", "female", "null"

  - `data.importance` (string | null, required)
    Importance level stored in the client card; `null` when unspecified. This is not a recalculated loyalty tier.
    Enum: "bronze", "silver", "gold", "null"

  - `data.birth_day` (integer | null, required)
    Stored day of birth; `null` when unknown or outside the range. Returned independently of the other birth parts without constructing a date.

  - `data.birth_month` (integer | null, required)
    Stored month of birth; `null` when unknown or outside the range.

  - `data.birth_year` (integer | null, required)
    Stored year of birth; `null` when unknown or outside the range. No substitute year is invented.

  - `data.discount_percent` (number, required)
    Personal discount set in the client card, percent; `0` when none.

  - `data.visits_count` (integer, required)
    Number of visits the client attended (marked as arrived), as in the client base of the Location.

  - `data.first_visit_at` (string | null, required)
    Start of the first attended visit, Location-local offset; `null` without attended visits.

  - `data.last_visit_at` (string | null, required)
    Start of the latest attended visit, Location-local offset; `null` without attended visits.

  - `data.sold_amount_minor` (integer, required)
    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`.

  - `data.currency` (string, required)
    ISO 4217, server-controlled by the Location.

  - `data.created_at` (string | null, required)
    UTC; `null` for legacy records without a creation date.

  - `data.updated_at` (string | null, required)
    UTC. Last change of the client card; `null` for legacy records without a change date.

  - `data.redacted_fields` (array, required)
    Names of fields withheld for this object: `phone`, `additional_phone` and `email` without contact access,
`surname` and `patronymic` without the permission to see client surnames, and `comment`
without the client card comment permission. A withheld
field is always returned as `null` — never as a masked, shortened or empty string, so
an integration cannot write a mask back. An empty array means nothing was withheld
and a `null` value simply means no value is stored.

## Response 200 headers (application/json):

  - `RateLimit-Remaining` (integer)
    Requests left in the most constrained policy window that applies to this request.

  - `RateLimit-Reset` (integer)
    On `429`, seconds until the most constrained policy frees up; it equals `Retry-After` there.
On a successful response it reports the **length** of that policy's window rather than the
time left in the current one, so treat it as the window size, not as a countdown — the
counter to pace against is `RateLimit-Remaining`.

  - `RateLimit-Policy` (string)
    Most constrained policy applied to the request, as `<limit>;w=<window in seconds>`.
    Example: 10;w=60

  - `X-Request-Id` (string)
    Request identifier for support and log correlation.

## Response 400:

  - `400` (unknown)
    Client error without a more specific registered code (`bad_request` — status default for
bare 400 and unknown 4xx), or protocol/syntax failure (`malformed_request` — broken JSON /
unparseable body only; must be thrown explicitly, never used as a synonym for every 400).
Semantic field validation is `422 validation_failed`, not 400.

## Response 400 fields (application/problem+json):

  - `type` (string, required)
    Stable URL identifying the problem type; links to documentation.

  - `title` (string, required)
    Human-readable summary of the problem type.

  - `status` (integer, required)
    HTTP status code of this response.

  - `detail` (string)
    Human-readable explanation of this occurrence.

  - `instance` (string, required)
    Request identifier for support and log correlation.

  - `code` (string, required)
    Stable machine-readable reason code.

  - `errors` (array)
    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).

  - `errors.code` (string, required)
    Stable machine-readable reason for this field.

  - `errors.pointer` (string, required)
    JSON Pointer for `body`; parameter name for `query`, `path`, or `header`.

  - `errors.message` (string, required)
    Human-readable explanation.

  - `errors.source` (string, required)
    Where the invalid value came from.
    Enum: "body", "query", "path", "header"

## Response 400 headers (application/problem+json):

  - `X-Request-Id` (string)
    Request identifier for support and log correlation.

## Response 401:

  - `401` (unknown)
    The request has no valid Bearer credential (`invalid_token`).

## Response 401 fields (application/problem+json):

  - `type` (string, required)
    Stable URL identifying the problem type; links to documentation.

  - `title` (string, required)
    Human-readable summary of the problem type.

  - `status` (integer, required)
    HTTP status code of this response.

  - `detail` (string)
    Human-readable explanation of this occurrence.

  - `instance` (string, required)
    Request identifier for support and log correlation.

  - `code` (string, required)
    Stable machine-readable reason code.

  - `errors` (array)
    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).

  - `errors.code` (string, required)
    Stable machine-readable reason for this field.

  - `errors.pointer` (string, required)
    JSON Pointer for `body`; parameter name for `query`, `path`, or `header`.

  - `errors.message` (string, required)
    Human-readable explanation.

  - `errors.source` (string, required)
    Where the invalid value came from.
    Enum: "body", "query", "path", "header"

## Response 401 headers (application/problem+json):

  - `WWW-Authenticate` (string)
    Bearer challenge with the URL of the protected resource metadata (RFC 9728 §5.1),
where the client finds the authorization server.
    Example: Bearer resource_metadata="https://api.alteg.io/.well-known/oauth-protected-resource/api/v3"

  - `X-Request-Id` (string)
    Request identifier for support and log correlation.

## Response 403:

  - `403` (unknown)
    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`).

## Response 403 fields (application/problem+json):

  - `type` (string, required)
    Stable URL identifying the problem type; links to documentation.

  - `title` (string, required)
    Human-readable summary of the problem type.

  - `status` (integer, required)
    HTTP status code of this response.

  - `detail` (string)
    Human-readable explanation of this occurrence.

  - `instance` (string, required)
    Request identifier for support and log correlation.

  - `code` (string, required)
    Stable machine-readable reason code.

  - `errors` (array)
    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).

  - `errors.code` (string, required)
    Stable machine-readable reason for this field.

  - `errors.pointer` (string, required)
    JSON Pointer for `body`; parameter name for `query`, `path`, or `header`.

  - `errors.message` (string, required)
    Human-readable explanation.

  - `errors.source` (string, required)
    Where the invalid value came from.
    Enum: "body", "query", "path", "header"

## Response 403 headers (application/problem+json):

  - `WWW-Authenticate` (string)
    Only on `missing_scope`: Bearer challenge with `error="insufficient_scope"`, the scope the
operation requires and the URL of the protected resource metadata (RFC 6750 §3.1, RFC 9728 §5.1).
    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` (string)
    Request identifier for support and log correlation.

## Response 404:

  - `404` (unknown)
    The resource does not exist or is hidden by tenant policy. Prefer a resource-specific
code (`appointment_not_found`, `location_not_found`, …). Routing/gate/unknown-path 404s
use the generic `resource_not_found` (same shape, so "no pin" and "missing" are not distinguished).

## Response 404 fields (application/problem+json):

  - `type` (string, required)
    Stable URL identifying the problem type; links to documentation.

  - `title` (string, required)
    Human-readable summary of the problem type.

  - `status` (integer, required)
    HTTP status code of this response.

  - `detail` (string)
    Human-readable explanation of this occurrence.

  - `instance` (string, required)
    Request identifier for support and log correlation.

  - `code` (string, required)
    Stable machine-readable reason code.

  - `errors` (array)
    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).

  - `errors.code` (string, required)
    Stable machine-readable reason for this field.

  - `errors.pointer` (string, required)
    JSON Pointer for `body`; parameter name for `query`, `path`, or `header`.

  - `errors.message` (string, required)
    Human-readable explanation.

  - `errors.source` (string, required)
    Where the invalid value came from.
    Enum: "body", "query", "path", "header"

## Response 404 headers (application/problem+json):

  - `X-Request-Id` (string)
    Request identifier for support and log correlation.

## Response 406:

  - `406` (unknown)
    Requested `Accept` media type cannot be satisfied (`not_acceptable`).

## Response 406 fields (application/problem+json):

  - `type` (string, required)
    Stable URL identifying the problem type; links to documentation.

  - `title` (string, required)
    Human-readable summary of the problem type.

  - `status` (integer, required)
    HTTP status code of this response.

  - `detail` (string)
    Human-readable explanation of this occurrence.

  - `instance` (string, required)
    Request identifier for support and log correlation.

  - `code` (string, required)
    Stable machine-readable reason code.

  - `errors` (array)
    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).

  - `errors.code` (string, required)
    Stable machine-readable reason for this field.

  - `errors.pointer` (string, required)
    JSON Pointer for `body`; parameter name for `query`, `path`, or `header`.

  - `errors.message` (string, required)
    Human-readable explanation.

  - `errors.source` (string, required)
    Where the invalid value came from.
    Enum: "body", "query", "path", "header"

## Response 406 headers (application/problem+json):

  - `X-Request-Id` (string)
    Request identifier for support and log correlation.

## Response 409:

  - `409` (unknown)
    Domain conflict (`slot_taken`, `duplicate_location`, `last_location_owner`), idempotency conflict, or generic `conflict` when no more specific registered code applies.

## Response 409 fields (application/problem+json):

  - `type` (string, required)
    Stable URL identifying the problem type; links to documentation.

  - `title` (string, required)
    Human-readable summary of the problem type.

  - `status` (integer, required)
    HTTP status code of this response.

  - `detail` (string)
    Human-readable explanation of this occurrence.

  - `instance` (string, required)
    Request identifier for support and log correlation.

  - `code` (string, required)
    Stable machine-readable reason code.

  - `errors` (array)
    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).

  - `errors.code` (string, required)
    Stable machine-readable reason for this field.

  - `errors.pointer` (string, required)
    JSON Pointer for `body`; parameter name for `query`, `path`, or `header`.

  - `errors.message` (string, required)
    Human-readable explanation.

  - `errors.source` (string, required)
    Where the invalid value came from.
    Enum: "body", "query", "path", "header"

## Response 409 headers (application/problem+json):

  - `X-Request-Id` (string)
    Request identifier for support and log correlation.

  - `Retry-After` (integer)
    Seconds to wait before retrying.

## Response 422:

  - `422` (unknown)
    Semantic validation failed (`validation_failed`); field-level details are in `errors[]`. Merge-patch violations use `field_not_nullable` / `field_immutable`.

## Response 422 fields (application/problem+json):

  - `type` (string, required)
    Stable URL identifying the problem type; links to documentation.

  - `title` (string, required)
    Human-readable summary of the problem type.

  - `status` (integer, required)
    HTTP status code of this response.

  - `detail` (string)
    Human-readable explanation of this occurrence.

  - `instance` (string, required)
    Request identifier for support and log correlation.

  - `code` (string, required)
    Stable machine-readable reason code.

  - `errors` (array)
    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).

  - `errors.code` (string, required)
    Stable machine-readable reason for this field.

  - `errors.pointer` (string, required)
    JSON Pointer for `body`; parameter name for `query`, `path`, or `header`.

  - `errors.message` (string, required)
    Human-readable explanation.

  - `errors.source` (string, required)
    Where the invalid value came from.
    Enum: "body", "query", "path", "header"

## Response 422 headers (application/problem+json):

  - `X-Request-Id` (string)
    Request identifier for support and log correlation.

## Response 429:

  - `429` (unknown)
    Rate limit exceeded (`rate_limit_exceeded`). Retry after `Retry-After`.

## Response 429 fields (application/problem+json):

  - `type` (string, required)
    Stable URL identifying the problem type; links to documentation.

  - `title` (string, required)
    Human-readable summary of the problem type.

  - `status` (integer, required)
    HTTP status code of this response.

  - `detail` (string)
    Human-readable explanation of this occurrence.

  - `instance` (string, required)
    Request identifier for support and log correlation.

  - `code` (string, required)
    Stable machine-readable reason code.

  - `errors` (array)
    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).

  - `errors.code` (string, required)
    Stable machine-readable reason for this field.

  - `errors.pointer` (string, required)
    JSON Pointer for `body`; parameter name for `query`, `path`, or `header`.

  - `errors.message` (string, required)
    Human-readable explanation.

  - `errors.source` (string, required)
    Where the invalid value came from.
    Enum: "body", "query", "path", "header"

## Response 429 headers (application/problem+json):

  - `Retry-After` (integer)
    Seconds to wait before retrying.

  - `RateLimit-Remaining` (integer)
    Requests left in the most constrained policy window that applies to this request.

  - `RateLimit-Reset` (integer)
    On `429`, seconds until the most constrained policy frees up; it equals `Retry-After` there.
On a successful response it reports the **length** of that policy's window rather than the
time left in the current one, so treat it as the window size, not as a countdown — the
counter to pace against is `RateLimit-Remaining`.

  - `RateLimit-Policy` (string)
    Most constrained policy applied to the request, as `<limit>;w=<window in seconds>`.
    Example: 10;w=60

  - `X-Request-Id` (string)
    Request identifier for support and log correlation.

## Response 500:

  - `500` (unknown)
    Unexpected server error (`internal_error`).

## Response 500 fields (application/problem+json):

  - `type` (string, required)
    Stable URL identifying the problem type; links to documentation.

  - `title` (string, required)
    Human-readable summary of the problem type.

  - `status` (integer, required)
    HTTP status code of this response.

  - `detail` (string)
    Human-readable explanation of this occurrence.

  - `instance` (string, required)
    Request identifier for support and log correlation.

  - `code` (string, required)
    Stable machine-readable reason code.

  - `errors` (array)
    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).

  - `errors.code` (string, required)
    Stable machine-readable reason for this field.

  - `errors.pointer` (string, required)
    JSON Pointer for `body`; parameter name for `query`, `path`, or `header`.

  - `errors.message` (string, required)
    Human-readable explanation.

  - `errors.source` (string, required)
    Where the invalid value came from.
    Enum: "body", "query", "path", "header"

## Response 500 headers (application/problem+json):

  - `X-Request-Id` (string)
    Request identifier for support and log correlation.

## Response 503:

  - `503` (unknown)
    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.

## Response 503 fields (application/problem+json):

  - `type` (string, required)
    Stable URL identifying the problem type; links to documentation.

  - `title` (string, required)
    Human-readable summary of the problem type.

  - `status` (integer, required)
    HTTP status code of this response.

  - `detail` (string)
    Human-readable explanation of this occurrence.

  - `instance` (string, required)
    Request identifier for support and log correlation.

  - `code` (string, required)
    Stable machine-readable reason code.

  - `errors` (array)
    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).

  - `errors.code` (string, required)
    Stable machine-readable reason for this field.

  - `errors.pointer` (string, required)
    JSON Pointer for `body`; parameter name for `query`, `path`, or `header`.

  - `errors.message` (string, required)
    Human-readable explanation.

  - `errors.source` (string, required)
    Where the invalid value came from.
    Enum: "body", "query", "path", "header"

## Response 503 headers (application/problem+json):

  - `X-Request-Id` (string)
    Request identifier for support and log correlation.

## Response 400 examples:

  - `Generic client reject (status default)` (unknown)

  - `Broken JSON / protocol only` (unknown)

## Response 403 examples:

  - `Token scope is insufficient` (unknown)

  - `Subject lacks the business permission` (unknown)

  - `Location license is not active` (unknown)

## Response 404 examples:

  - `Generic 404 (routing / gate / hidden)` (unknown)

  - `Resource-specific 404` (unknown)

