API · Interactions and accounting
Accounts
Customer balance by account kind, manual entries and their reversals.
Customer entries
GET/customers/{id}/ledger-entries
A page of the customer's entries across all their accounts, newest first (created_at descending,
ties — by id), cursor pagination: meta.cursor.next is passed as the cursor parameter with the
same account_kind until it becomes null. Ability ledgers:read. Manual entries are visible
to everyone with the ability; an entry bound to an interaction (redemption, accrual and their
reversing entries) — only if the interaction is in projects assigned to the API client (including
deactivated ones). Entries of disabled account kinds stay in the list. The customer is not in the
organization — NOT_FOUND with details.id. account_kind — a kind code (an unknown one gives an
empty list, a malformed one gives an error). Errors — VALIDATION_FAILED with
details.fields.<parameter>, before the customer check: first the request shape (a parameter outside
the list — “Unknown parameter”), then the values — all at once (kind, limit range, cursor).
Parameters
idstring (uuid)pathrequiredaccount_kindstringquerylimitintegerqueryList 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 entries
application/jsonobject
dataarray<LedgerEntry>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
Manual entry
POST/customers/{id}/ledger-entries
A manual entry on the customer's account — kind manual: an accrual (amount greater than zero) or a
redemption (less than zero) by the API client outside an interaction. Ability ledgers:write; the
Idempotency-Key header is required; a manual entry has no project. The account is opened by its
first entry.
amount — a decimal as a string: digits, an optional leading minus, a fractional part after a
dot ("100", "-40.50"); +100, .5, an exponent, zero and a JSON number — VALIDATION_FAILED
under amount, as are more digits after the dot than the kind's scale (no rounding) and an absolute
value from 10^14. reason — the reason, 1–1000 characters. external_id — an optional natural key of
the accounting system (up to 128 characters, unique within the organization): a repeat with the same
key and the same body (account_kind, amount, reason as sent, after trimming whitespace at the
edges; the same customer) — 200 with the same entry and meta.idempotent_replay: true; with a
different body or for another customer — CONFLICT with details.external_id and
details.existing_id. The key is checked before the state: a retry of a redemption that already went
through does not get INSUFFICIENT_BALANCE.
Order of refusals: body shape (VALIDATION_FAILED) — natural key (CONFLICT; checked before the
customer from the path and the amount) — amount format (under amount) — customer (NOT_FOUND; not
active — VALIDATION_FAILED under customer) — kind (unknown or disabled — under account_kind) —
amount value (zero, digits beyond scale, the limit — under amount) — balance: a redemption that
takes the balance negative for a kind where negative balances are not allowed — INSUFFICIENT_BALANCE
with details.account_kind, details.balance (before the operation) and details.requested (the
absolute redemption amount), nothing is written. Response 201 — the entry and meta.balance — the
kind's balance after it (on a repeat — the current one).
The customer from the path is merged: the new entry is written to the primary,
meta.redirected_from — the ID from the path. A repeat by external_id of an entry written to the
absorbed customer before the merge — the same entry (its customer is the absorbed one: entries do not
move), meta.balance — the kind's balance of the primary (the absorbed customer's account is zero
after the transfer; after a chain of merges — of the last primary) and meta.redirected_from — the ID
from the path.
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
LedgerEntryInput
account_kindstringrequiredCode of an active account kind (entity_types:account_kind)- Example
points
amountstringrequiredSigned amount — a decimal as a string; plus is an accrual, minus is a redemption, zero is not allowed- Constraints
pattern: ^-?[0-9]+(\.[0-9]+)?$- Example
100-40.50
reasonstringrequired- Constraints
minLength: 1maxLength: 1000
external_idstring | nullNatural key of the accounting system, unique within the organization- Constraints
maxLength: 128
Responses
200
Repeat by
external_id— the recorded entry,meta.idempotent_replayapplication/jsonLedgerEntryResponse
dataLedgerEntryrequiredmetaobjectrequiredService 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
effectsInteractionEffectsbalanceCustomerBalancerequired
201
Entry recorded
application/jsonLedgerEntryResponse
dataLedgerEntryrequiredmetaobjectrequiredService 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
effectsInteractionEffectsbalanceCustomerBalancerequired
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 —
external_idis taken by an entry with a different body or for another customer (details.external_id,details.existing_id); IDEMPOTENCY_IN_PROGRESS — a request with this key is still running (details.key).422
VALIDATION_FAILED —
details.fields:account_kind,amount,reason,external_id,customer,Idempotency-Key; INSUFFICIENT_BALANCE —details.account_kind,details.balance,details.requested(decimals as strings with the kind'sscale); 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
Reverse an entry
POST/ledger-entries/{id}/reverse
A reversal is a reversal entry for the same amount with the opposite sign, one per original entry.
Ability ledgers:write; the Idempotency-Key header is required. It bypasses the negative-balance
ban and works for a disabled kind and for a customer in any status: a reversal corrects an error. The
entry is not in the organization or is bound to an interaction outside the projects assigned to the
API client — NOT_FOUND. A reversing entry and an interaction entry (redemption, accrual — only
voiding the interaction cancels them) cannot be reversed separately — CONFLICT with
details.entry_id and details.kind; an erroneous reversal is corrected with a new manual entry.
reason — 1–1000 characters.
Response 201 — the reversing entry and meta.balance — the kind's balance after it. A repeated
reversal — 200 with the same reversing entry (the first reason) and meta.idempotent_replay: true.
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
The entry was already reversed — the same reversing entry,
meta.idempotent_replayapplication/jsonLedgerEntryResponse
dataLedgerEntryrequiredmetaobjectrequiredService 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
effectsInteractionEffectsbalanceCustomerBalancerequired
201
Reversing entry recorded
application/jsonLedgerEntryResponse
dataLedgerEntryrequiredmetaobjectrequiredService 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
effectsInteractionEffectsbalanceCustomerBalancerequired
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 reversing entry or an interaction entry (
details.entry_id,details.kind); IDEMPOTENCY_IN_PROGRESS — a request with this key is still running (details.key).422
VALIDATION_FAILED —
details.fields:reason,Idempotency-Key; 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
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
Actor
object
kindstringrequired- Values
api_clientusersystem
idstring | nullrequiredID of the API client (UUID) or user; null forsystem
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