RU
EN

Authentication & Scopes

Authentication scheme

There are three distinct authentication paths, depending on who is calling whom:

Never put a token in the URL (e.g. ?api_token=...) -- URLs are logged in more places than headers are. Always use the Authorization header.

Safe writes and AI setup

Send X-Smartbtn-Idempotency-Key on every POST/PATCH/PUT/DELETE: a new UUID for a new operation, the same key for the same operation. This is a safe client convention, not global server-side UUID validation. Required operations carry x-idempotency: required in OpenAPI; the reference lists exact DELETE exemptions and the separate causation_id contract for AI replies. On a required operation, a missing key returns 400 and reuse within 24 hours returns 409, not a cached successful response. Read state after uncertainty; never automatically change the key, and respect Retry-After. On 405 for a documented method, stop and report the method, path and status without the token; do not seek alternate writes.

To configure your widget, choose the “AI setup” preset: widget:read, widget:write, ai:read, ai:write, ai:apply, kb:read, kb:write, files:write, stats:read. It replaces the entire scope selection. Grant ai:credentials:write separately only when the owner authorizes provider credential setup. Account, billing and partner rights are unnecessary. Enable “Allow widget API (JS and REST)”; issuing a token does not enable this switch.

https://smartbtn.ru/api/v1 and https://smartbtn.me/api/v1 serve the same API and project data. A different embed domain does not mean a different widget. Choose a verified base URL; send the token only in Authorization directly to that host and never automatically forward it on redirects.

Scopes

Every token carries an explicit list of scopes. The canonical registry has 40 grantable scopes: 39 are operational (38 route-required and one conditional) and one is reserved but unavailable. A request only succeeds if the token has the route scope and any conditional scope selected by its body. The Endpoints page is authoritative for what is callable today; granting a reserved scope creates no endpoint.

Scope Grants
chats:readRead chats and their metadata.
chats:writeClose, transfer, or request a rating for a chat.
messages:readRead a chat's message history.
messages:writeSend messages, typing indicators, and read receipts as an agent.
contacts:readRead contacts.
contacts:writeUpdate contact fields and attributes.
agents:readRead agent/operator info and presence.
tags:readRead tags.
tags:writeAttach tags to a contact.
files:readDownload a previously uploaded file.
files:writeUpload a new file.
stats:readRead aggregate chat/message/rating statistics.
channels:readRead a custom channel's online status.
channels:writeDeliver an inbound message on a custom channel.
webhooks:readList your webhook subscriptions.
webhooks:writeCreate, delete, or redeliver a webhook subscription.
responder:inject sensitiveInject a reply into a live chat as an external AI operator/bot.
responder:escalate sensitiveConditional on POST /v1/ai/replies: permit caller-directed handoff via escalate=true or [KEY_TO_OPERATOR]. Empty replies and platform safety floors do not require it.
channels:register sensitiveRegister a new custom channel (gated to installed apps only).
widget:readRead widget appearance, behaviour, and embed settings.
widget:writeUpdate widget settings and purge the served widget cache.
agents:write sensitiveInvite, update, suspend, restore, or remove agents. An invitation creates a new person with operator-console access to every chat on this widget.
agents:events:readRead an agent's activity/event log and per-agent metrics.
departments:readRead departments, their agents, and their schedules.
departments:writeCreate, update, or delete departments and their schedules.
messengers:readRead which messenger and social channels are connected (never their credentials).
messengers:write sensitiveConnect or disconnect a messenger channel. Writes provider credentials and repoints provider-side webhook registration.
ai:readRead AI assistants, their configuration, and AI alerts.
ai:write sensitiveCreate and update AI assistants, AI settings, and AI operators. This includes the persona and system prompt the bot speaks to your customers under.
ai:credentials:write sensitiveStore third-party LLM provider credentials that the platform then uses for outbound calls.
ai:apply sensitiveApprove an improvement that rewrites a live assistant's persona/system prompt.
kb:readRead knowledge-base rules and ingested sources.
kb:writeCreate, update, or delete knowledge-base rules and ingestion sources.
transcripts:readExport a chat transcript.
account:readRead the owning account's profile and all of its legal entities, including those used by sibling widgets.
account:writeUpdate only the owning account's name, surname, and phone; legal entities are not writable here.
billing:readRead this widget's billing records and the owning account's account-wide legal entities.
billing:write sensitiveCreate, update, or delete the owning account's account-wide legal entities. It does not issue invoices or move money.
partners:readRead partner/referral account data.
partners:withdraw sensitivereserved_unavailable: no payout operation consumes this scope in the current API, so granting it is currently inert.

The scopes marked sensitive above let a token act as (or hand off to) another operator on your behalf, invite a new person into your operator console, write third-party credentials, rewrite a live assistant's persona, or select another high-impact action -- grant them to a self-issued token only if you actually need that operational capability. partners:withdraw remains marked sensitive for any future review, but it is reserved and has no callable operation today.

Signature rotation

The outbound signature header is versioned independently of the API path version, e.g. X-Smartbtn-Signature: sha256=v1:<hex hmac>. When you rotate your per-tenant signing secret, both the old and the new secret remain valid for a short overlap window so in-flight deliveries signed with the old secret still verify -- there is no moment where every delivery fails. Revoking a token or secret, on the other hand, takes effect immediately.

Keeping credentials safe

Treat your API token and any webhook signing secret as passwords: never commit them to source control, never log them, and never pass a token as a URL query parameter. If a token or secret leaks, contact support to revoke it and have a new one issued -- a compromised credential cannot be "changed" in place, only replaced.

RU
EN
Smart button