Developer docs
Build Live Chat into your site and admin panel
One script tag for the widget, a small JavaScript API for your own buttons, single sign-on from your admin panel, and an MCP server so your AI assistant can do the wiring.
Add the widget
Paste this tag before </body> on every page that should show the chat. Find your Workspace ID in Settings › General, or copy the whole tag from Settings › Widget.
The script is small and loads nothing else until a visitor opens the chat. It works on any site: plain HTML, WordPress, Shopify, Next.js or a single-page app.
<script src="https://api.hibira.io/live-chat/w/v1.js"
data-workspace="ws_..." async></script>Add each site's address under Settings › Widget › Sites the widget may run on. The widget refuses other sites.
Widget options
Set these attributes on the script tag.
<script src="https://api.hibira.io/live-chat/w/v1.js"
data-workspace="ws_..."
data-color="#0f766e"
data-lang="ja"
async></script>| Attribute | What it does |
|---|---|
data-workspace | Required. Your Workspace ID (ws_...). |
data-color | Overrides the colour set in Settings › Widget, as a hex value such as #0f766e. Default: that setting, else #e5484d. |
data-lang | The widget's language: en, ja, ko, zh-TW, zh-CN, th or vi. Default: the visitor's browser language. |
data-launcher="none" | Leaves out the round chat button, so your page opens the chat with its own buttons (see JavaScript API). |
nonce | On a page with a strict Content-Security-Policy, the widget puts the script tag's nonce on the styles and scripts it adds. |
JavaScript API
Once the script has loaded, window.HibiraLiveChat lets your page open and close the chat. Listen for the hibira-livechat:ready event if your code may run before the widget loads.
<button type="button" id="talk-to-sales">Talk to sales</button>
<script src="https://api.hibira.io/live-chat/w/v1.js"
data-workspace="ws_..." data-launcher="none" async></script>
<script>
document.getElementById("talk-to-sales").addEventListener("click", function () {
if (window.HibiraLiveChat) window.HibiraLiveChat.open({ topic: "sales" });
});
window.addEventListener("hibira-livechat:ready", function () {
// The widget is loaded: HibiraLiveChat.open() and .close() work now.
});
</script>| Call or event | What it does |
|---|---|
HibiraLiveChat.open() | Opens the chat panel. |
HibiraLiveChat.open({ topic: "sales" }) | Opens the chat and marks a new conversation as a sales inquiry, so your team sees it as one in the inbox. |
HibiraLiveChat.close() | Closes the chat panel. |
hibira-livechat:ready | A window event fired once the widget has loaded. |
hibira_chat_open, hibira_chat_start, hibira_chat_message, hibira_chat_rating | Google Analytics events sent to the gtag or Tag Manager already on your site, when you turn analytics on in Settings › Widget. Nothing personal is sent. |
Content-Security-Policy
If your site sends a strict Content-Security-Policy, allow the hosts below and put your page's nonce on the script tag. The widget passes that nonce on to everything it adds.
challenges.cloudflare.com runs the spam check on a new visitor's first message.
script-src 'nonce-R4nd0m' https://api.hibira.io https://challenges.cloudflare.com;
style-src 'nonce-R4nd0m';
connect-src https://api.hibira.io wss://*.hibira.io;
img-src https://api.hibira.io data:;
frame-src https://challenges.cloudflare.com;
<script src="https://api.hibira.io/live-chat/w/v1.js" nonce="R4nd0m"
data-workspace="ws_..." async></script>Agent single sign-on (JWT) Starter and up
Let your staff go from your own admin panel straight into the Live Chat inbox, without a separate password. Your server signs a short-lived token for the signed-in staff member and sends them to Live Chat.
- Turn on single sign-on in Team › Single sign-on and copy the secret.
- Store the secret on your server only, for example in the HIBIRA_LIVECHAT_SSO_SECRET environment variable. Never put it in browser code.
- Add a link in your admin panel to a route of yours that checks the user is staff, signs the token below and redirects to /sso/jwt.
- The first time someone signs in, Live Chat adds them as an agent if a seat is free. Their role follows the token on every sign-in.
import crypto from "node:crypto";
const b64 = (v) => Buffer.from(JSON.stringify(v)).toString("base64url");
// Build a new URL on every click, behind your admin panel's own login.
export function liveChatSsoUrl(user) {
const now = Math.floor(Date.now() / 1000);
const head = b64({ alg: "HS256", typ: "JWT" });
const body = b64({
iss: "ws_...", // your Workspace ID
sub: String(user.id), // the user's ID in your system
email: user.email,
name: user.name,
role: user.isAdmin ? "admin" : "agent",
jti: crypto.randomUUID(), // single use
iat: now,
exp: now + 120, // 5 minutes at most
});
const sig = crypto
.createHmac("sha256", process.env.HIBIRA_LIVECHAT_SSO_SECRET)
.update(head + "." + body)
.digest("base64url");
return "https://hibira.io/portal/live-chat/sso/jwt?" + new URLSearchParams({
jwt: head + "." + body + "." + sig,
return_to: "/inbox",
});
}| Claim | Meaning |
|---|---|
iss | Required. Your Workspace ID. |
sub | Required. The user's ID in your system (up to 200 characters). It links the agent across sign-ins, even if the email changes. |
email | Required. The user's email address. |
name | Optional. The name shown to visitors and teammates. |
role | Optional. agent (default) or admin. |
jti | Required. A unique ID for this token (up to 128 characters). Each token works once. |
iat | Optional. When the token was signed, in Unix seconds. |
exp | Required. When the token expires, in Unix seconds: at most 5 minutes from now. |
- Sign with HS256 and send the token as ?jwt= to /sso/jwt. Add return_to with a path such as /inbox to choose where the agent lands.
- Clocks may differ by up to 30 seconds.
- After you rotate the secret, the previous one keeps working for 24 hours, so you can deploy the new one without downtime.
- Turn on "Only single sign-on" once it works: agents can then only sign in through your admin panel, while the owner can still use email.
Ready-made code for Node.js, Laravel, PHP, Python, Django, Rails, Go, Java and .NET is available through the MCP server below.
Single sign-on with your identity provider (OIDC or SAML) Business and up
Let agents sign in with your company's own identity provider: Okta, Microsoft Entra ID, Google Workspace, Auth0, Keycloak, OneLogin, JumpCloud or any other OpenID Connect or SAML 2.0 provider. One provider per workspace; the JWT handoff above keeps working next to it.
- In Settings › Single sign-on, choose OpenID Connect or SAML and copy the values shown (Redirect URI, or Entity ID and ACS URL).
- Register Live Chat as an app in your provider with those values and assign the people who answer chats.
- OpenID Connect: enter the issuer URL, client ID and client secret. SAML: paste the provider's metadata XML or its metadata URL. Save; Live Chat checks the settings at once.
- Agents open your team's sign-in link, choose "Sign in with your company" on the sign-in page, or open Live Chat from the provider's app dashboard.
# OpenID Connect
Redirect URI https://hibira.io/portal/live-chat/sso/oidc/callback
Scopes openid email profile
Sign-in link https://hibira.io/portal/live-chat/sso/ws_...
# SAML 2.0
Entity ID https://hibira.io/portal/live-chat/sso/saml/ws_...
ACS URL https://hibira.io/portal/live-chat/sso/saml/ws_.../acs
Metadata https://hibira.io/portal/live-chat/sso/saml/ws_...| Claim or attribute | Meaning |
|---|---|
email | Required. The agent's email: the OIDC email claim (or preferred_username on Microsoft Entra ID), or a SAML attribute named email, mail or emailaddress, or an email-shaped NameID. An email_verified of false is refused. |
sub / NameID | Required. Who the person is at the provider. The first sign-in links the agent with the same email; after that, another person with that email is refused. |
name / displayName | Optional. The name shown to visitors and teammates; given and family names also work. |
- OpenID Connect uses the authorization code flow with PKCE, state and nonce, and checks the ID token's signature with the provider's published keys. A public client with PKCE only needs no secret.
- SAML accepts sign-ins started here or from the provider's dashboard. The response or assertion must be signed by a certificate from the metadata, and each assertion works once.
- New people are added as agents while a seat is free. Roles never come from the provider: set them on the Team page, or with SCIM on Enterprise.
- Turn on "Only single sign-on" once it works: agents can then only sign in through your provider, while the owner can still use email.
- The client secret is stored with the workspace's other secrets and never shown again; leave the field empty to keep it.
Before your provider's signing certificate expires, save its new metadata here; the settings show the expiry date.
Show the inbox in your admin panel Team and up
Put the Live Chat inbox in a frame on your own admin panel, so your staff answer chats without leaving it. It signs in with the same single sign-on token, and inside the frame it can only answer chats: settings, billing, members and keys stay in Live Chat, whatever the person's role.
- Set up agent single sign-on above.
- In Team › Single sign-on, under "Show the inbox in your admin panel", list your admin panel's sites, like https://admin.example.com (up to 5). Only these sites can frame the inbox.
- Add one element and our script to an admin page, with data-url set to your single sign-on route. In that route, add embed=1 to the Live Chat URL when its own request has embed=1.
- The script signs in again when the session ends, offers a new tab when the browser keeps no sign-in inside frames, and keeps data-badge at the number of chats waiting for a reply. It also fires hibira-inbox:ready, hibira-inbox:waiting, hibira-inbox:signed-out and hibira-inbox:cookies-blocked events on the element. Our MCP server's get_sso_snippet with embed returns this code for your project.
<!-- data-url: your single sign-on route; it adds embed=1 to the
Live Chat URL when its own request has embed=1 -->
<a href="https://chat.hibira.io/admin/chats">Customer chats <span id="chat-badge" hidden></span></a>
<div data-hibira-inbox data-url="/admin/live-chat"
data-badge="#chat-badge" style="height:80vh"></div>
<script src="https://chat.hibira.io/w/inbox-v1.js" async></script>The sign-in inside the frame is kept for your admin panel's site only. Browsers that keep no sign-in inside frames send hibira-inbox:cookies-blocked. Desktop notifications do not work inside a frame. Removing your sites, turning off single sign-on or leaving Team and Business ends the embedded sessions at once.
Provisioning with SCIM Enterprise
Let your identity provider (Okta, Microsoft Entra ID, OneLogin, JumpCloud and others) add agents to Live Chat and turn them off when they leave, through SCIM 2.0.
- The workspace owner opens Team › Single sign-on and, under Provisioning (SCIM), creates a token.
- In your identity provider's SCIM app, enter the base URL below and the token as the Bearer token (HTTP header). Turn on creating users, updating user attributes and deactivating users.
- Assign the people who answer chats. To make some of them admins, push a group named Admins, or link your group to it.
# Base URL: https://api.hibira.io/live-chat/scim/v2
curl -H "Authorization: Bearer $HIBIRA_SCIM_TOKEN" \
"https://api.hibira.io/live-chat/scim/v2/Users?filter=userName%20eq%20%22jane%40example.com%22"
# Turn someone off: they are removed and signed out at once
curl -X PATCH -H "Authorization: Bearer $HIBIRA_SCIM_TOKEN" \
-H "Content-Type: application/scim+json" \
-d '{"schemas":["urn:ietf:params:scim:api:messages:2.0:PatchOp"],
"Operations":[{"op":"replace","value":{"active":false}}]}' \
https://api.hibira.io/live-chat/scim/v2/Users/agt_...- userName is the agent's email address; name or displayName is shown in the inbox.
- Setting active to false removes the agent and signs them out everywhere at once. They stay readable as inactive, and setting active to true adds them back while a seat is free.
- When every seat is taken, creating a user answers 409, so your identity provider shows the error.
- The workspace owner is never turned off, removed or changed through SCIM.
- Every change is in the workspace's activity log, by scim.
Supported: Users (filter by userName, externalId or id; PATCH and PUT), the Admins and Agents groups, ServiceProviderConfig, Schemas and ResourceTypes. Replacing the token stops the old one at once.
Verified visitors Starter and up
Tell the chat who your signed-in user is, so your team sees their real name, email and your user ID, and their chat follows them to every device. A chat can only claim a user your server signed.
- Create an identity secret in Settings › Widget › Verified visitors and keep it on your server only.
- On your server, compute user_hash: the hex HMAC-SHA256 of the user's ID with the secret.
- On pages where the user is signed in, add data-user-id and data-user-hash (and optionally data-user-name and data-user-email) to the widget's tag. Single-page apps can call HibiraLiveChat.identify({ id, hash, name, email }) instead, and HibiraLiveChat.logout() on sign-out.
<!-- user_hash = hex(HMAC-SHA256(identity secret, user ID)), made on your server -->
<script src="https://api.hibira.io/live-chat/w/v1.js" data-workspace="ws_..."
data-user-id="u_123" data-user-hash="9f86d0..."
data-user-name="Ann Lee" data-user-email="ann@example.com" async></script>
// Node.js
crypto.createHmac("sha256", process.env.HIBIRA_LIVECHAT_IDENTITY_SECRET)
.update(String(user.id)).digest("hex");
// Single-page apps
HibiraLiveChat.identify({ id: "u_123", hash: "9f86d0...", name: "Ann Lee" });
HibiraLiveChat.logout();A wrong hash is refused, so a mistake shows at once. Conversations from verified users carry visitor.user_id and verified in the REST API and webhooks.
AI assistants (MCP)
The Live Chat MCP server lets an AI assistant such as Claude, Cursor or VS Code set up single sign-on in your own codebase. The assistant signs in with your Live Chat account in the browser; only the workspace owner and admins can approve it.
The SSO secret never passes through MCP. The assistant reads the setup, writes the code for your stack and checks a token it signed, without signing anyone in.
The Hibira MCP server (https://hibira.io/mcp) reaches Live Chat too: list_livechat_workspaces, livechat_get and livechat_request let an assistant read and change settings, teams, business hours, saved replies, the AI's knowledge and webhooks, and read or answer conversations, as you.
# Claude Code
claude mcp add --transport http hibira-live-chat https://api.hibira.io/live-chat/mcp
# Any client with remote MCP servers (Cursor, VS Code, ...)
{ "mcpServers": { "hibira-live-chat": { "url": "https://api.hibira.io/live-chat/mcp" } } }| Tool | What it does |
|---|---|
get_sso_setup | Whether single sign-on is on, the Workspace ID, the sign-in URL, the token's claims and limits, and free seats. |
get_sso_snippet | Server code for your stack that signs the token and redirects the staff member, with your Workspace ID filled in. |
check_sso_token | Checks a token exactly as the real sign-in would, and lists every problem, without using it up. |
list_agents | The workspace's agents, their roles, how they were added and when they were last seen. |
set_sso_only | Turns "Only single sign-on" on or off. Owner only. |
The Hibira plugin for Claude Code, Cursor, Codex and Gemini CLI already includes this server. To disconnect every AI app at once, use Team › Single sign-on › Disconnect AI apps.
REST API Team and up
Your own servers can read and answer conversations with the REST API, and hear about new chats, messages, closes and ratings through webhooks.
Create a key in Settings › API & webhooks (owners and admins). A read-only key can only look; a read and write key can also reply, assign and close. Send it as Authorization: Bearer <key> to https://api.hibira.io/live-chat/v1. Each key may make 10 requests a second.
An admin key also changes the workspace's settings, webhooks and AI knowledge, so you can keep them in code with scripts, CI or Terraform. Changes are made as the agent who created the key and show in the activity log.
A hibira.io API token also works in place of a key: send Authorization: Bearer hkb_pat_... with a Hibira-Workspace: ws_... header, and it acts as you, with your role in that workspace. GET /v1/workspaces lists the workspaces your email is in. This is how the Hibira MCP server and the Terraform provider manage Live Chat with the same token as your other Hibira products.
Already run a bot with Chat SDK (chat-sdk.dev) on Slack, Teams or Discord? Add the @hibira-io/chat-adapter package and the same bot answers your website chat, LINE and email visitors, and can hand a chat to your team.
# Open conversations, newest activity first
curl "https://api.hibira.io/live-chat/v1/conversations?status=open" \
-H "Authorization: Bearer $HIBIRA_LIVECHAT_KEY"
# Reply as the key's agent, then close the chat
curl https://api.hibira.io/live-chat/v1/conversations/c_abc/messages \
-H "Authorization: Bearer $HIBIRA_LIVECHAT_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Your order shipped today."}'
curl https://api.hibira.io/live-chat/v1/conversations/c_abc \
-H "Authorization: Bearer $HIBIRA_LIVECHAT_KEY" \
-H "Content-Type: application/json" \
-d '{"status": "closed"}'
# The same API with a hibira.io API token
curl https://api.hibira.io/live-chat/v1/settings \
-H "Authorization: Bearer $HIBIRA_TOKEN" \
-H "Hibira-Workspace: ws_..."
| Endpoint | What it does |
|---|---|
GET /v1/workspace | The workspace's ID, name, plan and sites. |
GET, POST /v1/workspaces | hibira.io token. List the workspaces your email is in (usable says whether the token can act there), or open a new one with a name. It starts on Free like a sign-up; the same name again answers 409 workspace_exists with that workspace. Up to 10 per person. |
GET /v1/agents | The workspace's agents and their roles. |
GET /v1/conversations | Conversations, newest activity first. Filter with status, assignee_id (or none), limit and before for the next page. |
GET /v1/conversations/{id} | One conversation and its latest messages, internal notes marked. |
POST /v1/conversations/{id}/messages | Write key. Reply as agent_id, or as the agent who made the key. Add internal: true for a note. |
POST /v1/conversations/{id}/typing | Write key. Show the visitor that agent_id (or the key's agent) is typing; typing: false stops it. Shown once that agent has written in the chat. |
POST /v1/conversations/{id} | Write key. Close or reopen (status) and assign (assignee_id). |
GET /v1/ratings | Visitors' ratings since a time, 30 days by default. |
GET, POST /v1/settings | Admin key. Read or change settings: name, sites, widget look, AI, ratings, co-browsing, channel links. Send only the fields to change. Also automatic assignment (routing: manual, round_robin or least_busy, Business). |
/v1/webhooks | Admin key. List, create, read, change and delete webhook endpoints; POST /v1/webhooks/{id}/secret rotates the secret. |
/v1/teams | Admin key. List, create, read, change and delete teams (name, agent_ids). |
/v1/channels | Admin key. List messaging apps; connect a LINE Official Account (channel_id, channel_secret) at /v1/channels/line, a Telegram bot (token) at /v1/channels/telegram, a Slack app (bot_token, signing_secret) at /v1/channels/slack, a Microsoft Teams bot (app_id, client_secret, tenant_id) at /v1/channels/teams, a Viber bot (token) at /v1/channels/viber a WeChat Official Account (app_id, app_secret) at /v1/channels/wechat, a support mailbox (address, name, auto_reply) at /v1/channels/email or a Twilio number (account_sid, auth_token, phone) at /v1/channels/sms. POST /v1/channels/{id} renames an email or SMS channel and sets the email acknowledgement. POST /v1/channels/{id}/test checks it, DELETE disconnects. Counts toward the plan's channels; WhatsApp, Messenger and Instagram connect in Settings. |
GET, POST /v1/hours | Admin key. Read or replace business hours: time zone, weekly hours, closed dates, away message. |
/v1/saved-replies | Admin key. List, create, read, change and delete saved replies (title, shortcut, text). |
/v1/knowledge | Admin key. List, create, read, change and delete AI knowledge entries; /v1/knowledge/sources adds, syncs and removes websites. |
Replies and changes made with a key show in the inbox under the agent they were made as.
Webhooks Team and up
Add up to 5 HTTPS endpoints in Settings › API & webhooks, each with the events it should receive and its own signing secret, shown once. An admin key or a hibira.io API token can manage them too, through /v1/webhooks.
We POST one event per request as JSON: id, type, created_at, workspace_id and data with the conversation (and the message, for message.created). Answer with any 2xx status within 15 seconds.
import crypto from "node:crypto";
import express from "express";
const app = express();
// Read the raw body: the signature covers it byte for byte.
app.post("/hibira/live-chat", express.raw({ type: "application/json" }), (req, res) => {
const sig = Object.fromEntries(
String(req.get("Hibira-Signature")).split(",").map((p) => p.split("=")),
);
const want = crypto
.createHmac("sha256", process.env.HIBIRA_LIVECHAT_WEBHOOK_SECRET)
.update(sig.t + "." + req.body)
.digest("hex");
const fresh = Math.abs(Date.now() / 1000 - Number(sig.t)) < 300;
if (!fresh || !sig.v1 || sig.v1.length !== want.length ||
!crypto.timingSafeEqual(Buffer.from(want), Buffer.from(sig.v1))) {
return res.sendStatus(401);
}
const event = JSON.parse(req.body);
// Hibira-Webhook-Id is the same on every retry: skip ones you have seen.
if (event.type === "message.created" && event.data.message.from === "visitor") {
// notify your team, update your CRM, ...
}
res.sendStatus(204);
});
| Event | When it is sent |
|---|---|
conversation.created | A visitor starts a chat. |
message.created | A visitor, an agent or the AI writes. Internal notes too, marked internal: true. |
conversation.assigned | The chat is assigned, transferred or unassigned. |
conversation.team_changed | The chat moves to a team, or out of one. |
conversation.closed | An agent closes the chat. |
conversation.reopened | An agent or a new message reopens it. |
conversation.rated | The visitor rates the chat. |
- Check the Hibira-Signature header: t=<timestamp>,v1=<hex HMAC-SHA256 of "<timestamp>.<raw body>" with the endpoint's secret>. Refuse timestamps more than 5 minutes old.
- Hibira-Webhook-Id stays the same on every retry of an event: use it to drop repeats.
- A failed delivery is retried after 10 seconds, 1 minute, 5 minutes and 30 minutes. Redirects are not followed.
- Send a test event (webhook.test) from the settings page, and see each endpoint's last 50 deliveries for 7 days with their status and timing.
Treat a webhook as a prompt to act, and read the conversation from the REST API when you need its full state.
For AI tools
Plain-text summaries of Live Chat for AI assistants and answer engines: /llms.txt is the short version, /llms-full.txt includes these docs and every feature page in full.
curl https://chat.hibira.io/llms.txt
curl https://chat.hibira.io/llms-full.txtAdd live chat to your site today
Sign up with your work email, paste one script tag, and start answering visitors in minutes.
Start free