API · Customers

OTP codes

POST /verifications — sending a one-time code to a recipient: phone — the number as is (the region and allowed countries come from the phone field settings in the customer schema) or customer_id — the phone from the card; the channel (sms, whatsapp) and the purpose (purpose — a code from the organization's message templates). Delivery goes through a queue, so a 201 response is always status: pending: a provider failure shows as failed in GET /verifications/{id} (with failure_reason) or as OTP_PROVIDER_ERROR when checking the code.

Limits are per recipient per channel, across all purposes: the pause before a resend — OTP_RESEND_TOO_SOON, sends per rolling twenty-four hours — OTP_DAILY_LIMIT, both with details.retry_after (seconds) and the moment. Organization setup errors (codes turned off, a channel without a driver, a purpose without a template) — VALIDATION_FAILED under channel or purpose: no record is created and the limit is not spent. Ability otp:send, Idempotency-Key is required; the project is not involved. The code itself never appears in API responses.

POST /verifications/{id}/check with otp_code — 200 and status: verified (the organization's customer with this phone is linked if there is exactly one and customer_id is empty). A wrong code — OTP_INVALID_CODE with details.attempts_left, expired — OTP_EXPIRED, attempts used up — OTP_ATTEMPTS_EXCEEDED (the correct code is no longer accepted), delivery failed — OTP_PROVIDER_ERROR (502, details.reason); after these three a new send is needed. Ability otp:verify, without Idempotency-Key: repeating the correct code on a verified check returns the same record.

Send a one-time code

POST/verifications

Issues a verification: generates a code, stores its hash and queues delivery. Ability otp:send; the Idempotency-Key header is required (a repeat without a key sends a second SMS).

Body: channel — sms or whatsapp; purpose — the reason (snake_case), known to the organization from its message templates (verification, check_code, … — the registry of purposes is the templates); exactly one of phone (raw number: without + it is parsed in the default_region of the field on the customer schema's phone slot and must fall within its regions; without such a field only E.164 is accepted) and customer_id (the phone from the card's phone slot; a customer of another organization or without a phone — VALIDATION_FAILED under customer_id); locale — the requested message language (ISO 639-1, case-insensitive); without it, or without a template in it — the organization's customer language, then the first available one. interaction_id must not be sent — it is set by the interaction.

Order of checks — configuration before limits: OTP disabled or the channel has no driver → VALIDATION_FAILED under channel; a purpose without a template on the channel → under purpose; then limits on the “channel + addressee” pair across all purposes and statuses (including failed): OTP_DAILY_LIMIT — sends within a rolling 24 hours are not fewer than daily_limit (details.limit, details.retry_after — seconds until the send after which the limit allows one again leaves the window, details.resets_at); OTP_RESEND_TOO_SOON — less than resend_after_seconds has passed since the last send (details.retry_after, details.resend_at) — the same code with retry_after: 1 if another request to this addressee is still running. A refusal creates no row.

Response 201 — Verification: status is always pending (delivery has not happened yet), addressee — the normalized E.164 number, expires_at — until when the check accepts the code, resend_after — from when the next code can be sent to the same addressee. The code itself is not returned in the response.

Parameters

  • Idempotency-Keystringheaderrequired

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

Request body

application/json

VerificationInput

Body of POST /verifications; exactly one of phone and customer_id — do not send the other, or send null or "" (treated as absent).
  • channelstringrequired

    Values
    smswhatsapp
  • purposestringrequired

    Purpose — a snake_case code known to the organization from its message templates
    Constraints
    maxLength: 64
    Example
    verification
  • phonestring | null

    Raw number; without + — in the region of the phone field of the customer schema
    Constraints
    maxLength: 32
    Example
    +7 701 555 00 018 (701) 555-00-01
  • customer_idstring (uuid) | null

    A customer of the organization; the phone is taken from their phone slot
  • localestring | null

    Requested message language, ISO 639-1; kk-KZ gives VALIDATION_FAILED under locale
    Constraints
    pattern: ^[A-Za-z]{2}$
    Example
    kk

Responses

  • 201

    Code issued, delivery queued

    application/json

    object

  • 401

    UNAUTHENTICATED — the Bearer token is missing or invalid

    Error format and codes

  • 403

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

    Error format and codes

  • 409

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

    Error format and codes

  • 422

    VALIDATION_FAILED — details.fields: channel (unknown channel, OTP disabled, the channel has no driver), purpose (not snake_case, no template on the channel), phone (cannot be parsed, outside the allowed countries, sent together with customer_id, neither sent — then also customer_id), customer_id (not a UUID, not found in the organization, no phone), locale, interaction_id, Idempotency-Key; OTP_RESEND_TOO_SOON (details.retry_after, details.resend_at); OTP_DAILY_LIMIT (details.limit, details.retry_after, details.resets_at); IDEMPOTENCY_MISMATCH (details.key).

    Error format and codes

  • 429

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

    Headers

    • Retry-Afterinteger

      Seconds until the window resets
    • X-RateLimit-Limitinteger

    • X-RateLimit-Remaininginteger

    Error format and codes

Verification status

GET/verifications/{id}

Verification by ID — the same Verification as in the POST response: the client checks status before the code is entered (failed with failure_reason — offer a retry) and expires_at. Ability otp:send; another organization's verification is indistinguishable from a nonexistent one — NOT_FOUND. The code hash, attempt count and provider response are not returned.

Parameters

  • idstring (uuid)pathrequired

Responses

  • 200

    Verification

    application/json

    object

  • 401

    UNAUTHENTICATED — the Bearer token is missing or invalid

    Error format and codes

  • 403

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

    Error format and codes

  • 404

    NOT_FOUND — resource or route not found

    Error format and codes

  • 429

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

    Headers

    • Retry-Afterinteger

      Seconds until the window resets
    • X-RateLimit-Limitinteger

    • X-RateLimit-Remaininginteger

    Error format and codes

Check a code

POST/verifications/{id}/check

Code entry. Ability otp:verify; no Idempotency-Key is needed — no entity is created, and repeating the correct code on an already verified verification returns the same Verification without a write. Another organization's verification is indistinguishable from a nonexistent one — NOT_FOUND.

Order: state first, then the code — the response does not reveal whether the code is correct while there is nothing to check. failed → OTP_PROVIDER_ERROR (502: the code was not delivered, details.reason — the provider's refusal text or a generic reason); expired or just expired → OTP_EXPIRED (details.expired_at; the row immediately becomes expired); attempts exhausted → OTP_ATTEMPTS_EXCEEDED (details.attempts) — the correct code is no longer accepted; then the comparison: a wrong code (including one that is not 4–8 digits) → OTP_INVALID_CODE, the attempt counts, details.attempts_left — how many more wrong entries are allowed (0 — that was the last one); correct → 200, status: verified, verified_at. On an already verified one, a wrong code gives OTP_INVALID_CODE without counting an attempt. After OTP_PROVIDER_ERROR, OTP_EXPIRED and OTP_ATTEMPTS_EXCEEDED a new send is needed (POST /verifications).

Customer binding: if customer_id is empty and the organization has exactly one customer with this phone, that customer is set in customer_id; with several or none it stays null.

Parameters

  • idstring (uuid)pathrequired

Request body

application/json

VerificationCheckInput

Body of POST /verifications/{id}/check
  • otp_codestringrequired

    The code from the message — as a string, not a number: leading zeros matter (0042 ≠ 42); a JSON number and an empty string give VALIDATION_FAILED; leading and trailing spaces are dropped. A non-empty string that is not 4–8 digits is a regular wrong code (OTP_INVALID_CODE, the attempt counts).
    Constraints
    minLength: 1maxLength: 16
    Example
    0427

Responses

  • 200

    Code is correct — the verification is confirmed (or was already confirmed with this code)

    application/json

    object

  • 401

    UNAUTHENTICATED — the Bearer token is missing or invalid

    Error format and codes

  • 403

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

    Error format and codes

  • 404

    NOT_FOUND — resource or route not found

    Error format and codes

  • 422

    VALIDATION_FAILED — details.fields.otp_code (missing, empty, not a string, longer than 16); OTP_INVALID_CODE (details.verification_id, details.attempts_left); OTP_EXPIRED (details.verification_id, details.expired_at); OTP_ATTEMPTS_EXCEEDED (details.verification_id, details.attempts).

    Error format and codes

  • 429

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

    Headers

    • Retry-Afterinteger

      Seconds until the window resets
    • X-RateLimit-Limitinteger

    • X-RateLimit-Remaininginteger

    Error format and codes

  • 502

    OTP_PROVIDER_ERROR — the code was not delivered (the provider refused or was unavailable on all attempts, or the code expired while delivery was queued): details.verification_id, details.provider (driver code or null), details.reason — the provider's refusal text, “Expired before delivery” (the provider was not called) or the generic “Delivery failed”. A new send is required.

    Error format and codes

Schemas

Verification

object

A verification: a code issued to one addressee over a channel for a purpose. The code itself, its hash, the number of attempts and the provider's response are not returned. resend_after — from when the next code can be sent to the same addressee (created_at plus the organization's resend pause at the time of the response; the pause counts from the last send to the addressee for any purpose, so in a GET some time later the value may be out of date — POST answers with an exact OTP_RESEND_TOO_SOON).
  • idstring (uuid)required

    The same ID is sent in the code check and when linking to an interaction
  • purposestringrequired

  • channelstringrequired

    Values
    smswhatsapp
  • addresseestringrequired

    Normalized E.164 number — in full, as sent to the provider
    Example
    +77015550001
  • localestring | nullrequired

    The requested language (not the actual message language after fallback)
    Constraints
    pattern: ^[a-z]{2}$
  • statusVerificationStatusrequired

  • expires_atstring (date-time)required

    Until when the code is accepted, ISO 8601, UTC
  • resend_afterstring (date-time)required

  • customer_idstring (uuid) | nullrequired

    The customer, if customer_id was sent (or found by phone during the check, or the customer of the interaction the verification is linked to)
  • interaction_idstring (uuid) | nullrequired

    The interaction after linking
  • created_atstring (date-time)required

  • verified_atstring (date-time) | nullrequired

  • failure_reasonstring | nullrequired

    Only for failed: the provider's refusal reason or “Expired before delivery” (the code expired before the delivery job reached the provider); configuration reasons are reported generically as “Delivery failed”.

VerificationStatus

string

Verification state (closed list). pending — the code is issued and awaits input (delivery may not have happened yet); verified — confirmed; expired — the code has expired; failed — the provider did not send it (see failure_reason).
Values
pendingverifiedexpiredfailed

Meta

object

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

    Fields
    • nextstring | nullrequired

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

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

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

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

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

InteractionEffects

object

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

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

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

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

    Asset changes of the operation
  • rules_firedarray<RuleFired>required

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

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

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

CustomerLabel

object

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

    Label type code (lower case)
  • kindstringrequired

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

  • expires_atstring (date-time) | nullrequired

    ISO 8601, UTC; null — no expiry
  • sourcestringrequired

    Set manually or by a rule
    Values
    manualrule
  • created_byActorrequired

  • created_atstring (date-time)required

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

    Active label rows by source — the manual one first

Actor

object

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

    Values
    api_clientusersystem
  • idstring | nullrequired

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

CustomerLabelSource

object

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

    Values
    manualrule
  • rule_idstring (uuid) | nullrequired

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

  • expires_atstring (date-time) | nullrequired

    ISO 8601, UTC; null — no expiry
  • created_byActorrequired

  • created_atstring (date-time)required

    Moment the row was set, ISO 8601, UTC

BalanceChange

object

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

  • changestringrequired

    Example
    -3000
  • balancestringrequired

    Example
    2000
  • unitobject | nullrequired

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

    Key values: string

AssetChange

object

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

  • typestringrequired

    Asset type code
  • serialstringrequired

    Serial number as recorded
  • eventstringrequired

    Values
    registeredtransitionedreverted
  • status_fromstring | nullrequired

  • status_tostringrequired

  • customer_idstring (uuid) | nullrequired

RuleFired

object

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

    Rule code
  • rule_idstring (uuid)required

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

    Label code
  • actionstringrequired

    Values
    setremoved

CustomerBalance

object

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

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

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

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

    Key values: string