API · Interactions and accounting

Interactions

An interaction is a piece of work with a customer in a project: a sale, a visit, a consultation.

  • POST /interactions — registration: type, customer, time, items by catalog item codes, attributes by the type's schema; the response carries the meta.effects block. Idempotency works both by Idempotency-Key and by the natural key external_id.
  • GET /interactions/{id} and GET /customers/{id}/interactions — only interactions of projects assigned to the API client.
  • PATCH /interactions/{id} changes attributes only — items, type, customer and time are immutable; each change is a revision, visible in GET /interactions/{id}?include=revisions.
  • POST /interactions/{id}/void — voiding an erroneous interaction.

Interaction by ID

GET/interactions/{id}

An interaction in any status: a voided one has status: void with the void fields. Ability interactions:read. Only interactions of projects assigned to the API client are visible (including deactivated ones: deactivation closes writing, not history). Not in the organization or the project is not assigned — NOT_FOUND with details.id (another project is indistinguishable from a nonexistent one); an ID that is not a UUID — also 404. include=revisions — revisions (attribute edits and voids) in Interaction.revisions, only for fields visible to the API. include=ledger_entries — the interaction's entries (redemptions, accruals, reversing entries and — for an interaction of a merged customer — the transfer pair to the primary on void) in Interaction.ledger_entries in write order; requires the ledgers:read ability — without it FORBIDDEN with details.ability (before the interaction is looked up). include=assets — the interaction's asset events (its actions on item serials and their cancellations on void) in Interaction.assets by event moment (equal moments — by asset and number); requires the assets:read ability — the same way. A parameter outside the list — VALIDATION_FAILED “Unknown parameter”, a numeric name — under query.

Parameters

  • idstring (uuid)pathrequired

  • includestringquery

    Comma-separated extensions — revisions, ledger_entries (ability ledgers:read), assets (ability assets:read). An unknown block — details.fields.include.
    Example
    revisionsrevisions,ledger_entries

Responses

  • 200

    Interaction

    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

  • 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

Update interaction attributes

PATCH/interactions/{id}

Attribute edit: attributes holds only the changed fields of the type's schema under their codes; null clears an optional field (so do an empty string and a whitespace-only string: the server trims the edges and turns empty into null), a required field cannot be cleared with null, an empty multi_enum list equals null; fields not sent (and fields hidden from the API) are left untouched. A field hidden from the API, inactive or unknown — VALIDATION_FAILED under attributes.<code>; phone_verified is set only by the system from verification_id on creation — a sent value, including null, is rejected. A catalog reference value equal to the stored one is not rechecked (a form may send all fields).

An interaction with a reference to a decision table row: the attribute from which the active type's decision setting takes a table parameter cannot be changed — VALIDATION_FAILED under attributes.<code> (the row eligibility was checked against it on creation; the fix is a void and a new interaction). If the parameter comes from the result, an edit of the result rule field that changes the result is rejected the same way. A value equal to the stored one is a no-op. A type without a decision setting or a retired type has no such restriction. The restriction is checked against the values the schema accepted: if the request has attribute errors, the response contains only them, and the restriction comes after they are fixed.

An interaction with an accrual by an account kind's decision table: the attribute from which the accruals setting of an enabled kind that accrued for the interaction takes a table parameter cannot be changed — the same VALIDATION_FAILED under attributes.<code>, including for a retired type (the accrual stays); the result rule field when the parameter comes from the result — the same, while the type is in use.

Items, type, project, customer, time, references, attachments, consents and verification are immutable: any body key other than attributes (even with an empty value — items: []) — VALIDATION_FAILED under its name, a numeric key (including a list body) — under body; the query string is not read. This shape check comes before the others: for a voided interaction such a request is also 422.

Order of refusals: access (NOT_FOUND — not in the organization or the project is not assigned to the API client, as in GET; FORBIDDEN with details.project — the project is deactivated) — then void (CONFLICT with details {id, status: "void"}: a voided interaction cannot be edited) — then attributes (VALIDATION_FAILED, all errors at once).

Each change is an updated revision with the diff attributes.<code> (author — the API client of the token) and an event for rules; updated_at moves. If the field the type computes the result from (result.attribute in the type settings) has changed, result is recalculated by the type's current rule and enters the diff under the path result; editing another field does not touch the result, and for a retired type the result is not recalculated. An edit “to the same value” and {} are a no-op: 200, no revision and no event, updated_at does not change, effect deltas are empty.

