Widgets API
Widgets are embeddable chat interfaces powered by AI agent workflows. The API is split into two sections: Dashboard endpoints (JWT-authenticated) for managing widgets, and Public endpoints (token-authenticated) for end-user chat interactions.
Dashboard Endpoints (JWT Auth)
These endpoints require standard JWT cookie authentication and are used from the NodeLoom dashboard to manage widget configurations.
List Widgets
/api/teams/:teamId/widgetsList all widgets for a team
[
{
"id": "uuid",
"name": "Support Chat",
"workflowId": "uuid",
"active": true,
"customization": {
"primaryColor": "#6366f1",
"title": "How can we help?",
"position": "bottom-right"
},
"createdAt": "2026-02-17T10:00:00.000Z"
}
]Create Widget
/api/teams/:teamId/widgetsCreate a new widget for a team
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Widget display name |
workflowId | UUID | Yes | AI agent workflow to power the widget |
customization | object | No | Visual customization (colors, title, position, avatar) |
allowedDomains | string[] | No | Restrict embedding to specific domains |
{
"name": "Support Chat",
"workflowId": "uuid",
"customization": {
"primaryColor": "#6366f1",
"title": "How can we help?",
"position": "bottom-right"
},
"allowedDomains": ["example.com", "app.example.com"]
}Update Widget
/api/teams/:teamId/widgets/:idUpdate widget configuration
Accepts the same fields as create. Only provided fields are updated.
Delete Widget
/api/teams/:teamId/widgets/:idDelete a widget and invalidate its embed token
Irreversible
Get Embed Code
/api/teams/:teamId/widgets/:id/embed-codeGet the HTML embed snippet for a widget
{
"embedCode": "<script src=\"https://your-domain.com/widget.js\" data-token=\"your-widget-token\"></script>"
}Regenerate Token
/api/teams/:teamId/widgets/:id/regenerate-tokenRegenerate the widget embed token
Invalidates the current token and generates a new one. Update the embed snippet on your website after regenerating.
{
"token": "new-widget-token-value",
"message": "Token regenerated. Update your embed code."
}Get Widget Stats
/api/teams/:teamId/widgets/:id/statsGet usage statistics for a widget
{
"totalSessions": 1234,
"totalMessages": 8765,
"avgMessagesPerSession": 7.1,
"activeSessionsToday": 42,
"tokenUsage": {
"input": 245000,
"output": 312000
}
}Public Endpoints (Token Auth)
These endpoints are used by the embedded widget on your website. They authenticate using the widget embed token instead of JWT cookies.
Token authentication
Initialize Widget
/api/widget-chat/init/:tokenInitialize the widget and load configuration
Called when the widget script loads on the page. Returns the widget customization settings and validates the token.
{
"widgetId": "uuid",
"name": "Support Chat",
"customization": {
"primaryColor": "#6366f1",
"title": "How can we help?",
"position": "bottom-right",
"avatarUrl": null
}
}Create Chat Session
/api/widget-chat/sessionsCreate a new public chat session
| Field | Type | Required | Description |
|---|---|---|---|
token | string | Yes | The widget embed token |
visitorId | string | No | Optional visitor identifier for session continuity |
{
"sessionId": "uuid",
"createdAt": "2026-02-17T10:00:00.000Z"
}Get Chat Messages
/api/widget-chat/sessions/:sessionId/messagesGet message history for a widget chat session
{
"messages": [
{
"id": "uuid",
"role": "user",
"content": "I need help with billing",
"createdAt": "2026-02-17T10:01:00.000Z"
},
{
"id": "uuid",
"role": "assistant",
"content": "I can help with billing questions...",
"createdAt": "2026-02-17T10:01:03.000Z"
}
]
}Send Chat Message
/api/widget-chat/sessions/:sessionId/messagesSend a message in a widget chat session (streaming response)
| Field | Type | Required | Description |
|---|---|---|---|
content | string | Yes | The message text |
token | string | Yes | The widget embed token |
Returns a streaming SSE response, identical in format to the Agent Chat send message endpoint.
Error Codes
| Status | Meaning |
|---|---|
400 | Invalid request or missing required fields |
401 | Invalid or expired widget token |
403 | Domain not allowed for this widget |
404 | Widget or session not found |
410 | Widget has been deleted or deactivated |