API
Btlify CRM API
The Btlify CRM API for the organization's external systems: mobile apps, websites, tills, accounting systems. The description below covers the rules common to all operations; operations are grouped by section in the menu.
- Base URL
https://app.btlify.com/api/v1- Version
1.0.0- OpenAPI 3.1 specification
- openapi.en.yaml
Connecting
The base URL is https://<CRM address>/api/v1, for example https://app.btlify.com/api/v1. Every request except
GET /ping and attachment content via a signed link carries the Authorization: Bearer <token> header — the
token of an API client issued by the organization's administrator in the admin panel (“Settings → API clients”).
The token determines the organization: all request data belongs to it only. To check the connection, call
GET /ping (no token); to check the token, call GET /me: the organization (the tenant field), abilities,
projects and the client's rate limit.
Responses and errors
A successful response is {data, meta}. An error is a non-2xx HTTP status and
{error: {code, message, details}}:
code— from the closed listErrorCode; this is what the app relies on;message— a technical description in English, for logs; the app composes the text for people itself;details— specifics: fields with errors (details.fields), ability, project, limit and others — described per operation.
Abilities and projects
API client abilities are the closed list Ability, by operation; an operation without the required ability
responds FORBIDDEN with details.ability. A request with the field or parameter project (project code)
passes only for projects assigned to the client, otherwise it gets FORBIDDEN with details.project (except
PATCH /interactions/{id}: there the project does not change, and the project field gives
VALIDATION_FAILED).
Rate limit
The limit is per API client, the window is one minute. The value is in GET /me and in the X-RateLimit-Limit
header, the remainder is in X-RateLimit-Remaining. When exceeded — RATE_LIMITED (429) with the Retry-After
header and details.limit, details.retry_after. GET /ping is not rate limited.
Idempotency
The Idempotency-Key header is required for operations where it is described as a parameter (recording
interactions, customers, entries, reversals, merge and others); other operations do not need it. The key is up
to 255 characters, unique within the API client; a UUID is recommended. Without the header — VALIDATION_FAILED
with details.fields["Idempotency-Key"].
- A repeat with the same key, path and body within 24 hours returns the saved response with the same status and
meta.idempotent_replay: true. - The same key with a different path or body —
IDEMPOTENCY_MISMATCH(422). - While the first request is still running —
IDEMPOTENCY_IN_PROGRESS(409): retry later. - Only successful responses are saved: after an error (4xx, 5xx) the key is free, and a repeat runs the request again.
Request log
The response of every operation carries the X-Request-Id header (UUID). Requests with a recognized token are
saved in the organization's log (“API log” in the admin panel) with bodies in which the values of secret fields
(password, token, secret, otp, api_key, *_token, *_secret — in any case and style, in the body and
in the query string) are replaced with ***. By X-Request-Id the request can be found in the log when
investigating incidents — send it to support. Still, do not pass secrets in the query string.
Fields and normalization
The set of fields of a customer, an interaction and a catalog is configured in the organization.
GET /schema/{entity} returns it for rendering forms; POST and PATCH check the body against the same
definitions: an unknown field, a field without visibility.api and an inactive field give VALIDATION_FAILED
with details.fields.<code>: ["Unknown field."].
Values are normalized: phone → E.164, email → lower case, date → Y-m-d, datetime → UTC with Z,
decimal → string. Send decimal and datetime as strings.
Lists and cursors
List operations with the limit and cursor parameters return data in pages: limit is 1…200, 50 by default;
the response has meta.cursor.next, an opaque string for the cursor parameter of the next page with the same
filters; null means there are no more pages. The order is stable under inserts: the cursor points to the last
returned row. The catalog list (GET /catalogs), asset search by serial number (GET /assets) and consent
texts (GET /consents/texts) are returned whole, without pages; catalog items (GET /catalogs/{code}/items)
come in pages.
Customer merge
Duplicate customers are merged into the primary one (POST /customers/{id}/merge). Requests by the absorbed
customer's id — in the path (/customers/{id}…) or in customer_id of the body (POST /interactions,
/verifications, /assets, /assets/{id}/transitions, /decision-tables/{code}/evaluate) — work on the
primary: the response carries the data and id of the primary and meta.redirected_from with the original id. A
search by the absorbed customer's identities finds the primary: the identities have moved.
A cursor issued for the absorbed customer's id is accepted only with the same id in the path (with the primary's
id — VALIDATION_FAILED under cursor) and continues from the same position: a cursor issued before the merge
does not show the primary's rows before that position — read the primary's full list from the first page.
Webhook delivery
The organization subscribes to events in the admin panel (“Settings → Webhooks”), and the CRM sends a POST
with the JSON envelope {id, type, occurred_at, data} to the subscription address, with Btlify-* headers and
the Btlify-Signature signature; events and their data are in the “Events” menu section.
- A
2xxresponse within 10 seconds — delivered. Otherwise (3xx,4xx,5xx, timeout, broken connection) — retries after 1 min, 5 min, 15 min, 1 h, 3 h, 6 h, 12 h; after the eighth attempt the delivery isfailed. - The guarantee is “at least once”: deduplicate repeats by
id. Order between events is not guaranteed — rely onoccurred_atand data from the API. - Redirects are not followed; the receiver address is checked against private networks before each attempt.
Versions and compatibility
The contract version is info.version (semantic, independent of the CRM version); the /api/v1 path is its major
part. Within /api/v1 only compatible changes are made: new operations, webhooks and event types, new optional
request fields and parameters, new response fields and new enum values (ErrorCode, event types and others). An
app skips unknown response fields and handles an unknown enum value as the general case. A compatible contract
change raises the second (minor) digit of the version (1.0.0 → 1.1.0); a schema fix to match the actual behaviour
(a format, null, a constraint) raises the third (patch) digit (1.0.0 → 1.0.1); clarifying description text does
not change the version.
Breaking changes — removing or renaming a field, changing a type, a new required field or ability on an existing
operation — ship only in a new path version (/api/v2). Organizations are notified of it at least 3 months
before /api/v1 stops working; until then both versions work.
Errors and codes
object
errorobjectrequiredFields
codeErrorCoderequiredmessagestringrequiredTechnical description in EnglishdetailsobjectrequiredDepends on the code:fieldsfor VALIDATION_FAILED (field → list of messages; for a rejection on interaction assets — alongside itreasons“path → reason code”owned_by_other/transition_not_allowed/serial_takenandexisting_idfor a singleserial_taken),slot/identity/existing_idfor CONFLICT (for an interaction —external_idandexisting_id; an edit of a voided one —idandstatus),customer_idandlabelsfor BLOCKED (for a rejection on a decision table row — plusrow_id,row_code),customer_id,row_id,row_codeandcolumnsfor NOT_QUALIFIED, the same pluslimitsfor LIMIT_REACHED (shaped likeDecisionRejectedRow.details),catalog/code/fieldfor CATALOG_ITEM_INACTIVE,keyfor IDEMPOTENCY_MISMATCH and IDEMPOTENCY_IN_PROGRESS;retry_after,resend_atfor OTP_RESEND_TOO_SOON;limit,retry_after,resets_atfor OTP_DAILY_LIMIT; for code check errors —verification_idandattempts_left(OTP_INVALID_CODE),expired_at(OTP_EXPIRED),attempts(OTP_ATTEMPTS_EXCEEDED),providerandreason(OTP_PROVIDER_ERROR — the refusal text);verification_idandreasonfor OTP_NOT_VERIFIED (reason code:customer_mismatch,phone_mismatch,not_verified,already_used,too_old). An empty object if there is nothing to add.
ErrorCode
string
- Values
UNAUTHENTICATEDFORBIDDENNOT_FOUNDVALIDATION_FAILEDCONFLICTIDEMPOTENCY_MISMATCHIDEMPOTENCY_IN_PROGRESSRATE_LIMITEDOTP_RESEND_TOO_SOONOTP_DAILY_LIMITOTP_INVALID_CODEOTP_EXPIREDOTP_ATTEMPTS_EXCEEDEDOTP_NOT_VERIFIEDOTP_PROVIDER_ERRORCATALOG_ITEM_INACTIVENOT_QUALIFIEDLIMIT_REACHEDBLOCKEDINSUFFICIENT_BALANCEINTERNAL
Sections
General
- System
Availability check and data about the current API client: organization, abilities, projects, limit.
- Field schema
The set of customer, interaction and catalog fields configured in the organization — for rendering forms and checking data before sending.
Customers
- Customers
A customer is a person in the organization's database.
- Consents
GET /consents/texts?locale= — the current texts of all active consent types in the customer's language.
- Attachments
Attachments are files: a signature, a photo, a document.
- 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 — th…
Interactions and accounting
- Interactions
An interaction is a piece of work with a customer in a project: a sale, a visit, a consultation.
- Accounts
Customer balance by account kind, manual entries and their reversals.
- Assets
Customer assets (a device, a card and other organization types): registration, update, status transitions.
Catalogs and rules
- Catalogs
Organization catalogs (products, outlets and others): reading, changes since a version, item upload.
- Decision tables
Decision tables: definition, rows since a version and evaluation for a customer.
- Agents
The registry of agents (the organization's employees and partners) and checking their codes.
Events
- Webhooks
Events the CRM sends to the organization's subscription address: the envelope, signature headers and the data shape of each event.