API · Customers

Consents

GET /consents/texts?locale= — the current texts of all active consent types in the customer's language. A version is a legal edition of the type's text; the current one is the latest whose date has come. The text is in the requested language, otherwise in the organization's customer language (customer_locale, without it — default_locale), otherwise the first available; locale in the response is the actual one. The app sends type and version from the response when recording consent.

POST /customers/{id}/consents — a “given” batch, POST /customers/{id}/consents/revoke — a “revoked” batch. An item is the type, the text version (without it — the current one on the local date of the fact in the organization's time zone; for a revocation — the version of the last record), the channel (app, office, paper… — the organization's codes), the agent's external id, a signature attachment, the moment of the fact occurred_at (RFC 3339 with a zone, by the device clock: an offline queue brings yesterday's signatures; without it — the moment of the request). The customer's state for a type is the last record by occurred_at, always in Customer.consents. Both operations are under Idempotency-Key; inside, the fact has a natural key (type + version + status + occurred_at): repeating the same form with a new key creates no records, meta.recorded shows how many were inserted.

Record a batch of “given” consents

POST/customers/{id}/consents

A batch of “the customer gave consent” facts in one call and one transaction: each item is a type (entity_types:consent_type, existing; case-insensitive), a text version (GET /consents/texts; without it — the current one on the local date of occurred_at in the organization's time zone, and without that — on the local today; a type without an effective version is an error), a channel, an agent, a signature attachment and the moment of the fact. Each type appears in a batch once. The attachment is bound to the record (attachments.owner); one signature for several types is allowed — the first record is the owner, the others refer to the same attachment_id; an attachment of another record or interaction is an error. A repeat of the same fact (same type, version, status and occurred_at) does not create a row — idempotent without Idempotency-Key; a repeat with a different attachment is an error: the record is immutable, and a signature must not silently disappear. Each new record that changes the state of a type is a consents.<type> history row. The response is the customer card with the state per type and meta.recorded (how many rows were inserted). Ability consents:write; the project plays no part.

Parameters

  • Idempotency-Keystringheaderrequired

    Idempotency key: unique within the client, lives for 24 hours. A repeat with the same key and request returns the saved response with meta.idempotent_replay: true; a different request with the same key gets IDEMPOTENCY_MISMATCH. A UUID is recommended.
    Constraints
    minLength: 1maxLength: 255
  • idstring (uuid)pathrequired

Request body

application/json

ConsentsInput

Batch of consents with one status
  • consentsarray<ConsentInput>required

    Batch items; each type at most once
    Constraints
    minItems: 1maxItems: 100
  • sourcestring | null

    How the fact reached the CRM — a code in snake_case; api when omitted
    Constraints
    maxLength: 64
    Example
    api

Responses

  • 200

    Customer card with the consent state; meta.recorded — rows inserted

    application/json

    object

  • 401

    UNAUTHENTICATED — the Bearer token is missing or invalid

    Error format and codes

  • 403

    FORBIDDEN — the token lacks an ability (details.ability) or a project (details.project)

    Error format and codes

  • 404

    NOT_FOUND — resource or route not found

    Error format and codes

  • 409

    IDEMPOTENCY_IN_PROGRESS — a request with this key is still running (details.key); CONFLICT — the customer is merged into another: details.customer_id, details.merged_into — the primary

    Error format and codes

  • 422

    VALIDATION_FAILED — details.fields: consents (empty or more than 100), consents.<i>.type (unknown type, duplicate in the batch), consents.<i>.version (no such version; no version effective on the local date of the fact), consents.<i>.channel, consents.<i>.agent_ref, consents.<i>.attachment_id (not in the organization or purged, already bound to another record, a repeat of the fact with a different attachment), consents.<i>.occurred_at (not RFC 3339 with a time zone, more than a minute in the future), consents.<i>.interaction_id (forbidden), source, Idempotency-Key; IDEMPOTENCY_MISMATCH — the key has already been used for a different request (details.key).

    Error format and codes

  • 429

    RATE_LIMITED — the client's rate limit is exceeded: details.limit — the limit per minute, details.retry_after — in how many seconds to retry; the same values are in the headers X-RateLimit-Limit and Retry-After.

    Headers

    • Retry-Afterinteger

      Seconds until the window resets
    • X-RateLimit-Limitinteger

    • X-RateLimit-Remaininginteger

    Error format and codes

Record a batch of “revoked” consents

POST/customers/{id}/consents/revoke

The same shape and rules as POST /customers/{id}/consents; the record status is revoked. A version without a number is the version of the customer's last record of this type (the text being revoked), or the current one if there were no records; a revocation without a preceding “given” is allowed: an explicit refusal is a state too. The response is the card with revoked and the fact date per type.

Parameters

  • Idempotency-Keystringheaderrequired

    Idempotency key: unique within the client, lives for 24 hours. A repeat with the same key and request returns the saved response with meta.idempotent_replay: true; a different request with the same key gets IDEMPOTENCY_MISMATCH. A UUID is recommended.
    Constraints
    minLength: 1maxLength: 255
  • idstring (uuid)pathrequired

Request body

application/json

ConsentsInput

Batch of consents with one status
  • consentsarray<ConsentInput>required

    Batch items; each type at most once
    Constraints
    minItems: 1maxItems: 100
  • sourcestring | null

    How the fact reached the CRM — a code in snake_case; api when omitted
    Constraints
    maxLength: 64
    Example
    api

Responses

  • 200

    Customer card with the consent state; meta.recorded — rows inserted

    application/json

    object

  • 401

    UNAUTHENTICATED — the Bearer token is missing or invalid

    Error format and codes

  • 403

    FORBIDDEN — the token lacks an ability (details.ability) or a project (details.project)

    Error format and codes

  • 404

    NOT_FOUND — resource or route not found

    Error format and codes

  • 409

    IDEMPOTENCY_IN_PROGRESS — a request with this key is still running (details.key); CONFLICT — the customer is merged into another: details.customer_id, details.merged_into — the primary

    Error format and codes

  • 422

    VALIDATION_FAILED — as for POST /customers/{id}/consents; IDEMPOTENCY_MISMATCH (details.key)

    Error format and codes

  • 429

    RATE_LIMITED — the client's rate limit is exceeded: details.limit — the limit per minute, details.retry_after — in how many seconds to retry; the same values are in the headers X-RateLimit-Limit and Retry-After.

    Headers

    • Retry-Afterinteger

      Seconds until the window resets
    • X-RateLimit-Limitinteger

    • X-RateLimit-Remaininginteger

    Error format and codes

Current consent texts in the customer's locale

GET/consents/texts

For each active consent type (entity_types:consent_type, by code) — the current text version: the highest-numbered among versions whose effective_from date has arrived (a calendar date in the organization's time zone — effective_from is the legal effective date; without a configured time zone — UTC). The text is in the requested locale (locale, ISO 639-1, case-insensitive), otherwise in the organization's default customer language (settings.customer_locale, without it — default_locale), otherwise the first available; locale in the item is the language of the text actually returned. A type without an effective version is present with version, effective_from, locale and text = null. Without locale — the organization's customer language. Ability consents:read; an organization setting, the project plays no part.

Parameters

  • localestringquery

    Customer language code, ISO 639-1 (ru, kk); kk-KZ is VALIDATION_FAILED under locale
    Constraints
    pattern: ^[A-Za-z]{2}$
    Example
    kk

Responses

  • 200

    Texts by type

    application/json

    object

  • 401

    UNAUTHENTICATED — the Bearer token is missing or invalid

    Error format and codes

  • 403

    FORBIDDEN — the token lacks an ability (details.ability) or a project (details.project)

    Error format and codes

  • 422

    VALIDATION_FAILED — details.fields with errors by field

    Error format and codes

  • 429

    RATE_LIMITED — the client's rate limit is exceeded: details.limit — the limit per minute, details.retry_after — in how many seconds to retry; the same values are in the headers X-RateLimit-Limit and Retry-After.

    Headers

    • Retry-Afterinteger

      Seconds until the window resets
    • X-RateLimit-Limitinteger

    • X-RateLimit-Remaininginteger

    Error format and codes

Schemas

ConsentInput

object

Consent batch item; the same item is used in the consents block at registration and in an interaction (there occurred_at defaults to the interaction's started_at). interaction_id is forbidden in the item — the server sets the link to the interaction.
  • typestringrequired

    Consent type code (entity_types:consent_type), case-insensitive
    Constraints
    maxLength: 64
    Example
    pdn
  • versioninteger | null

    Text version number from GET /consents/texts. Without it: “given” — the current version on the local date of occurred_at in the organization's time zone (without that — on the local today), “revoked” — the version of the customer's last record of the type, otherwise the current one. A nonexistent number — VALIDATION_FAILED.
    Constraints
    minimum: 1
    Example
    1
  • channelstringrequired

    Where the customer expressed their will — an arbitrary channel code in snake_case (app, office, paper, web); the CRM does not interpret it
    Constraints
    maxLength: 64
    Example
    app
  • agent_refstring | null

    External ID of the agent in whose presence consent was given (predates the agent registry); leading and trailing spaces are trimmed
    Constraints
    maxLength: 255
    Example
    AG-7
  • attachment_idstring (uuid) | null

    Signature attachment (POST /attachments) in this organization, not yet linked or linked to a record of the same batch (one signature for several types). Linking removes the retention period.
  • occurred_atstring (date-time) | null

    Moment of the fact by the client's clock — strictly RFC 3339 with a time zone (Z or ±hh:mm), no later than the request moment plus one minute (tolerance for the device clock); fractional seconds are dropped. Without it — the request moment. Part of the fact's natural key: a retry with the same value does not create a record.
    Constraints
    maxLength: 64

Customer

object

The customer card — one contract for POST /customers, GET /customers/search and GET /customers/{id}. attributes — every active schema field visible to the API, under its code (not set — null); identities — all identities with normalized values (slot types phone/email/national_id — only if the field of that slot is visible to the API, custom types — always); labels — active labels; in responses of customer operations they already include rule labels recalculated by this request. consents — consent state by type (the latest record of each type; types without records are absent); balances — one element for each active account kind of the organization (an account has no project — it is visible to everyone who can see the customer; a kind without entries shows zero; a disabled kind is not returned); assets — assets whose current owner is the customer, in any status, newest first (an asset has no project; assets of disabled types and of types with corrupted settings are not returned — the latter until the settings are fixed on the “Entity types” page); history — only with include=history.
  • idstring (uuid)required

  • typestringrequired

    Customer type code
  • statusstringrequired

    Record lifecycle; blocks and segments are labels, not a status
    Values
    activearchivedmerged
  • sourcestringrequired

    Code of the channel that created the record (api, admin, import or a custom one)
  • attributesobjectrequired

  • identitiesarray<CustomerIdentity>required

  • labelsarray<CustomerLabel>required

    Active labels, one element per code, in order of the code's first row; the top-level created_at is the moment of the manual row if there is one, so it can be later than that of the next label
  • consentsarray<Consent>required

    The latest record of each consent type, by type code
  • balancesarray<CustomerBalance>required

    By active account kinds, in ascending order of the kind code
  • assetsarray<Asset>required

  • created_atstring (date-time)required

    ISO 8601, UTC
  • updated_atstring (date-time)required

    ISO 8601, UTC
  • historyarray<CustomerHistoryEntry>

    Only with include=history; without it the key is absent

CustomerIdentity

object

A customer identity — the normalized value (E.164, lower case, digits only or as is — depending on the type); id is for DELETE /customers/{id}/identities/{identity}.
  • idstring (uuid)required

  • typestringrequired

    Identity type code (phone, email, national_id or a custom one)
  • valuestringrequired

CustomerLabel

object

Active customer label — one item per code; expired labels are not in the response. A label can have two rows — manual and rule; the label is active while at least one of them is. The top-level fields come from the manual row if there is one, otherwise from the rule row; sources — each active row.
  • codestringrequired

    Label type code (lower case)
  • kindstringrequired

    Kind from the type settings — blocking operations, a group, a flag
    Values
    blocksegmentflag
  • reasonstring | nullrequired

  • expires_atstring (date-time) | nullrequired

    ISO 8601, UTC; null — no expiry
  • sourcestringrequired

    Set manually or by a rule
    Values
    manualrule
  • created_byActorrequired

  • created_atstring (date-time)required

    Moment the label was set, ISO 8601, UTC
  • sourcesarray<CustomerLabelSource>required

    Active label rows by source — the manual one first

Actor

object

Who performed the operation — an API client, an admin panel user or the system
  • kindstringrequired

    Values
    api_clientusersystem
  • idstring | nullrequired

    ID of the API client (UUID) or user; null for system

CustomerLabelSource

object

Label row of one source: a person sets and removes the manual row, only the rule sets and removes the rule row (it cannot be removed via DELETE …/labels/{code}).
  • sourcestringrequired

    Values
    manualrule
  • rule_idstring (uuid) | nullrequired

    Rule that set the row; null for the manual one
  • reasonstring | nullrequired

  • expires_atstring (date-time) | nullrequired

    ISO 8601, UTC; null — no expiry
  • created_byActorrequired

  • created_atstring (date-time)required

    Moment the row was set, ISO 8601, UTC

object

Consent state by type — the last record
  • typestringrequired

    Consent type code
  • statusstringrequired

    Values
    givenrevoked
  • versionintegerrequired

    Number of the text version the record refers to
    Constraints
    minimum: 1
  • channelstringrequired

  • agent_refstring | nullrequired

  • occurred_atstring (date-time)required

    Moment of the fact by the client's clock, ISO 8601, UTC
  • sourcestringrequired

    How the fact reached the CRM (api, admin, import, …)
  • attachment_idstring (uuid) | nullrequired

    Signature attachment; link — GET /attachments/{id}/url
  • interaction_idstring (uuid) | nullrequired

    Interaction in which it was submitted; null before it
  • created_byActorrequired

  • created_atstring (date-time)required

    Record moment, ISO 8601, UTC

CustomerBalance

object

Customer balance by account kind. There is no kind label — as with the card's labels and consents, kind labels are in the schema (GET /v1/schema).
  • account_kindstringrequired

    Account kind code (entity_types:account_kind)
    Example
    points
  • balancestringrequired

    Balance — a decimal as a string with exactly the kind's number of decimal places (scale): "0" for a kind with no decimal places, "100.50" for a kind with two; can be negative (a minus allowed by the kind, or a reversal).
    Example
    100100.50-40.00
  • unitobject | nullrequired

    Unit label for displaying the balance — a “language → text” object with any languages; null — not set. One form per language, as set on the account kind: plural forms by number (“1 point”, “5 points”) are not returned by the API — the forms are in the account kind settings, and only the admin panel uses them.
    Example
    {"ru":"балл","en":"pts"}

    Key values: string

Asset

object

Customer asset — an item of the customer card's assets, of lists and of asset write responses. The status is a code without a label (status labels are in the asset type settings, as with balances and labels). attributes — each active field of the asset:<type> schema visible to the API, under its code (not set — null).
  • idstring (uuid)required

  • typestringrequired

    Asset type code (entity_types:asset_type)
    Example
    device
  • serialstringrequired

    Serial number as sent (without leading and trailing spaces, NFC); unique within the type by its normalized form
  • modelobject | nullrequired

    Model — an item of the type's catalog (catalog); null — no model specified
    Fields
    • idstring (uuid)required

    • codestringrequired

      Item code in the catalog
  • statusstringrequired

    Status code from the type settings
    Example
    owned
  • customer_idstring (uuid) | nullrequired

    Owner; null — the asset has no owner (after the registering interaction is voided or the owner is removed)
  • attributesobjectrequired

  • created_atstring (date-time)required

    ISO 8601, UTC
  • updated_atstring (date-time)required

    Moment of the last change (status, owner, attributes), ISO 8601, UTC

CustomerHistoryEntry

object

A change of one customer field: field — the path (type, status, a slot code — phone, national_id, …; attributes.<field code>; identities.<type> — the list of normalized values of the type; labels.<code> — labels), old_value/new_value — before and after (null — was not set / is no longer set). On creation — a row for each value set.
  • fieldstringrequired

    Example
    phoneattributes.favorite_productidentities.qr_token
  • old_valueany valuerequired

  • new_valueany valuerequired

  • created_byActorrequired

  • created_atstring (date-time)required

    ISO 8601, UTC

Meta

object

Service data of the response; for lists it contains cursor
  • cursorobject

    Fields
    • nextstring | nullrequired

      Cursor of the next page, null — there are no more pages
  • redirected_fromstring (uuid)

    Only on a redirect: the request came with the ID of a customer merged into another one (in the path or in the body's customer_id), the response is for the primary one; the value is the original ID (normalized, lower case). Without a redirect the key is absent. A retry with the same Idempotency-Key returns the response stored by the first execution as is.
  • idempotent_replayboolean

    Only on a retry: the response is taken from the idempotency store, data is byte-for-byte the same as in the first response; or a retry by the interaction's natural key external_id — data is the existing interaction in its current state; or a repeated void of an already voided one. The first execution has no such field.
    Always
    true
  • versioninteger

    Only in catalog lists: the catalog version — for items it is read before the rows of the first page of the traversal, for changes it is the upper bound of the feed. The next sync is changes?since=<version>.
    Constraints
    minimum: 0
  • recordedinteger

    Only when recording consents: how many rows were inserted; 0 — the whole batch was already recorded (a retry by natural key).
    Constraints
    minimum: 0
  • effectsInteractionEffects

InteractionEffects

object

Effects of the operation: what rules and accounts did in its transaction. On a retry by external_id the deltas are empty. Rules are recalculated when an interaction is created, edited and voided: labels_added and labels_removed are labels the customer gained and lost; a change of a rule row that did not make a label appear or disappear (a manual row exists alongside, a row of another rule is overwritten) is visible only in rules_fired. balances — changes to the customer's balances made by the operation (redemptions and accruals on create, offsetting entries on void), one element per kind in ascending order of the code; empty on a retry and an edit. assets — asset changes made by the operation (actions on item serial numbers on create, their reversal on void) in recording order; empty on a retry and an edit. labels and current_balances — the customer's state after the operation, returned on a retry too.
  • labels_addedarray<CustomerLabel>required

    Labels the customer gained in the operation
  • labels_removedarray<string>required

    Codes of labels the customer lost in the operation
  • balancesarray<BalanceChange>required

    Balance changes of the operation by account kind
  • assetsarray<AssetChange>required

    Asset changes of the operation
  • rules_firedarray<RuleFired>required

    Changes to label rows made by rules, in order of application
  • labelsarray<CustomerLabel>required

    The customer's active labels after the operation
  • current_balancesarray<CustomerBalance>required

    The customer's current balances after the operation — like balances of the customer card: one element for each active account kind, zero without entries

BalanceChange

object

A change of the customer's balance of one account kind in the operation: change — the sum of the operation's entries for the kind (signed; a redemption and an accrual of one kind make one element), balance — the balance after; decimal as a string with exactly the kind's scale, unit — as in CustomerBalance. A kind with corrupted settings (a void goes through for it as well) — in canonical form, unit: null.
  • account_kindstringrequired

  • changestringrequired

    Example
    -3000
  • balancestringrequired

    Example
    2000
  • unitobject | nullrequired

    As unit in CustomerBalance — one unit form per language, not inflected by number

    Key values: string

AssetChange

object

An asset change made by an interaction operation: registered — registration (status_from: null) or re-linking of an ownerless asset, transitioned — a transition of the customer's asset, reverted — undone on void; customer_id — the owner after the change
  • idstring (uuid)required

  • typestringrequired

    Asset type code
  • serialstringrequired

    Serial number as recorded
  • eventstringrequired

    Values
    registeredtransitionedreverted
  • status_fromstring | nullrequired

  • status_tostringrequired

  • customer_idstring (uuid) | nullrequired

RuleFired

object

A rule that fired: the rule's label row was set (set) or removed (removed).
  • rulestringrequired

    Rule code
  • rule_idstring (uuid)required

    Rule ID — same as sources[].rule_id of a customer label
  • labelstringrequired

    Label code
  • actionstringrequired

    Values
    setremoved

ConsentText

object

The current consent text of one type. version — the legal edition number per type, effective_from — the version date (Y-m-d), locale — the language of the returned text (after fallback), text — plain text with line breaks. For a type without an effective version these four fields are null.
  • typestringrequired

    Consent type code; it and version are sent in a consent record
    Example
    pdn
  • labelobjectrequired

    Type label by interface language: {"ru": …, "en": …}

    Key values: string

  • versioninteger | nullrequired

    Constraints
    minimum: 1
  • effective_fromstring (date) | nullrequired

  • localestring | nullrequired

    Constraints
    pattern: ^[a-z]{2}$
  • textstring | nullrequired