DevelopersWidget embed & API Browse docs

Widget embed & API

Embed the website chat widget with one script tag, or build your own chat interface on the widget's public endpoints.

Embed the widget

The simplest integration is the script tag from Widget Settings:

<script src="https://YOUR_WORKSPACE_DOMAIN/widget/chatbot.js" data-key="YOUR_WIDGET_KEY" defer></script>
AttributeDescription
srcThe widget script on your workspace domain. The snippet in Widget Settings adds a version parameter so browsers pick up updates.
data-keyYour widget key. Required.

Put it just before </body>. The widget renders in its own shadow root, so your site’s styles don’t affect it and it doesn’t affect your page. See Website chat widget for the settings.

Build your own chat interface

To design the chat yourself, call the same public endpoints the widget uses. They don’t need an API token — the widget key identifies your widget — and they enforce your widget’s Allowed Domains, based on the request’s Origin or Referer header.

  • Base URL: https://YOUR_WORKSPACE_DOMAIN/api/widget
  • Limit: 30 requests per minute per IP address

Get the widget’s settings

GET/api/widget/config?key=YOUR_WIDGET_KEY
{
  "bot_name": "Assistant",
  "welcome_message": "Hi! How can I help you today?",
  "theme_color": "#2f7cf6",
  "enabled": true
}

Start or resume a session

POST/api/widget/session
FieldRequiredDescription
widget_keyYesYour widget key
nameYesThe visitor’s name, up to 100 characters
emailYesThe visitor’s email address
session_idNoA previous session_id, to resume that conversation
lead_tokenNoThe lead_token from an earlier session. It proves this is the same visitor and restores their history.
{
  "session_id": "4a7c2e…",
  "lead_token": "9f1b6d…",
  "name": "Sara",
  "welcome_message": "Hi! How can I help you today?",
  "messages": []
}

When a conversation is resumed, messages holds the earlier messages — each with a role of visitor or bot — and welcome_message is null. Keep session_id and lead_token in the visitor’s browser and send them back next time. The visitor is recorded as a lead at this step.

Send a message

POST/api/widget/chat
FieldRequiredDescription
widget_keyYesYour widget key
session_idYesFrom the session call
messageYesThe visitor’s message, up to 2,000 characters
{
  "reply": "We deliver every day between 9 am and 9 pm.",
  "session_id": "4a7c2e…"
}

Errors

Errors return { "error": "…" } with one of these status codes:

StatusWhen
400The widget key is missing from a config request
401The session has expired ("code": "session_required"). Start a new session, then send the message again.
403The widget is switched off, or the page’s domain isn’t in Allowed Domains
404The widget key isn’t valid
422A field is missing or invalid
429Too many requests, the daily message cap was reached, or the monthly conversation limit was reached
503The assistant couldn’t reply — try again shortly
Still have questions?

Our team is happy to walk you through Wazline and help you set up your workspace.

Contact us