# CHAT_WIDGETS

chat-widgets endpoints.

**Base URL:** `https://api.trustpager.com/functions/v1/api/v1`

## Endpoints

### POST /chat-widgets

Create a Live Chat widget. It answers only from the knowledge bases you give it (kb_ids, at least one) and only on the websites in allowed_origins.

**Scopes:** `chat-widgets:write` — [full detail](./chat-widgets/post-chat-widgets.md)

### DELETE /chat-widgets/:widget_id

Delete a Live Chat widget and all of its saved chats. Leads already created are not touched. Waits in the approvals queue for connectors that hold chat-widgets:delete-approval.

**Scopes:** `chat-widgets:delete` — [full detail](./chat-widgets/delete-chat-widgets-widget-id.md)

### DELETE /chat-widgets/:widget_id/sessions/:session_id

Erase one saved chat: its messages and the visitor details are removed for good. A small record of counts and the level stays. Leads already created are not touched.

**Scopes:** `chat-widgets:write` — [full detail](./chat-widgets/delete-chat-widgets-widget-id-sessions-session-id.md)

### POST /chat-widgets/:widget_id/sessions/delete-older

Erase every saved chat on a widget that started more than older_than_days days ago (1 to 3650). Messages and visitor details are removed for good. Leads already created are not touched. Answers how many were erased; more_remain true means run it again.

**Scopes:** `chat-widgets:write` — [full detail](./chat-widgets/post-chat-widgets-widget-id-sessions-delete-older.md)

### GET /chat-widgets/:widget_id

Get one live chat widget: its knowledge bases, allowed websites, rules text, tone of voice, limits and public key.

**Scopes:** `chat-widgets:read` — [full detail](./chat-widgets/get-chat-widgets-widget-id.md)

### GET /chat-widgets/:widget_id/sessions/:session_id

Get one chat with its messages in order, the level it was given and the details captured.

**Scopes:** `chat-widgets:read` — [full detail](./chat-widgets/get-chat-widgets-widget-id-sessions-session-id.md)

### POST /chat-widgets/:widget_id/sessions/:session_id/hand-back

Hand a live chat back to the agent, which answers the visitor again.

**Scopes:** `chat-widgets:write` — [full detail](./chat-widgets/post-chat-widgets-widget-id-sessions-session-id-hand-back.md)

### POST /chat-widgets/:widget_id/sessions/:session_id/links

Link a live chat to a CRM contact and an opportunity, change them, or unlink them (null). A field you leave out stays as it is. Works on chats that have ended. Nothing is shown to the visitor. A Client Portal chat keeps the client of its portal as the contact; it can still be linked to an opportunity.

**Scopes:** `chat-widgets:write` — [full detail](./chat-widgets/post-chat-widgets-widget-id-sessions-session-id-links.md)

### GET /chat-widgets/:widget_id/sessions

List the chats a widget has had, newest first. Filter with level (urgent, priority, standard) or trigger_failed=true. Chats can hold a visitor first name and mobile number: treat them as personal data.

**Scopes:** `chat-widgets:read` — [full detail](./chat-widgets/get-chat-widgets-widget-id-sessions.md)

### GET /chat-widgets

List live chat widgets, newest first. Filter with status (active or paused).

**Scopes:** `chat-widgets:read` — [full detail](./chat-widgets/get-chat-widgets.md)

### POST /chat-widgets/:widget_id/sessions/:session_id/reply

Reply to a live chat as a person on the team. If the agent is answering, the chat is taken over first (the visitor sees that a person joined). The reply shows in the visitor's chat within seconds. Refused once the chat has ended.

**Scopes:** `chat-widgets:write` — [full detail](./chat-widgets/post-chat-widgets-widget-id-sessions-session-id-reply.md)

### POST /chat-widgets/:widget_id/sessions/:session_id/retry-send

Try again to send the lead from a chat whose send failed (trigger_error is failed). The send runs once at most: the same key is reused, so a lead is never created twice.

**Scopes:** `chat-widgets:write` — [full detail](./chat-widgets/post-chat-widgets-widget-id-sessions-session-id-retry-send.md)

### POST /chat-widgets/:widget_id/sessions/:session_id/take-over

Take a live chat over from the agent: a person answers from now on and the agent stays quiet. A take over with no reply for 30 minutes goes back to the agent on the visitor's next message.

**Scopes:** `chat-widgets:write` — [full detail](./chat-widgets/post-chat-widgets-widget-id-sessions-session-id-take-over.md)

### PATCH /chat-widgets/:widget_id

Change a Live Chat widget: pause it, change its knowledge bases, allowed websites, rules text, tone of voice, wording or limits.

**Scopes:** `chat-widgets:write` — [full detail](./chat-widgets/patch-chat-widgets-widget-id.md)