No idempotency key is needed — repeating the same body changes nothing; a repeat after a lost response returns empty meta.effects deltas (the effects of the first run are not repeated). Concurrent edits of different fields do not lose each other; of the same field — the last one wins. Ability interactions:write.

Parameters

  • idstring (uuid)pathrequired

Request body

application/json

InteractionPatch

Body of an interaction attributes edit; there are no other keys
  • attributesobjectrequired

    Only the type schema fields being changed, under their codes; null clears an optional field
    Example
    {"note":"Call back in the evening","outcome":null}

No other keys

Responses

  • 200

    Interaction after the edit (or unchanged) and rule effects

    application/json

    InteractionResponse

    • dataInteractionrequired

    • metaobjectrequired

      Service data of the response; for lists it contains cursor
      Fields
      • 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
      • effectsInteractionEffectsrequired

  • 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

    CONFLICT — a conflict with existing data. A request with the ID of a merged customer — both reads and writes — is redirected to the primary customer (meta.redirected_from). For writes, if the customer was merged while the request was waiting, the operation is restarted once on the primary customer; a second conflict in the restart is returned: the primary was merged too — details.customer_id, details.merged_into; the customer was changed concurrently with the edit — details.customer_id, re-read and retry

    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

Void an interaction

POST/interactions/{id}/void

Void: status void, reason, moment and author (the API client of the token); a voided revision (diff of status and void_reason, visible in GET /interactions/{id}?include=revisions). Ability interactions:write; the Idempotency-Key header is required. The project comes from the interaction: not assigned to the API client or the interaction is not in the organization — NOT_FOUND (as in GET); assigned but deactivated — FORBIDDEN with details.project (reading is allowed, writing is not).

reason — a human-readable reason, 1–1000 characters, multiline; whitespace at the edges (including non-breaking spaces) is trimmed, control characters other than line breaks and tabs — VALIDATION_FAILED under reason.

