SDKs
Official clients handle authentication, pagination, retries with backoff and webhook signatures. No dependencies.
Node.js 18+, Bun, Deno (TypeScript types included)
npm install @bynix/chat
import { Bynix } from "@bynix/chat";
const bynix = new Bynix({ apiKey: process.env.BYNIX_API_KEY, baseUrl: "https://YOUR-HOST" });
const { data } = await bynix.conversations.list({ status: "open", limit: 10 });
await bynix.conversations.reply(data[0].id, "Your order #4521 has shipped.");
for await (const c of bynix.conversations.all({ channel: "whatsapp" })) console.log(c.id);
await bynix.contacts.upsert({ email: "meera@buyer.example", tags: ["vip"] });
Python 3.8+
pip install bynix-chat
from bynix_chat import Bynix, BynixError
bynix = Bynix(api_key=os.environ["BYNIX_API_KEY"], base_url="https://YOUR-HOST")
for c in bynix.conversations.all(status="open"):
print(c["id"], c["channel"])
try:
bynix.conversations.reply(812, "Your order #4521 has shipped.")
except BynixError as e:
print(e.status, e.type) # e.g. 409 window_closed
Both retry rate limits (honouring Retry-After), server errors and network errors twice. A reply is only retried when the server refused it with 429, so it is never sent twice.
Authentication
Create a key in Settings → API & webhooks. Send it in every request. Read-only keys can only use GET.
curl https://YOUR-HOST/v1/me \
-H "Authorization: Bearer bx_live_…"
Keys are shown once. Keep them on your server, never in a browser or app. Limit: 600 requests per minute per key.
Errors
Errors use standard HTTP status codes and a JSON body:
{ "error": { "type": "not_found", "message": "Conversation not found" } }
| Status | Type | Meaning |
|---|---|---|
| 400 | invalid_request | A field is missing or invalid |
| 401 | unauthorized | Missing, invalid or revoked key |
| 403 | forbidden | Read-only key used for a change |
| 404 | not_found | No such object in your workspace |
| 409 | window_closed | WhatsApp/Messenger/Instagram messaging window has closed |
| 429 | rate_limited | Slow down and retry |
Pagination
Lists return newest first: { "data": [...], "has_more": true, "next_starting_after": 812 }. Pass starting_after to get the next page and limit (1–100, default 25).
Conversations
/v1/conversationsFilters: status (open, pending, snoozed, closed), channel (web, email, whatsapp, messenger, instagram, telegram), updated_since (unix seconds).
/v1/conversations/{id}The conversation with its messages (internal notes are not included).
/v1/conversations/{id}/messagesReply as your integration. It's delivered on the conversation's channel (website chat, email, WhatsApp…). Set "note": true for an internal note.
curl -X POST https://YOUR-HOST/v1/conversations/812/messages \
-H "Authorization: Bearer bx_live_…" -H "Content-Type: application/json" \
-d '{"body": "Your order #4521 has shipped. Tracking: https://track.example/4521"}'
/v1/conversations/{id}Fields: status (open, pending, snoozed, closed; with snoozed also send snoozed_until in Unix seconds, at most a year ahead: the conversation comes back as open then, or as soon as the customer writes), priority (low, normal, high, urgent), tags (replaces the list), assigned_to (teammate id or null), fields (your conversation fields by key, e.g. {"order_number": "CW-10482"}; null clears one). Closing is refused while a field that's required to close is empty.
Contacts
/v1/contactsFilters: email, phone (with country code).
/v1/contactsCreates a contact, or updates the one with the same email or phone (returns 200 instead of 201).
{ "email": "meera@buyer.example", "name": "Meera Iyer", "phone": "+919876543210",
"company": "Iyer Traders", "tags": ["vip"], "custom": { "plan": "Pro" } }
/v1/contacts/{id}/v1/contacts/{id}/v1/contacts/{id}Permanently deletes the contact and all their conversations (for privacy requests).
Webhooks
Add a URL in Settings → API & webhooks and choose events. Works with Zapier ("Webhooks by Zapier → Catch Hook"), Make, n8n or your own server.
| Event | When |
|---|---|
conversation.created | A new conversation starts on any channel |
message.created | A customer, teammate or bot sends a message (not internal notes) |
conversation.closed | A conversation is closed |
automation.run | Sent only to the webhook an automation rule names, when that rule runs (adds rule, trigger and conversation) |
conversation.rated | A customer rated a conversation (adds rating 1–5 and rating_comment) |
contact.created / contact.updated | A contact is created or changed |
POST your-url
X-Bynix-Event: message.created
X-Bynix-Delivery: 9841
X-Bynix-Signature: t=1795540000,v1=5f2c…
{ "id": "evt_9841", "event": "message.created", "created_at": 1795540000,
"data": { "message": { "id": 1201, "sender": "visitor", "body": "Hi!" }, "conversation": { "id": 812, "channel": "whatsapp", … } } }
Verify the signature
Compute HMAC-SHA256 of <t>.<raw body> with your webhook secret and compare it to v1. Reject requests older than 5 minutes.
// Node.js
const [t, v1] = header.split(",").map((p) => p.split("=")[1]);
const expected = crypto.createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
const ok = crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(v1)) && Date.now() / 1000 - t < 300;
Or let the SDK do it (pass the raw body, not parsed JSON):
// Node.js (Express)
import { verifyWebhook } from "@bynix/chat";
app.post("/bynix", express.raw({ type: "application/json" }), async (req, res) => {
try { const event = await verifyWebhook(req.body, req.get("X-Bynix-Signature"), process.env.BYNIX_WEBHOOK_SECRET); /* … */ res.sendStatus(200); }
catch { res.sendStatus(400); }
});
# Python (Flask)
from bynix_chat import verify_webhook, BynixSignatureError
event = verify_webhook(request.get_data(), request.headers["X-Bynix-Signature"], os.environ["BYNIX_WEBHOOK_SECRET"])
Retries
Answer with any 2xx status within 10 seconds. Otherwise we retry after 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours and 12 hours. Use X-Bynix-Delivery to ignore duplicates. After 20 failed deliveries in a row the webhook is paused; turn it back on in Settings.
Widget JavaScript
On your website, after the widget script:
BynixChat.identify({ name: "Meera Iyer", email: "meera@buyer.example", user_hash: "…" }); // who is logged in
BynixChat.setCart({ items: [{ title: "Tea set", quantity: 1, price: 1499 }], total: 1499, currency: "INR" });
BynixChat.open(); BynixChat.close();
BynixChat.on("message", (m) => console.log(m.sender, m.body)); // also "ready", "open", "close", "unread"
Identity verification
So nobody can type a customer's email into the chat and see their history or orders, create a secret in Settings → Chat widget → Identity verification, have your server sign the logged-in customer's email, and turn on Require verified identity. Unsigned emails are then never matched to a customer (an email a visitor types into the chat is only used to email them replies).
// on your server, never in the browser
user_hash = hex(HMAC_SHA256(identity_secret, lowercase(email)))
// PHP: hash_hmac('sha256', strtolower($email), $secret)
// Node: crypto.createHmac('sha256', secret).update(email.toLowerCase()).digest('hex')
// Python: hmac.new(secret.encode(), email.lower().encode(), hashlib.sha256).hexdigest()
// Shopify (theme.liquid): {{ customer.email | downcase | hmac_sha256: "your secret" }}
Mobile apps
Put the same chat inside your iOS or Android app. Conversations, the AI agent, files, voice notes and calls work as on the website, and the app gets events (new message, unread count, close). The site key is in Settings → Install.
React Native
npm install @bynix/chat-react-native react-native-webview
import { BynixChat } from "@bynix/chat-react-native";
<BynixChat baseUrl="https://YOUR-HOST" siteKey="SITE_KEY" user={{ name: "Meera", email: "meera@buyer.example" }}
showClose onClose={() => navigation.goBack()} onUnread={({ count }) => setBadge(count)} />
Flutter
BynixChat(
baseUrl: 'https://YOUR-HOST', siteKey: 'SITE_KEY',
user: const BynixUser(name: 'Meera', email: 'meera@buyer.example'),
showClose: true, onClose: () => Navigator.of(context).pop(),
)
Native iOS (Swift) and Android (Kotlin)
Open https://YOUR-HOST/mobile/SITE_KEY?name=…&email=… in a web view with JavaScript and storage on. Add &close=1 to show a close button.
// iOS: events arrive as { source: "bynix-chat", type, data }
let config = WKWebViewConfiguration()
config.userContentController.add(self, name: "bynix") // WKScriptMessageHandler
config.allowsInlineMediaPlayback = true
let web = WKWebView(frame: .zero, configuration: config)
web.load(URLRequest(url: URL(string: "https://YOUR-HOST/mobile/SITE_KEY")!))
// Android
webView.settings.javaScriptEnabled = true
webView.settings.domStorageEnabled = true
webView.addJavascriptInterface(object { @JavascriptInterface fun postMessage(json: String) { /* {"type":"message",…} */ } }, "BynixAndroid")
webView.loadUrl("https://YOUR-HOST/mobile/SITE_KEY")
Later, from the app: window.bynixIdentify({ name, email }), window.bynixSetCart(cart). For calls, add camera and microphone permissions to the app.