# POST /chat-widgets

**Resource:** [CHAT_WIDGETS](./chat-widgets.md)  
**MCP tool:** `create_chat_widget`  
**Scopes:** `chat-widgets:write`  
**Write operation:** yes

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.

## Parameters

| Name | In | Type | Required | Description |
|------|----|------|----------|-------------|
| `name` | body | string | yes | A name for the widget, for your own list (1 to 120 characters). |
| `status` | body | string | no | active answers visitors. paused stops the chat on the website without deleting anything. |
| `allowed_origins` | body | array | no | Website hostnames that may show the chat, such as www.example.com. Whole hostnames only: no wildcards, ports or paths. The chat refuses to start on any other site. |
| `kb_ids` | body | array | yes | Ids of the knowledge bases the chat answers from. At least one. The chat answers only from these and says it cannot help when nothing matches. |
| `show_in_client_portal` | body | boolean | no | Default false. When true, this chat also shows in your Client Portals (the pages your clients sign in to): a signed-in client is already known, so the chat never asks for their name or mobile. Only one chat per workspace is the Client Portal default: turning it on here turns it off on your other chats. A single portal can pick a different chat in its own settings. A chat shown only in portals needs no website in allowed_origins. |
| `website_id` | body | string | no | Optional: the TrustPager website this chat belongs to. The chat does not need one. Send null to clear. |
| `rules_text` | body | string | no | Plain-words rules for Urgent, Priority and Standard, for example which kinds of enquiry count as Urgent, such as a visitor who needs a quote today (up to 8000 characters). Treated as data: it can raise a level, never lower the built-in safety floor. |
| `tone` | body | string | no | The bot's tone of voice, how its text replies are worded (not spoken audio). One of: friendly, professional, casual, direct, warm. New widgets start on friendly. A widget created before this setting has none and keeps its original wording until you set one. |
| `tone_notes` | body | string | no | Optional extra notes on wording style, for example "Use the customer's first name" (up to 300 characters). They only shape the wording and can never change the chat's safety rules or make it answer from outside the knowledge bases. |
| `profile` | body | string | no | Which built-in rules sort the chats: sales or insolvency. sales (the default, also for a widget that never set one): a visitor ready to buy, needing a quote today or with an order problem is Urgent. insolvency: for business advisory and insolvency firms; a Director Penalty Notice, statutory demand, bankruptcy notice, court date or garnishee, or a letter from the ATO, ASIC or a court, is always Urgent with its own reason_code, and the date question asks for the date on the letter (still stored as letter_date). Welfare is always first on both. Send sales to go back to the default. |
| `urgency_rules` | body | object | no | Optional urgency words: { disabled_rule_ids: string[], custom: [{ id, phrase, level: urgent or priority }] }. Null restores all built-in floors. Get a widget to read urgency_rule_catalog for its profile. Phrases are literal whole words or phrases, not patterns; trim and collapse spaces. At most 50, each 1 to 80 characters containing a letter or digit, with no case-insensitive duplicates. Disabling a floor does not stop TrustPager AI from raising urgency on its own. |
| `cost_questions_standard` | body | boolean | no | Default false. When true, a plain question about prices, fees or costs (for example "How much do you charge?") stays Standard instead of being raised to Priority, so it is answered without asking for details. It never lowers an Urgent chat or a welfare chat. |
| `opening_prompt` | body | string | no | The first line the visitor sees. |
| `opening_buttons` | body | array | no | Quick-start buttons: a list of { label, seed_message }. Up to 6. |
| `refusal_text` | body | string | no | What the chat says when the knowledge bases have nothing relevant. Empty uses the built-in wording. |
| `handoff_text` | body | string | no | What the chat says to point the visitor to a person. Empty uses the built-in wording. |
| `capture_fields` | body | object | no | Which details to ask for on an Urgent chat: { first_name, mobile, letter_date }, each true or false. letter_date is the date the visitor wants to hear back by or needs this done by; on the insolvency profile it is the date on the letter (the key keeps its old name so saved chats and automations still work). Optional ask_on_priority (default false): also offer the details to a Priority visitor, and fire website_chat_completed once more when their mobile arrives. |
| `appearance` | body | object | no | Look and feel. Sending appearance replaces the whole object, so send every setting you want to keep. brand_color (#rrggbb, the main colour, also used for links and borders). brand_gradient (optional, 2 or 3 #rrggbb colours: the header, launcher, Send button and visitor bubbles use the gradient instead of the flat colour). font (one of: system, Inter, Geist, DM Sans, Plus Jakarta Sans, Manrope, Poppins, Montserrat, Nunito, Open Sans, Roboto, Lato, Work Sans, Outfit, Figtree; system is the visitor's own font). position (bottom-right or bottom-left). launcher_style (icon: a round chat button, the default; label: the icon plus launcher_label). launcher_label (text on the launcher when launcher_style is label). header_title (the name at the top of the chat). header_subtitle (the small line under the name; default "Usually replies in seconds"). avatar_url (https image shown as the chat's picture). team_label (first_name or team). botcheck (standard or strict). |
| `daily_llm_cap_credits` | body | number | no | Most AI credits the widget may spend in one day (0 to 1,000,000). At 80 percent your team is told once. At the cap the chat stops answering with AI but still records leads. |
| `daily_trigger_cap` | body | number | no | Most automation fires per day (0 to 1,000). Over it, leads are still created; only the SMS side is switched off. |
| `max_messages_per_session` | body | number | no | Most visitor messages in one chat (1 to 200). |
| `retention_days` | body | number | no | How many days a chat is kept before the daily clean-up erases it (7 to 365, default 90). Erasing removes the messages and the personal details and keeps only a record of counts and level. |
| `require_approval` | body | boolean | no | Optional. Set true to route this write into the approval queue for human review instead of executing it immediately (returns 202 + an approval_id). Works even when your key/token has permission to execute directly. |

## Request example

```bash
curl -X POST   "https://api.trustpager.com/functions/v1/api/v1/chat-widgets"   -H "Authorization: Bearer YOUR_API_KEY"   -H "Content-Type: application/json"   -d '{"name":"...","status":"...","allowed_origins":"..."}'
```

---
Base URL: `https://api.trustpager.com/functions/v1/api/v1` — Auth: `Authorization: Bearer YOUR_API_KEY`