Response 200 — the interaction after the void and meta.effects — what rules did in the same transaction (removed labels) and accounts did (reversing entries for all of the interaction's redemptions and accruals — bypassing the negative-balance ban, a disabled kind and the customer status; balances — changes by kind), the customer's active labels and current balances after the operation. Order of refusals: reason (VALIDATION_FAILED) — then access (NOT_FOUND, FORBIDDEN) — then repeat. A repeated void (already void, with any valid reason) — 200 as is: the first reason, meta.idempotent_replay: true, empty effect deltas. The same Idempotency-Key — the saved first response (with its effects; the project is not rechecked); the same key with a different body (any byte difference, including whitespace) or for another interaction — IDEMPOTENCY_MISMATCH. A voided interaction stays in reads and lists (status: void); the list of active ones — GET /customers/{id}/interactions?status=active. A void does not release the phone verification.

Parameters

  • idstring (uuid)pathrequired

  • 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

Request body

application/json

VoidInput

Void body
  • reasonstringrequired

    Human-readable reason, may be multiline
    Constraints
    minLength: 1maxLength: 1000

Responses

  • 200

    Interaction voided (or already was — meta.idempotent_replay)

    application/json

    InteractionResponse

    • dataInteractionrequired

    • metaobjectrequired

      Service data of the response; for lists it contains cursor
      Fields
      • 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
      • effectsInteractionEffectsrequired

  • 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 Idempotency-Key (details.key) is still running; retry later to get the stored response.

    Error format and codes

  • 422

    VALIDATION_FAILED — details.fields: reason, Idempotency-Key; IDEMPOTENCY_MISMATCH — the key was already used for another request (the path or body differs, 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

Customer interactions

GET/customers/{id}/interactions

A page of the customer's interactions, newest first (started_at descending, ties — by id), cursor pagination: meta.cursor.next is passed as the cursor parameter with the same filters until it becomes null. Ability interactions:read; only projects assigned to the API client are visible (including deactivated ones). The customer is not in the organization — NOT_FOUND with details.id; an ID that is not a UUID — a route 404 without details.id. Filters: type and campaign — codes (an unknown code gives an empty list, a malformed one gives an error), status — active or void (both by default), from/to — RFC 3339 with a time zone, the half-open interval [from, to) on started_at with one-second precision (from strictly less than to). Errors — VALIDATION_FAILED with details.fields.<parameter>, before the customer check: first the request shape (an array instead of a string, a non-numeric limit, a parameter outside the list — including include — “Unknown parameter”, a numeric name — under query), then the values — all at once (codes, status, period, limit range, cursor).

Parameters

  • idstring (uuid)pathrequired

  • typestringquery

  • campaignstringquery

  • statusstringquery

    Values
    activevoid
  • fromstring (date-time)query

  • tostring (date-time)query

  • limitintegerquery

    List page size, 1…200; 50 when omitted
    Default
    50
    Constraints
    minimum: 1maximum: 200
  • cursorstringquery

    Opaque cursor from meta.cursor.next of the previous page; valid only with the same filters — otherwise VALIDATION_FAILED under cursor. Without the parameter — the first page.
    Constraints
    maxLength: 512

Responses

  • 200

    A page of interactions

    application/json

    object

    • dataarray<Interaction>required

    • metaobjectrequired

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

        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

  • 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

  • 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

Record an interaction

POST/interactions

Creation is synchronous: the response is the interaction with its items and the operation's effects, or an error. Ability interactions:write; the Idempotency-Key header is required; project — the code of a project assigned to the client (otherwise FORBIDDEN with details.project).

Body: type — the code of an active interaction type available in the project; customer_id — a customer of the organization in active status (search by identities — GET /customers/search); started_at/ended_at — RFC 3339 with a time zone by the device clock, no later than “now” + 60 s; agent_ref, outlet_ref — strings up to 255 characters; lat/lng — as a pair, a number or a string (rounded to 6 digits); external_id — the API client's key (up to 128 characters); campaign — the code of a campaign active in the project at started_at; attributes — fields of the interaction:<type> schema under their codes (GET /schema/interaction:<type>), errors — under attributes.<code> (unlike POST /customers: the top level of the body is taken by interaction fields); items — items: role — a role from the type settings, item — the catalog item code in the role's catalog, quantity — an integer from 1, price/discount — decimals as strings with up to 2 digits (facts, the CRM does not recalculate them), discount_kind — a discount kind code, serial — the asset serial: only for a role with the type's assets rule (otherwise VALIDATION_FAILED under items.<i>.serial), required if the rule requires it; normalized by the asset type's rule, up to 128 characters, the quantity of an item with a serial is 1, the same asset twice in a request is an error. The number of items per role is within the type settings. items[].attributes are not accepted yet (VALIDATION_FAILED).

Attachments: attachments — up to 20 IDs of files uploaded with POST /attachments in this organization and not yet bound (an expired but not yet purged one is accepted; the uploader is not checked). The kind comes from the attachment; attachments in the type settings are required kinds (the type requires, it does not restrict): without an attachment of the required kind — VALIDATION_FAILED under attachments. Element errors — under attachments.<i> together with the other data errors: not found (including purged), a repeat in the list, already bound (to a consent or another interaction), the same ID in consents.*.attachment_id. Attachments are bound in the same transaction as the interaction; a void does not release them. A repeat after a lost response — with the same Idempotency-Key or a body with the same external_id: a new request with the same attachments gets “already attached”.

Consents: consents — a batch of “given” records for the interaction's customer, of the same shape as POST /customers/{id}/consents; the rows refer to the interaction being created (interaction_id in the consents block of the customer card), occurred_at defaults to started_at, and they are written in the same transaction as the interaction. A type may require consents (consents in the type settings): the requirement is met if the type is in the batch or the customer's last record for it is “given” (any version); otherwise VALIDATION_FAILED under consents. Element errors — under consents.<i>.<field> together with the other data errors. A repeat by external_id does not write the consents again; a different batch with the same key — CONFLICT.

Phone verification: verification_id — a verification of the organization confirmed via POST /verifications/{id}/check whose addressee matches the customer's phone (for a customer without a phone — phone_mismatch), not older than the type's verification.max_age_seconds (a type setting in the admin panel, 600 s by default) and not used yet. It is bound to the interaction (one verification — one interaction, a void does not release it; an empty customer_id of the verification gets the interaction's customer) and sets the attribute phone_verified: true if the type's schema has an active field with this code. Such a field must be an optional boolean — otherwise any request of the type gets VALIDATION_FAILED under type (a configuration error). phone_verified is written only by the CRM: sent in attributes — VALIDATION_FAILED; without verification_id the attribute is not set (the API client may have verified the phone itself). A type may require verification (verification.required) — without it VALIDATION_FAILED under verification_id. A repeat after a lost response — with the same Idempotency-Key or the same body with the same external_id (200, meta.idempotent_replay); the same external_id with a different body — CONFLICT; a new request without them with an already bound verification — OTP_NOT_VERIFIED (already_used, and for another customer — customer_mismatch).

Reference to a decision table row: decision_line_id — the row ID (matched[].id of the POST /decision-tables/{code}/evaluate response). Accepted if the type has a decision setting (the table and the mapping of its parameters to interaction data; set in the admin panel), the row belongs to the type's table, the table is enabled and available to the interaction's project, and the row version is valid at started_at — otherwise VALIDATION_FAILED under decision_line_id. A type may require the reference (decision.required) — without it, the same. The values the table parameters come from (type attributes, campaign) are required with a reference — an empty one: VALIDATION_FAILED under attributes.<code> or campaign. A type configuration error — the table does not exist, the setting does not fit the table (the table changed after the setting was made), the source field is hidden from the API — VALIDATION_FAILED under type; checked only when a reference is sent or required. The reference is written as is and returned in decision_line_id; UUID case does not matter.

Row eligibility and limit: the row is evaluated for the customer at started_at with parameters from the mapping — the same way as POST /decision-tables/{code}/evaluate, but the row key is a condition too. A refusal — 422 with the reason code and details of the same shape as a row in the evaluation's rejected[]: NOT_QUALIFIED (the row conditions are not met or its key did not match the value from the interaction data, details.columns), BLOCKED (details.labels — the customer's blocking labels from the row's label column), LIMIT_REACHED (details.limits); all three have details.customer_id, row_id, row_code. On a refusal the interaction is not written and the verification stays unused. An accepted interaction with a reference — with a result or not — uses up the row limit; a void releases it. A value the table does not accept (an option outside the parameter's list, no catalog item) — VALIDATION_FAILED under the request field the parameter comes from (attributes.<code>, campaign), and if the parameter comes from the type, project or result code — under type. A table column template that fails the check against the current setting, or a disabled parameter catalog — VALIDATION_FAILED under type (together with the rest of the configuration; a disabled campaign catalog gives it before the campaign check).

Order of refusals: a repeat by external_id — first; configuration (project, type) — then the customer and blocking (BLOCKED: the customer has an active label of kind block that forbids the type, details.labels) — then all data errors in one VALIDATION_FAILED — then an inactive campaign or item (CATALOG_ITEM_INACTIVE, details.field — campaign or items.<i>.item) — then verification (OTP_NOT_VERIFIED, details.reason) — then the decision table parameter values (VALIDATION_FAILED) — then, for a row reference, the row evaluation (BLOCKED, NOT_QUALIFIED, LIMIT_REACHED with the row) — then, for the ledger block, the balance (INSUFFICIENT_BALANCE) — then, for items with a serial, assets (VALIDATION_FAILED with details.reasons).

Assets: for a role with the type's assets rule, the item serial (items[].serial) names the customer's asset. take moves this customer's asset to the rule's status by the type's transition table; an unregistered serial registers the asset to the customer directly in this status; an ownerless one (after a void) is bound again. give registers a new asset to the customer (the rule's status or the type's initial status); an ownerless one is bound again. Refusals — after the entries, in one VALIDATION_FAILED under items.<i>.serial with details.reasons (owned_by_other — another customer's asset, transition_not_allowed — no such transition, serial_taken — for give the asset already has an owner; for a single serial_taken — details.existing_id): no interaction, the verification and attachments are free. The rule's asset type is disabled or the rule does not fit the type — 422 under type. Changes — meta.effects.assets.

Redemption: the ledger block — redemptions from the customer's accounts in the same transaction as the interaction. The account kind comes from the type's ledger setting, is not repeated, exists and is enabled; the amount is positive, a decimal as a string (a JSON number — 422), with no more digits than the kind's scale, no rounding; the reason is required. redemption entries with a minus and a reference to the interaction are written after the rules; a redemption that takes the balance negative for a kind without negative balances — INSUFFICIENT_BALANCE: no interaction, the verification and attachments are free. An empty block is the same as none; the block enters the body fingerprint only when non-empty, as a set (element order does not matter, the kind code is case-insensitive).

Accrual: an account kind whose accruals setting lists the type evaluates its decision table at started_at with parameters from the interaction data and, for the first matching row with an unexhausted limit, writes an accrual entry for the amount of its result with a reference to the row, using up the row limit. The request body does not set the accrual; no matching row or an unsuitable setting means no accrual, and this is not an error. The exception is an accrual after which the balance would exceed the amount cap (10^14): VALIDATION_FAILED under ledger, even for a request without this block. A redemption is checked against the balance before the accrual of the same operation (points from a purchase are not spent in that same purchase). An attribute that serves as an accrual parameter cannot be changed by PATCH on an interaction with an accrual (VALIDATION_FAILED). A void reverses the accrual and releases the limit, even if the points were already spent (the balance goes negative).

Idempotency by external_id: an interaction of the organization with the same key and the same body (including the project; values are compared as sent — "1.5" and "1.50" differ) — response 200 with the existing one (including a voided one), meta.idempotent_replay: true and empty effect deltas; a different body — CONFLICT with details.external_id and details.existing_id. A repeat does not depend on what changed after creation (blocking, item deactivation). Response 201 — the created interaction, meta.effects — what rules and entries did in the same transaction, the customer's active labels and current balances after the operation (on a repeat — too, with empty deltas).

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

Request body

application/json

InteractionInput

  • typestringrequired

  • projectstringrequired

    Code of a project assigned to the API client
  • customer_idstring (uuid)required

  • started_atstring (date-time)required

    RFC 3339 with a time zone, by the device clock
  • ended_atstring (date-time) | null

  • agent_refstring | null

    Constraints
    maxLength: 255
  • outlet_refstring | null

    Constraints
    maxLength: 255
  • latnumber | string | null

    Latitude −90…90, paired with lng
  • lngnumber | string | null

    Longitude −180…180, paired with lat
  • external_idstring | null

    The API client's natural key, unique within the organization
    Constraints
    maxLength: 128
  • campaignstring | null

    Campaign code (catalog with the campaign role)
  • verification_idstring (uuid) | null

    A confirmed verification of the customer's phone; sets phone_verified
  • attachmentsarray<string (uuid)> | null

    IDs of attachments (POST /attachments) to link to the interaction; case-insensitive
    Constraints
    maxItems: 20
  • decision_line_idstring (uuid) | null

    A row of the type's decision table — the ID from the “evaluate” response
  • ledgerarray<RedemptionInput> | null

    Redemptions from the customer's accounts; kinds come from the type's ledger setting
    Constraints
    maxItems: 20
  • consentsarray<ConsentInput> | null

    Consents “given” submitted with the interaction; occurred_at defaults to started_at
    Constraints
    maxItems: 100
  • attributesobject | null

    Fields of the interaction:<type> schema under their codes; only the CRM writes phone_verified
  • itemsarray<InteractionItemInput> | null

    Constraints
    maxItems: 1000

Responses

  • 200

    Repeat by external_id with the same body — the existing one, meta.idempotent_replay

    application/json

    InteractionResponse

    • dataInteractionrequired

    • metaobjectrequired

      Service data of the response; for lists it contains cursor
      Fields
      • 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
      • effectsInteractionEffectsrequired

  • 201

    Interaction created

    application/json

    InteractionResponse

    • dataInteractionrequired

    • metaobjectrequired

      Service data of the response; for lists it contains cursor
      Fields
      • 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
      • effectsInteractionEffectsrequired

  • 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

  • 409

    CONFLICT — external_id is already taken by an interaction with a different body (details.external_id, details.existing_id) or by an interaction of another project (only details.external_id — the ID is not disclosed); IDEMPOTENCY_IN_PROGRESS — a request with this key is still running (details.key).

    Error format and codes

  • 422

    VALIDATION_FAILED — details.fields: type, project, customer_id, started_at, ended_at, agent_ref, outlet_ref, lat, lng, external_id, campaign, attributes.<code> (including attributes.phone_verified — written by the CRM), items, items.<i>, items.<i>.<field>, verification_id (not a UUID, not found, required by the type), Idempotency-Key, consents, consents.<i>.<field>, attachments, attachments.<i>, decision_line_id (not a UUID, not found, belongs to another table, the table is disabled or unavailable to the project, no version valid at started_at, the type has no table, required by the type), ledger, ledger.<i>.account_kind (the kind is not accepted by the type, is repeated, unknown, disabled), ledger.<i>.amount, ledger.<i>.reason; type — including an account kind from the block with broken settings; items.<i>.attributes is not accepted yet; INSUFFICIENT_BALANCE — a redemption takes the balance negative (details.account_kind, details.balance — before the operation, details.requested — the absolute sum of the kind's redemptions); BLOCKED — the type is forbidden for the customer (details.customer_id, details.labels) or the referenced row is (plus details.row_id, details.row_code); NOT_QUALIFIED and LIMIT_REACHED — the referenced row does not fit the customer (details.customer_id, row_id, row_code, columns or limits — the same shape as in the table evaluation); CATALOG_ITEM_INACTIVE — an inactive campaign or item (details.catalog, details.code, details.field); OTP_NOT_VERIFIED — the verification is not usable (details.verification_id, details.reason: customer_mismatch — issued to another customer, phone_mismatch — the addressee does not match the customer's phone or there is no phone, not_verified — not confirmed, already_used — already bound to an interaction, too_old — confirmed earlier than the type's verification.max_age_seconds); IDEMPOTENCY_MISMATCH — the key was already used for another 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

Schemas

Interaction

object

An interaction — one contract for POST /interactions and reads. attributes — every active field of the type schema visible to the API (not set — null); items — items by number, immutable; attachments — attachments in upload order with a signed link to the content (the link lives 10 minutes — a fresh one in every GET response; a retry with the same Idempotency-Key returns the stored response with the old one); void fields are null for an active interaction; for void they hold the reason, moment and author (POST /interactions/{id}/void); updated_at is moved by a void and by an attributes edit (PATCH /interactions/{id}), an edit without changes does not move it.
  • idstring (uuid)required

  • typestringrequired

  • projectstringrequired

    Project code
  • customer_idstring (uuid)required

  • statusstringrequired

    Values
    activevoid
  • resultstringrequired

    By the type's result rule
    Values
    effectiveineffective
  • started_atstring (date-time)required

    ISO 8601, UTC, to the second
  • ended_atstring (date-time) | nullrequired

  • agent_refstring | nullrequired

  • outlet_refstring | nullrequired

  • locationobject | nullrequired

    Fields
    • latstringrequired

      A decimal as a string, 6 decimal places
    • lngstringrequired

  • external_idstring | nullrequired

  • campaignstring | nullrequired

    Campaign code
  • decision_line_idstring (uuid) | nullrequired

    The decision table row the interaction referred to; null — no reference
  • attributesobjectrequired

  • itemsarray<InteractionItem>required

  • attachmentsarray<InteractionAttachment>required

  • void_reasonstring | nullrequired

  • voided_atstring (date-time) | nullrequired

  • voided_byActor | nullrequired

  • created_byActorrequired

  • created_atstring (date-time)required

  • updated_atstring (date-time)required

  • revisionsarray<InteractionRevision>

    Only with include=revisions; without it the key is absent
  • ledger_entriesarray<LedgerEntry>

    Only with include=ledger_entries (ability ledgers:read); without it the key is absent
  • assetsarray<InteractionAssetEvent>

    Only with include=assets (ability assets:read); without it the key is absent

InteractionItem

object

  • idstring (uuid)required

  • positionintegerrequired

    Item number in the create request, starting from 1
    Constraints
    minimum: 1
  • rolestringrequired

  • catalogstringrequired

    Code of the item's catalog
  • itemstringrequired

    Item code
  • quantityintegerrequired

    Constraints
    minimum: 1
  • pricestring | nullrequired

    A decimal as a string with 2 decimal places
  • discountstring | nullrequired

    A decimal as a string with 2 decimal places
  • discount_kindstring | nullrequired

  • serialstring | nullrequired

    Serial number of the item's asset as recorded; null — none

InteractionAttachment

object

An interaction attachment with a signed link to its content
  • idstring (uuid)required

  • kindstringrequired

    Values
    signaturephotodocument
  • mimestringrequired

    Example
    image/png
  • sizeintegerrequired

    Bytes
  • created_atstring (date-time)required

    Upload moment
  • urlstring (uri)required

    As in GET /attachments/{id}/url — opens without a token until url_expires_at
  • url_expires_atstring (date-time)required

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

InteractionRevision

object

An interaction revision — an attributes edit (updated) or a void (voided). diff — the changed paths {<path>: {old, new}}: attributes.<code> — only fields visible to the API, result — the result recalculated by an edit of a field used in the type's rule, status and void_reason — a void; a revision without visible paths is {} (an edit of a hidden field).
  • numberintegerrequired

    Constraints
    minimum: 1
  • operationstringrequired

    Values
    updatedvoided
  • diffobjectrequired

    Key values
    • oldany valuerequired

    • newany valuerequired

  • created_byActorrequired

  • created_atstring (date-time)required

LedgerEntry

object

A ledger entry on a customer account. Entries are only appended, never changed or deleted. The amount is signed: plus is an accrual, minus is a redemption. reversal_id is the offsetting entry if this one was reversed (one reversal per entry).
  • idstring (uuid)required

  • account_kindstringrequired

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

  • amountstringrequired

    Signed amount — a decimal as a string with exactly the kind's number of decimal places (scale); for a kind with corrupted settings — the canonical form without trailing zeros
    Example
    100-40.00
  • reasonstring | nullrequired

    Reason; accrual has none — the decision row gives the reason
  • interaction_idstring (uuid) | nullrequired

    The interaction for redemption, accrual, their offsetting entries, and the transfer pair that moves the offsetting entries of a merged customer's interaction void to the primary customer
  • decision_row_idstring (uuid) | nullrequired

    Decision table row for accrual
  • reverses_entry_idstring (uuid) | nullrequired

    The entry being reversed, for reversal
  • reversal_idstring (uuid) | nullrequired

    The offsetting entry if this one was reversed
  • external_idstring | nullrequired

    The API client's natural key, for manual
  • actorActorrequired

  • created_atstring (date-time)required

    ISO 8601, UTC, to the second

LedgerEntryKind

string

Entry kind (closed list): manual — manual (API, customer card), redemption — a spend in an interaction request, accrual — an award by the account kind's decision table, reversal — the offsetting reversal entry, transfer — a balance transfer on a customer merge: a pair with an offsetting entry, minus on the absorbed customer, plus on the primary, without a cause, not reversible; in the entry list and timeline of the primary the pairs within the group “primary and those merged into it” are not returned, entries of merged customers are
Values
manualredemptionaccrualreversaltransfer

InteractionAssetEvent

object

Interaction asset event — a history event (AssetEvent) and the asset it belongs to
  • idstring (uuid)required

  • numberintegerrequired

    Event number for the asset — history order
    Constraints
    minimum: 1
  • kindstringrequired

    Values
    registeredtransitionedowner_changedreverted
  • status_fromstring | nullrequired

    Status before the event; null for the first registration
  • status_tostringrequired

  • owner_from_idstring (uuid) | nullrequired

  • owner_to_idstring (uuid) | nullrequired

  • interaction_idstring (uuid) | nullrequired

    Interaction that changed the asset
  • reverts_event_idstring (uuid) | nullrequired

  • reasonstring | nullrequired

  • created_byActorrequired

  • created_atstring (date-time)required

    ISO 8601, UTC
  • asset_idstring (uuid)required

  • typestringrequired

    Asset type code
  • serialstringrequired

    Serial number as recorded

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

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

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

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

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

RedemptionInput

object

A redemption from a customer account in an interaction request
  • account_kindstringrequired

    Account kind code from the interaction type's ledger setting
    Constraints
    maxLength: 255
  • amountstringrequired

    Redemption amount — positive, decimal as a string, no more decimal places than the kind's scale
    Constraints
    maxLength: 64
    Example
    3000
  • reasonstringrequired

    Redemption reason
    Constraints
    maxLength: 1000

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

InteractionItemInput

object

  • rolestringrequired

    Item role code from the type settings (purchase, gift, …)
  • itemstringrequired

    Item code in the role's catalog
  • quantityintegerrequired

    Constraints
    minimum: 1
  • pricestring | null

    Price — a decimal as a string, at least 0, up to 2 decimal places
  • discountstring | null

    Discount — a decimal as a string, at least 0, up to 2 decimal places
  • discount_kindstring | null

    Discount kind code
  • serialstring | null

    Asset serial number — for a role with an assets rule of the interaction type; leading and trailing spaces are trimmed, normalization follows the asset type's rule, after it up to 128 characters. null is the same as absent
    Constraints
    maxLength: 1000