AIRONIK protocol

AIRONIK Bots v1 protocol

AIRONIK connects to the platform where your bot already runs. AIRONIK stores conversations and provides owner and operator tools; your platform generates bot replies. The first external agent automatically gets one trial month with INS and a knowledge base, without renewal.

1. Preparation

The owner adds an External application agent in AIRONIK. Its API key is air_ followed by 64 lowercase hex characters; its confirmation code is 16 uppercase hex characters. Both are shown once. Keep them private. Use the agent home API origin: international https://ai2.dating/api, Russia https://ai2.ru/api, Kazakhstan https://ai2dating.kz/api. The FI sandbox uses its separate API. Do not construct reply_url: use the URL returned by connect. All timestamps are UTC ISO 8601 with Z.

2. Connect

POST /api/public/aironik/connect, without JWT or HMAC:

{"api_key":"air_<64 hex>","confirmation_code":"<16 uppercase hex>","webhook_url":"https://platform.example/aironik-hook","token":"<platform token>"}

Webhook must be public HTTPS, at most 500 bytes, without URL credentials, private IPs or redirects. Optional token is at most 4096 bytes without CR/LF; AIRONIK sends it as Bearer to your webhook. Successful data contains protocol:AIRONIK Bots v1, agent_ref, webhook_secret, reply_url, max_body_bytes:64000 and replay_window_seconds:300. Save the signing secret and reply_url. Connecting again replaces the webhook and secret. One agent has one platform connection. Connect does not purchase access or remove a manual pause.

Before the stand connects a selected agent, it calls the authorized POST /api/agents/{ref}/external/validate-credentials with the key and code. This requires owner manage rights and returns {valid:true,agent_ref,can_manage:true}. A mismatch returns the same invalid_credentials error for either half. This owner method is separate from public platform authentication.

3. Signing

Content-Type: application/json, X-AI2-Timestamp: Unix seconds, X-AI2-Signature: sha256= followed by the HMAC hex digest.

canonical = timestamp + "\n" + raw_body
signature = "sha256=" + hex(HMAC_SHA256(canonical, webhook_secret))

Use the secret as a string; do not decode its hex. Sign exact JSON bytes. Timestamp tolerance is ±300 seconds; identical timestamp/signature is replay. Preserve business refs when retrying and generate a fresh signature. AIRONIK public platform calls require Bearer api_key plus HMAC. Webhooks use HMAC plus optional platform Bearer token; late replies require HMAC. JSON limit is 64000 bytes, webhook response 262144 bytes, visitor text 4000 characters, bot reply 8000. Connect limit: 10/min/IP; other public calls: 120/min/IP and 60/min/agent. The replay guard is local to an API node.

4. Platform client messages

POST /api/public/aironik/messages:

{"visitor":{"id":"client-session-42","name":"Anna"},"message_ref":"client-message-0001","text":"Hello","lang":"en"}

visitor.name is an optional client display name. The server removes control and invisible formatting characters, truncates it to 120 Unicode characters and stores it for this visitor.id within the connection. Send a changed name with a new message. Omitting the field keeps the previous name; an empty string or null clears it. Replaying message_ref returns the previous result and does not update the name. The name appears in conversations and INS client cards and is returned in visitor.name in the platform webhook. Without a name, the interface uses “Guest #N” in the reader’s language and the webhook contains null. ZWJ and variation selectors are preserved so compound emoji stay intact. This is display text, not an identity key; escape it when rendering.

visitor.id: 1–190 bytes, stable within a client session. message_ref: 1–100 [A-Za-z0-9_.:-], unique across the connection. A retry returns the saved result without adding another visitor message. AIRONIK stores the message then invokes your bot webhook; prevent a loop by not sending that webhook text back into messages. data.conv_id:N maps to gN in the protocol and guest:N for the owner. Results include ok with answer, pending, silent, ai_unavailable and conversation_closed. Check data.status as well as HTTP and success. A test:true field does not turn a public message into a visitor test. Failed first results are cached by message_ref too; a retry does not guarantee another webhook call.

5. Platform webhook

{"protocol":"AIRONIK Bots v1","version":1,"event":"message","bot":{"id":"<agent_ref>","name":"Assistant"},"conversation":{"id":"g123","channel":"aironik"},"visitor":{"id":"<opaque id>","name":null,"lang":"en"},"message":{"id":"456","text":"Hello","sent_at":"2026-10-10T12:00:00Z"},"history":[],"reply_url":"https://api.example/api/public/bots/<agent_ref>/reply"}

Validate protocol, version, bot.id, expected reply_url, token, timestamp and signature before processing. Deduplicate message.id within conversation and event_id for events. Visitor id is opaque and differs from the original platform session id. History contains up to 10 visitor/bot/operator entries and may be shortened for size. Ignore additional fields safely.

6. Immediate and late replies

Immediate: HTTP 200 {"reply":"Hello!"}. Webhook timeout is 10 seconds, connect timeout 4 seconds. For slower work return HTTP 202 {"accepted":true}, then POST to reply_url with HMAC:

{"conversation_id":"g123","message_ref":"bot-answer-0001","text":"Hello!"}

