API · Catalogs and rules
Agents
The registry of agents (the organization's employees and partners) and checking their codes.
Agent registry
GET/agents
A page of the organization's agent registry (the registry master is the organization's accounting
system): by external ID in byte order (B < a < Я), disabled agents included; cursor pagination:
pass meta.cursor.next as the cursor parameter with the same filters until it becomes null.
Ability agents:read. Projects play no part. Filters combine with AND: role — role code (an unknown
role gives an empty list, a malformed code is an error); group — exact equality after the same trimming
and NFC as on write (a group that is empty after trimming means no filter); active —
true|false|1|0, case-insensitive. An empty parameter value means no filter. Errors —
VALIDATION_FAILED with details.fields.<parameter>: first the request shape (a parameter outside the
list — “Unknown parameter”), then the values, all at once (role, group, activity, limit range); the
cursor is checked only when the other parameters are valid.
Parameters
rolestringquery- Example
promoter
groupstringqueryactivestringquery- Example
false
limitintegerqueryList 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
Page of agents
application/jsonobject
dataarray<Agent>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)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
Agent by external ID
GET/agents/{external_id}
A registry agent by external ID, including a disabled one (is_active: false). Ability agents:read.
Parameters
external_idstringpathrequiredExternal ID of the agent (1–64 characters without whitespace, control characters and/, edges are trimmed, case-sensitive). If the organization has no such agent or the ID fails the format —NOT_FOUNDwithdetails.external_idas sent (first 64 characters).- Example
A-17
Responses
200
Agent
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 — the organization has no agent with this external ID, or the ID does not match the format (
details.external_id— as in the path, the first 64 characters)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
Create or update an agent
PUT/agents/{external_id}
Partial upsert of an agent by external ID (the registry master is the organization's accounting system).
Ability agents:write. No Idempotency-Key: repeating the same body changes nothing
(meta.outcome: unchanged). A body with full_name and role creates a new agent (is_active defaults to true); for
an existing agent only the keys sent are changed, null clears group and a schema field
({"attributes": {"<code>": null}}). Disabling — {"is_active": false}; there is no deletion. An empty
string also becomes null (for full_name and role — “Required.”). Fields of the agent schema
hidden from the API are “Unknown field” in the body and are kept on update; a required field hidden from
the API is not required when creating through the API.
A registry change recalculates labels of rules with an agent_registry leaf for the affected customers in
the same transaction, by the old and new values of the agent's slots; the response has no effects
(meta.effects is absent), the labels are visible on customer cards. A recalculation failure rolls back
the upsert — INTERNAL (500), the agent is not written.
Errors — VALIDATION_FAILED with details.fields, in stages: body shape (not a JSON object — body) →
the external ID from the path (external_id: 1–64 characters without whitespace and control characters,
not dots only, not starting with a combining mark; / (%2F) and an empty ID are cut off by the router —
NOT_FOUND) → everything else at once: an unknown key, full_name, role (an unknown or disabled role;
an unchanged role is not re-checked), group, is_active, attributes (not an object; [] equals
{}), attributes.<code> (field value, slot normalization), codes (not a list, more than 100),
codes.<i> (not an object), codes.<i>.<key> (code, duplicate, taken by another agent, validity
period, activity), codes.<i>.parameters.<key>.
Personal codes (codes) are written in the same transaction; if only the codes changed —
meta.outcome: updated, while the agent's updated_at stays the same (a code has its own). Rules do not
read codes, so codes do not trigger label recalculation.
Parameters
external_idstringpathrequiredExternal ID of the agent: 1–64 characters without whitespace, control characters and/, edges are trimmed, NFC, case-sensitive. A value that fails the format —VALIDATION_FAILEDunderexternal_id(for reading —NOT_FOUND);/(%2F) and an empty ID are a different path, the router'sNOT_FOUND.- Example
A-17
Request body
application/json
AgentUpsert
full_namestringFull name; edges are trimmed (whitespace, invisible, control characters), NFC; required for a new agent- Constraints
maxLength: 255
rolestringCode of an active agent role (typeagent_role); required for a new agent- Example
promoter
groupstring | nullGroup;nullor empty after trimming — no group- Constraints
maxLength: 255
is_activebooleanfalsedisables the agent;trueby default for a new agentattributesobjectFields of theagentschema visible to the API, under their codes; a field on thephoneslot is normalized to E.164 by the field's region, on thenational_idslot — by the identity type;nullclears an optional field.codesarray<AgentCodeUpsert>Personal codes ({}is the same as[]) — merged by code: a code the agent does not have is created, an existing one gets the sent item keys changed; the agent's codes missing from the list do not change; nocodeskey — codes are left alone. There is no deletion — disable withis_active: false. The same code twice in the list (including in a different case) — “Duplicate code”; a code of another agent of the organization (even a disabled one) — “already taken”: a code is unique within the organization and does not move to another agent.- Constraints
maxItems: 100
No other keys
Responses
200
Agent updated or unchanged
application/jsonAgentUpsertResponse
dataAgentrequiredmetaobjectrequiredService 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
effectsInteractionEffectsoutcomestringrequiredUpsert outcome;created— with status 201- Values
createdupdatedunchanged
201
Agent created
application/jsonAgentUpsertResponse
dataAgentrequiredmetaobjectrequiredService 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
effectsInteractionEffectsoutcomestringrequiredUpsert outcome;created— with status 201- Values
createdupdatedunchanged
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
500
INTERNAL — the agent rule recalculation failed, or another error; the upsert is rolled back
Check an agent's personal code
POST/agent-codes/validate
Whether an agent's personal code is valid at moment. Ability agent-codes:validate, separate from
agents:read: the check does not open the registry with phone numbers and national identifiers.
Projects play no part; codes are shared across the organization. The check writes nothing: the
response is 200 even on refusal — valid: false with the reason in reason. No Idempotency-Key.
The code is compared case-insensitively (ref-31ab is the same code as REF-31AB), edges are trimmed; a
code that fails the format (not Latin letters, digits, -, _; longer than 64) is unknown, not an
error. Reasons — the first that applies, in order: unknown (no such code in the organization) →
inactive (the code is disabled) → agent_inactive (the agent is disabled) → not_started (moment is
before valid_from) → expired (moment is not before valid_to). The CRM does not interpret code
parameters and returns them as is; parameters and the agent are returned only for a valid code.
Request body
application/json
object
VALIDATION_FAILED under its name; a list body — under bodycodestring | nullrequiredThe code as a string; empty, whitespace only ornull—unknown. A missing key or a non-string (including a number) —VALIDATION_FAILEDundercode.- Constraints
maxLength: 255- Example
ref-31ab
momentstring (date-time)Moment of the check (RFC 3339 with a time zone, to the second); no key — “now”; an empty string andnull—VALIDATION_FAILED. No further into the future than the client clock tolerance — otherwiseVALIDATION_FAILEDundermoment.
No other keys
Responses
200
Check result (also on refusal)
application/jsonobject
dataAgentCodeCheckrequiredmetaMetarequired
401
UNAUTHENTICATED — the Bearer token is missing or invalid
403
FORBIDDEN — the token lacks an ability (
details.ability) or a project (details.project)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
Schemas
Agent
object
id is not exposed.external_idstringrequiredExternal ID — no whitespace, control characters or/, case-sensitive- Constraints
minLength: 1maxLength: 64- Example
A-17
full_namestringrequired- Constraints
maxLength: 255
rolestringrequiredAgent role code — typeagent_role(GET /v1/schema/agent,types)- Example
promoter
groupstring | nullrequiredGroup for filtering;null— no group- Constraints
maxLength: 255
is_activebooleanrequiredA disabled agent does not take part in matching with customers (theagent_registryrule leaf)attributesobjectrequiredEach active field of theagentschema visible to the API, under its code, in schema order; a field on a slot (phone,national_id) — the normalized value (phone — E.164); not set —null.codesarray<AgentCode>requiredThe agent's personal codes ordered by code bytewise, including disabled ones;[]— nonecreated_atstring (date-time)requiredupdated_atstring (date-time)required
AgentCode
object
POST /v1/agent-codes/validate
returns them as is. Validity is [valid_from, valid_to) in UTC to the second: at valid_to the code is no longer valid.codestringrequiredCode in canonical upper case- Constraints
pattern: ^[A-Z0-9_-]{1,64}$- Example
REF-31AB
valid_fromstring (date-time) | nullrequiredStart of validity;null— no startvalid_tostring (date-time) | nullrequiredEnd of validity (exclusive);null— no expiryparametersAgentCodeParametersrequiredis_activebooleanrequiredA disabled code is rejected byvalidatewith reasoninactivecreated_atstring (date-time)requiredupdated_atstring (date-time)required
AgentCodeParameters
object
_, starting with a letter (any other
form, such as Discount, is an error, not converted); a value is a string up to 255 characters without control
characters, a finite number or true/false; null, an object and a list are errors. An integer with a .0
fraction is returned as an integer.- Constraints
maxProperties: 32- Example
{"discount":2000,"kind":"fixed"}
Key values: string | number | boolean
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
Actor
object
kindstringrequired- Values
api_clientusersystem
idstring | nullrequiredID of the API client (UUID) or user; null forsystem
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
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
AgentCodeUpsert
object
codes in an agent upsert — only the keys sent: a new code gets valid_from and valid_to set to
null, parameters to {}, is_active to true. An empty string becomes null (for valid_* it clears
the validity bound, for code — “Required.”); parameters are taken as sent, without trimming or replacing "". An
item [] is parsed as an empty object. Errors are under codes.<i>, codes.<i>.<key>,
codes.<i>.parameters.<key>; a key outside the list — “Unknown key”.codestringrequiredLatin letters, digits,-and_, 1–64 after trimming the edges (whitespace, invisible characters); case-insensitive — stored in upper case- Example
ref-31ab
valid_fromstring (date-time) | nullRFC 3339 with a time zone; fractions of a second are dropped;null— no startvalid_tostring (date-time) | nullRFC 3339 with a time zone, later thanvalid_from; may be in the past;null— no expiryparametersAgentCodeParametersis_activeboolean
No other keys
AgentCodeCheck
object
codestringrequiredCode in canonical upper case; for a code that fails the format — as sent, with edges trimmed (empty —"")momentstring (date-time)requiredCheck moment in UTC to the secondvalidbooleanrequiredreasonAgentCodeReason | nullrequirednull— the code is validvalid_fromstring (date-time) | nullrequiredStart of validity of a known code;nullforunknownand with no startvalid_tostring (date-time) | nullrequiredEnd of validity of a known code (exclusive);nullforunknownand with no expiryparametersAgentCodeParameters | nullrequiredParameters — only whenvalid: trueagentAgentBrief | nullrequiredAgent — only whenvalid: true
AgentCodeReason
string
unknown — no such code (or it fails the format),
inactive — the code is disabled, agent_inactive — the agent is disabled, not_started — validity has not
started yet, expired — validity has ended- Values
unknowninactiveagent_inactivenot_startedexpired
AgentBrief
object
external_idstringrequiredfull_namestringrequiredrolestringrequiredgroupstring | nullrequired