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 themeta.effectsblock. Idempotency works both byIdempotency-Keyand by the natural keyexternal_id.GET /interactions/{id}andGET /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 inGET /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)pathrequiredincludestringqueryComma-separated extensions —revisions,ledger_entries(abilityledgers:read),assets(abilityassets:read). An unknown block —details.fields.include.- Example
revisionsrevisions,ledger_entries
Responses
200
Interaction
application/jsonobject
dataInteractionrequiredmetaMetarequired
401
UNAUTHENTICATED — the Bearer token is missing or invalid
403
FORBIDDEN — the token lacks an ability (
details.ability) or a project (details.project)404
NOT_FOUND — resource or route not found
422
VALIDATION_FAILED —
details.fieldswith errors by field429
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 headersX-RateLimit-LimitandRetry-After.Headers
Retry-AfterintegerSeconds until the window resetsX-RateLimit-LimitintegerX-RateLimit-Remaininginteger
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
attributesobjectrequiredOnly the type schema fields being changed, under their codes;nullclears 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/jsonInteractionResponse
dataInteractionrequiredmetaobjectrequiredService data of the response; for lists it containscursorFields
cursorobjectFields
nextstring | nullrequiredCursor 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'scustomer_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 sameIdempotency-Keyreturns the response stored by the first execution as is.idempotent_replaybooleanOnly on a retry: the response is taken from the idempotency store,datais byte-for-byte the same as in the first response; or a retry by the interaction's natural keyexternal_id—datais 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
versionintegerOnly 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 ischanges?since=<version>.- Constraints
minimum: 0
recordedintegerOnly 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
403
FORBIDDEN — the token lacks an ability (
details.ability) or a project (details.project)404
NOT_FOUND — resource or route not found
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 retry422
VALIDATION_FAILED —
details.fieldswith errors by field429
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 headersX-RateLimit-LimitandRetry-After.Headers
Retry-AfterintegerSeconds until the window resetsX-RateLimit-LimitintegerX-RateLimit-Remaininginteger
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)pathrequiredIdempotency-KeystringheaderrequiredIdempotency key: unique within the client, lives for 24 hours. A repeat with the same key and request returns the saved response withmeta.idempotent_replay: true; a different request with the same key getsIDEMPOTENCY_MISMATCH. A UUID is recommended.- Constraints
minLength: 1maxLength: 255
Request body
application/json
VoidInput
reasonstringrequiredHuman-readable reason, may be multiline- Constraints
minLength: 1maxLength: 1000
Responses
200
Interaction voided (or already was —
meta.idempotent_replay)application/jsonInteractionResponse
dataInteractionrequiredmetaobjectrequiredService data of the response; for lists it containscursorFields
cursorobjectFields
nextstring | nullrequiredCursor 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'scustomer_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 sameIdempotency-Keyreturns the response stored by the first execution as is.idempotent_replaybooleanOnly on a retry: the response is taken from the idempotency store,datais byte-for-byte the same as in the first response; or a retry by the interaction's natural keyexternal_id—datais 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
versionintegerOnly 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 ischanges?since=<version>.- Constraints
minimum: 0
recordedintegerOnly 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
403
FORBIDDEN — the token lacks an ability (
details.ability) or a project (details.project)404
NOT_FOUND — resource or route not found
409
IDEMPOTENCY_IN_PROGRESS — a request with this
Idempotency-Key(details.key) is still running; retry later to get the stored response.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).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 headersX-RateLimit-LimitandRetry-After.Headers
Retry-AfterintegerSeconds until the window resetsX-RateLimit-LimitintegerX-RateLimit-Remaininginteger
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)pathrequiredtypestringquerycampaignstringquerystatusstringquery- Values
activevoid
fromstring (date-time)querytostring (date-time)querylimitintegerqueryList page size, 1…200; 50 when omitted- Default
50- Constraints
minimum: 1maximum: 200
cursorstringqueryOpaque cursor frommeta.cursor.nextof the previous page; valid only with the same filters — otherwiseVALIDATION_FAILEDundercursor. Without the parameter — the first page.- Constraints
maxLength: 512
Responses
200
A page of interactions
application/jsonobject
dataarray<Interaction>requiredmetaobjectrequiredService data of the response; for lists it containscursorFields
cursorobjectrequiredFields
nextstring | nullrequiredCursor 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'scustomer_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 sameIdempotency-Keyreturns the response stored by the first execution as is.idempotent_replaybooleanOnly on a retry: the response is taken from the idempotency store,datais byte-for-byte the same as in the first response; or a retry by the interaction's natural keyexternal_id—datais 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
versionintegerOnly 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 ischanges?since=<version>.- Constraints
minimum: 0
recordedintegerOnly 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
403
FORBIDDEN — the token lacks an ability (
details.ability) or a project (details.project)404
NOT_FOUND — resource or route not found
422
VALIDATION_FAILED —
details.fieldswith errors by field429
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 headersX-RateLimit-LimitandRetry-After.Headers
Retry-AfterintegerSeconds until the window resetsX-RateLimit-LimitintegerX-RateLimit-Remaininginteger
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-KeystringheaderrequiredIdempotency key: unique within the client, lives for 24 hours. A repeat with the same key and request returns the saved response withmeta.idempotent_replay: true; a different request with the same key getsIDEMPOTENCY_MISMATCH. A UUID is recommended.- Constraints
minLength: 1maxLength: 255
Request body
application/json
InteractionInput
typestringrequiredprojectstringrequiredCode of a project assigned to the API clientcustomer_idstring (uuid)requiredstarted_atstring (date-time)requiredRFC 3339 with a time zone, by the device clockended_atstring (date-time) | nullagent_refstring | null- Constraints
maxLength: 255
outlet_refstring | null- Constraints
maxLength: 255
latnumber | string | nullLatitude −90…90, paired withlnglngnumber | string | nullLongitude −180…180, paired withlatexternal_idstring | nullThe API client's natural key, unique within the organization- Constraints
maxLength: 128
campaignstring | nullCampaign code (catalog with thecampaignrole)verification_idstring (uuid) | nullA confirmed verification of the customer's phone; setsphone_verifiedattachmentsarray<string (uuid)> | nullIDs of attachments (POST /attachments) to link to the interaction; case-insensitive- Constraints
maxItems: 20
decision_line_idstring (uuid) | nullA row of the type's decision table — the ID from the “evaluate” responseledgerarray<RedemptionInput> | nullRedemptions from the customer's accounts; kinds come from the type'sledgersetting- Constraints
maxItems: 20
consentsarray<ConsentInput> | nullConsents “given” submitted with the interaction;occurred_atdefaults tostarted_at- Constraints
maxItems: 100
attributesobject | nullFields of theinteraction:<type>schema under their codes; only the CRM writesphone_verifieditemsarray<InteractionItemInput> | null- Constraints
maxItems: 1000
Responses
200
Repeat by
external_idwith the same body — the existing one,meta.idempotent_replayapplication/jsonInteractionResponse
dataInteractionrequiredmetaobjectrequiredService data of the response; for lists it containscursorFields
cursorobjectFields
nextstring | nullrequiredCursor 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'scustomer_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 sameIdempotency-Keyreturns the response stored by the first execution as is.idempotent_replaybooleanOnly on a retry: the response is taken from the idempotency store,datais byte-for-byte the same as in the first response; or a retry by the interaction's natural keyexternal_id—datais 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
versionintegerOnly 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 ischanges?since=<version>.- Constraints
minimum: 0
recordedintegerOnly 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/jsonInteractionResponse
dataInteractionrequiredmetaobjectrequiredService data of the response; for lists it containscursorFields
cursorobjectFields
nextstring | nullrequiredCursor 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'scustomer_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 sameIdempotency-Keyreturns the response stored by the first execution as is.idempotent_replaybooleanOnly on a retry: the response is taken from the idempotency store,datais byte-for-byte the same as in the first response; or a retry by the interaction's natural keyexternal_id—datais 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
versionintegerOnly 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 ischanges?since=<version>.- Constraints
minimum: 0
recordedintegerOnly 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
403
FORBIDDEN — the token lacks an ability (
details.ability) or a project (details.project)409
CONFLICT —
external_idis already taken by an interaction with a different body (details.external_id,details.existing_id) or by an interaction of another project (onlydetails.external_id— the ID is not disclosed); IDEMPOTENCY_IN_PROGRESS — a request with this key is still running (details.key).422
VALIDATION_FAILED —
details.fields:type,project,customer_id,started_at,ended_at,agent_ref,outlet_ref,lat,lng,external_id,campaign,attributes.<code>(includingattributes.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 atstarted_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>.attributesis 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 (plusdetails.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,columnsorlimits— 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'sverification.max_age_seconds); IDEMPOTENCY_MISMATCH — the key was already used for another request (details.key).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 headersX-RateLimit-LimitandRetry-After.Headers
Retry-AfterintegerSeconds until the window resetsX-RateLimit-LimitintegerX-RateLimit-Remaininginteger
Schemas
Interaction
object
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)requiredtypestringrequiredprojectstringrequiredProject codecustomer_idstring (uuid)requiredstatusstringrequired- Values
activevoid
resultstringrequiredBy the type's result rule- Values
effectiveineffective
started_atstring (date-time)requiredISO 8601, UTC, to the secondended_atstring (date-time) | nullrequiredagent_refstring | nullrequiredoutlet_refstring | nullrequiredlocationobject | nullrequiredFields
latstringrequiredA decimal as a string, 6 decimal placeslngstringrequired
external_idstring | nullrequiredcampaignstring | nullrequiredCampaign codedecision_line_idstring (uuid) | nullrequiredThe decision table row the interaction referred to; null — no referenceattributesobjectrequireditemsarray<InteractionItem>requiredattachmentsarray<InteractionAttachment>requiredvoid_reasonstring | nullrequiredvoided_atstring (date-time) | nullrequiredvoided_byActor | nullrequiredcreated_byActorrequiredcreated_atstring (date-time)requiredupdated_atstring (date-time)requiredrevisionsarray<InteractionRevision>Only withinclude=revisions; without it the key is absentledger_entriesarray<LedgerEntry>Only withinclude=ledger_entries(abilityledgers:read); without it the key is absentassetsarray<InteractionAssetEvent>Only withinclude=assets(abilityassets:read); without it the key is absent
InteractionItem
object
idstring (uuid)requiredpositionintegerrequiredItem number in the create request, starting from 1- Constraints
minimum: 1
rolestringrequiredcatalogstringrequiredCode of the item's catalogitemstringrequiredItem codequantityintegerrequired- Constraints
minimum: 1
pricestring | nullrequiredA decimal as a string with 2 decimal placesdiscountstring | nullrequiredA decimal as a string with 2 decimal placesdiscount_kindstring | nullrequiredserialstring | nullrequiredSerial number of the item's asset as recorded;null— none
InteractionAttachment
object
idstring (uuid)requiredkindstringrequired- Values
signaturephotodocument
mimestringrequired- Example
image/png
sizeintegerrequiredBytescreated_atstring (date-time)requiredUpload momenturlstring (uri)requiredAs inGET /attachments/{id}/url— opens without a token untilurl_expires_aturl_expires_atstring (date-time)required
Actor
object
kindstringrequired- Values
api_clientusersystem
idstring | nullrequiredID of the API client (UUID) or user; null forsystem
InteractionRevision
object
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
diffobjectrequiredKey values
oldany valuerequirednewany valuerequired
created_byActorrequiredcreated_atstring (date-time)required
LedgerEntry
object
reversal_id is the offsetting entry if this one was
reversed (one reversal per entry).idstring (uuid)requiredaccount_kindstringrequiredAccount kind code (entity_types:account_kind)- Example
points
kindLedgerEntryKindrequiredamountstringrequiredSigned 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 | nullrequiredReason;accrualhas none — the decision row gives the reasoninteraction_idstring (uuid) | nullrequiredThe interaction forredemption,accrual, their offsetting entries, and thetransferpair that moves the offsetting entries of a merged customer's interaction void to the primary customerdecision_row_idstring (uuid) | nullrequiredDecision table row foraccrualreverses_entry_idstring (uuid) | nullrequiredThe entry being reversed, forreversalreversal_idstring (uuid) | nullrequiredThe offsetting entry if this one was reversedexternal_idstring | nullrequiredThe API client's natural key, formanualactorActorrequiredcreated_atstring (date-time)requiredISO 8601, UTC, to the second
LedgerEntryKind
string
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
AssetEvent) and the asset it belongs toidstring (uuid)requirednumberintegerrequiredEvent number for the asset — history order- Constraints
minimum: 1
kindstringrequired- Values
registeredtransitionedowner_changedreverted
status_fromstring | nullrequiredStatus before the event; null for the first registrationstatus_tostringrequiredowner_from_idstring (uuid) | nullrequiredowner_to_idstring (uuid) | nullrequiredinteraction_idstring (uuid) | nullrequiredInteraction that changed the assetreverts_event_idstring (uuid) | nullrequiredreasonstring | nullrequiredcreated_byActorrequiredcreated_atstring (date-time)requiredISO 8601, UTCasset_idstring (uuid)requiredtypestringrequiredAsset type codeserialstringrequiredSerial number as recorded
Meta
object
cursorcursorobjectFields
nextstring | nullrequiredCursor 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'scustomer_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 sameIdempotency-Keyreturns the response stored by the first execution as is.idempotent_replaybooleanOnly on a retry: the response is taken from the idempotency store,datais byte-for-byte the same as in the first response; or a retry by the interaction's natural keyexternal_id—datais 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
versionintegerOnly 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 ischanges?since=<version>.- Constraints
minimum: 0
recordedintegerOnly 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
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>requiredLabels the customer gained in the operationlabels_removedarray<string>requiredCodes of labels the customer lost in the operationbalancesarray<BalanceChange>requiredBalance changes of the operation by account kindassetsarray<AssetChange>requiredAsset changes of the operationrules_firedarray<RuleFired>requiredChanges to label rows made by rules, in order of applicationlabelsarray<CustomerLabel>requiredThe customer's active labels after the operationcurrent_balancesarray<CustomerBalance>requiredThe customer's current balances after the operation — likebalancesof the customer card: one element for each active account kind, zero without entries
CustomerLabel
object
sources — each active row.codestringrequiredLabel type code (lower case)kindstringrequiredKind from the type settings — blocking operations, a group, a flag- Values
blocksegmentflag
reasonstring | nullrequiredexpires_atstring (date-time) | nullrequiredISO 8601, UTC; null — no expirysourcestringrequiredSet manually or by a rule- Values
manualrule
created_byActorrequiredcreated_atstring (date-time)requiredMoment the label was set, ISO 8601, UTCsourcesarray<CustomerLabelSource>requiredActive label rows by source — the manual one first
CustomerLabelSource
object
DELETE …/labels/{code}).sourcestringrequired- Values
manualrule
rule_idstring (uuid) | nullrequiredRule that set the row; null for the manual onereasonstring | nullrequiredexpires_atstring (date-time) | nullrequiredISO 8601, UTC; null — no expirycreated_byActorrequiredcreated_atstring (date-time)requiredMoment the row was set, ISO 8601, UTC
BalanceChange
object
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_kindstringrequiredchangestringrequired- Example
-3000
balancestringrequired- Example
2000
unitobject | nullrequiredAsunitinCustomerBalance— one unit form per language, not inflected by numberKey values: string
AssetChange
object
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 changeidstring (uuid)requiredtypestringrequiredAsset type codeserialstringrequiredSerial number as recordedeventstringrequired- Values
registeredtransitionedreverted
status_fromstring | nullrequiredstatus_tostringrequiredcustomer_idstring (uuid) | nullrequired
RuleFired
object
set) or removed (removed).rulestringrequiredRule coderule_idstring (uuid)requiredRule ID — same assources[].rule_idof a customer labellabelstringrequiredLabel codeactionstringrequired- Values
setremoved
CustomerBalance
object
GET /v1/schema).account_kindstringrequiredAccount kind code (entity_types:account_kind)- Example
points
balancestringrequiredBalance — 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 | nullrequiredUnit 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
account_kindstringrequiredAccount kind code from the interaction type'sledgersetting- Constraints
maxLength: 255
amountstringrequiredRedemption amount — positive,decimalas a string, no more decimal places than the kind'sscale- Constraints
maxLength: 64- Example
3000
reasonstringrequiredRedemption reason- Constraints
maxLength: 1000
ConsentInput
object
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.typestringrequiredConsent type code (entity_types:consent_type), case-insensitive- Constraints
maxLength: 64- Example
pdn
versioninteger | nullText version number fromGET /consents/texts. Without it: “given” — the current version on the local date ofoccurred_atin 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
channelstringrequiredWhere 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 | nullExternal 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) | nullSignature 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) | nullMoment of the fact by the client's clock — strictly RFC 3339 with a time zone (Zor±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
rolestringrequiredItem role code from the type settings (purchase,gift, …)itemstringrequiredItem code in the role's catalogquantityintegerrequired- Constraints
minimum: 1
pricestring | nullPrice — a decimal as a string, at least 0, up to 2 decimal placesdiscountstring | nullDiscount — a decimal as a string, at least 0, up to 2 decimal placesdiscount_kindstring | nullDiscount kind codeserialstring | nullAsset serial number — for a role with anassetsrule of the interaction type; leading and trailing spaces are trimmed, normalization follows the asset type's rule, after it up to 128 characters.nullis the same as absent- Constraints
maxLength: 1000