message_ref is required (1–100 [A-Za-z0-9_.:-]); repeats in the conversation return the original message_id. A successful HTTP 200 with message_id:0 means the reply was suppressed, for example by operator takeover. Do not display it as delivered or retry to override the operator. Closed or expired conversations reject replies.

7. History and close

POST /api/public/aironik/conversations {"after":0} returns up to 100 working conversations. The same path with {"conversation_id":"g123","after":0} returns visible messages {id,sender,body,created_at}. Envelope: {items,next_after,has_more}. Conversation and message cursors are separate. sender is guest/model/operator. Poll known conversation histories; new messages in older conversations do not change the conversation PK. POST /api/public/aironik/conversations/close {"conversation_id":"g123"} closes a session. Use a new visitor.id for a new session. Visitor tests are excluded from public history.

8. Events and sync

Envelope: {protocol,version,event,event_id,bot,data,reply_url}. Events: handoff (thread_ref,human_operated), conversation_closed, ins_created and sync. Return 2xx; deduplicate event_id. Event retry attempts are limited to five, with 20/60/180/600 second delays; actual delivery depends on workers. Ordinary client webhooks are not retried automatically.

sync carries up to 20 new working messages, up to 10 changed INS records, requests, ins, settings, has_more and pull_status. requests and ins are two views of the same registry. Settings include effective use_knowledge_base/use_ins and name/role/gender/sync_every/sync_unit. Sync period controls server sync delivery, not bot reply delay. Cursors move after successful delivery; pending knowledge copying can stop advancement. Pauses, schedules and missing access stop working sync. Visitor tests are excluded. This is not a full edit/delete change log or guaranteed two-way mirror.

9. Knowledge base

POST /api/public/aironik/kb/search {"query":"consultation terms"}: 2–500 characters, up to 8 results. POST /api/public/aironik/kb/documents {"document_ref":"conditions-v1","operation":"upsert","text":"…"}: ref 1–100 [A-Za-z0-9_.:-], text 20–50000 characters. For deletion use operation:delete. Search is scoped to one agent; your platform uses the results to generate its own reply. A switch does not automatically make a platform use RAG. Features require effective access; the trial includes both. Searching is available during visitor tests when the agent has access. Test messages are excluded from copying into working knowledge. Documents using ins: refs also require INS access.

10. INS

POST /api/public/aironik/ins with Bearer and HMAC:

{"title":"Consultation request","request_ref":"request-0001","conversation_id":"g123","details":{"service":"consultation"}}

title: 1–200 characters; request_ref: 1–100 bytes, idempotent per agent; conversation must belong to this agent. Read with {"after":0} or {"ins":"AI2-…"}. List returns items,next_after,has_more; lookup returns ins,title,status,details,test,void. PK cursors do not detect edits: use sync or lookup. Provider status mutation is not supported. Disabled INS blocks create/list/lookup. A saved visitor test issues safe records with test:true,void:true,status:cancelled, visible to the owner in agent events with a test label and read_only:true; they are excluded from the combined Processes inbox. They have no working notifications or sync and are excluded from provider working list/lookup. Normal trial conversations issue working INS.

11. Visitor test and operator

Owner JWT methods, separate from platform authorization: GET /api/agents/{ref}/test-threads returns active tests with ref,expires_at,created_at,created_by,last_message,last_message_at,messages_url. Every new agent has a permanent Test conversation (expires_at:null). Legacy temporary tests keep their deadlines. POST /api/agents/{ref}/test-thread returns the permanent conversation without duplication, including test:true,thread_ref,expires_at,messages_url. For external message delivery connect first.

POST /api<messages_url> {"text":"Hello"} sends as visitor; GET reads up to 100 recent visible messages. DELETE clears only this test history, test INS and takeover and returns new thread_ref/messages_url. The old ref no longer accepts pending replies. Creation/sending/clearing require chat rights; reading requires threads. Platform receives event:test,test:true with gN and uses the same immediate/late reply protocol. Never deliver test replies to real clients.

Operator takeover/release: POST /api/agents/{ref}/threads/{thread}/takeover or /release. Operator reply: POST .../messages {"text":"Personal reply"}, with takeover rights and explicit takeover held by this person. Visitor input continues through messages_url. Tests bypass basic subscription checks but retain pauses, schedules and active state. Their history is separate from working threads, conversations and sync. Expired legacy tests return 410, removed tests 404.

12. Errors and scope

API success: {success:true,message:"OK",data:{…}}. Error: {success:false,message:"…",code:"bad_payload",error_code:"bad_payload"}. 401 invalid_credentials/bad_signature/stale; 402 subscription_required; 403 forbidden/feature_disabled; 404 not_found/conversation_not_found; 409 replay/not_connected/external_not_connected/paused/busy; 410 test_thread_expired; 413 payload_too_large; 422 bad_payload/bad_settings/webhook_url_blocked; 429 rate_limited; 503 protocol_guard_unavailable/knowledge_unavailable. Retry temporary failures with bounded backoff and jitter, stable business refs, and fresh signatures. Check nested data.status for HTTP 200 too.

This version supports text, working conversations, sync and events, knowledge documents/search and INS. It does not promise old-history import, arbitrary attachments, an AIRONIK LLM for external bots, automatic channels, a ready SDK or two-way INS updates.