API · Customers

Attachments

Attachments are files: a signature, a photo, a document. POST /attachments uploads a file without an owner; GET /attachments/{id}/url — a signed link to the content with a limited lifetime; GET /attachments/{id}/content — the content itself via that link, without a token. The attachment id is passed in consents and interactions; a file not linked to anything is deleted after a day.

Upload an attachment

POST/attachments

A file without an owner: a consent signature (signature), a photo (photo), a document (document). The body is multipart/form-data with the kind and file fields. Size — at most 10 MiB; the type is detected from the file content, not from the extension or the client's header: image/png, image/jpeg, image/webp, application/pdf are allowed. The response is the attachment id for consents[].attachment_id and interaction attachments; an unbound file lives for a day (expires_at) and is then deleted. The content is served by a signed link (GET /attachments/{id}/url). Ability attachments:write; the Idempotency-Key header is required, the fingerprint is the form fields and the file's sha256.

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

multipart/form-data

object

  • kindstringrequired

    Values
    signaturephotodocument
  • filestring (binary)required

    PNG, JPEG, WebP or PDF, up to 10 MiB

Responses

  • 201

    Attachment saved

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

    Error format and codes

  • 422

    VALIDATION_FAILED — details.fields.kind (kind outside the list), details.fields.file (no file, empty, over the limit, content type outside the list), Idempotency-Key; IDEMPOTENCY_MISMATCH — the key has already been used for a different request (details.key).

    Error format and codes

  • 429

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

    Headers

    • Retry-Afterinteger

      Seconds until the window resets
    • X-RateLimit-Limitinteger

    • X-RateLimit-Remaininginteger

    Error format and codes

Signed link to the attachment content

GET/attachments/{id}/url

A link to GET /attachments/{id}/content with a server signature and a lifetime (10 minutes, expires_at); it opens without a token — the signature is the permission. A link is issued only for an attachment of your own organization (someone else's id — NOT_FOUND). Ability attachments:read — a link to any attachment by id; links to attachments of its own interactions are also available with interactions:read — in Interaction.attachments.

Parameters

  • idstring (uuid)pathrequired

Responses

  • 200

    Link issued

    application/json

    object

    • dataobjectrequired

      Fields
      • urlstring (uri)required

      • expires_atstring (date-time)required

        The moment after which the link returns 403, ISO 8601, UTC
    • metaMetarequired

  • 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

Attachment content by a signed link

GET/attachments/{id}/contentNo token

The address from GET /attachments/{id}/url: the expires and signature parameters are required and checked by the server; no Bearer token is needed. A modified or expired link — FORBIDDEN; a purged attachment — NOT_FOUND. The rate limit is per IP. The response is the file as is, Content-Type by content, Cache-Control: private, no-store.

Parameters

  • idstring (uuid)pathrequired

  • expiresintegerqueryrequired

    Signature expiry as Unix time
  • signaturestringqueryrequired

Responses

  • 200

    File content

    Headers

    • Content-Dispositionstring

      inline; filename="<id>.<ext>"

    image/png

    string (binary)

    image/jpeg

    string (binary)

    image/webp

    string (binary)

    application/pdf

    string (binary)

  • 403

    FORBIDDEN — the signature does not match or the link has expired

    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

Schemas

Attachment

object

An attachment: a file in private storage; owner — a consent or an interaction after linking; before linking it is null and expires_at applies. The storage key and hash are not returned.
  • idstring (uuid)required

  • kindstringrequired

    Values
    signaturephotodocument
  • mimestringrequired

    Type detected from the file content
  • sizeintegerrequired

    Bytes
  • ownerobject | nullrequired

    Fields
    • typestringrequired

      Values
      consentinteraction
    • idstring (uuid)required

  • expires_atstring (date-time) | nullrequired

    When an unlinked file is deleted, ISO 8601, UTC; null after linking
  • created_atstring (date-time)required

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