Create a web chat
SDK platic.webchats.create()
Create and publish a web chat. The response includes embed.script for your HTML. With mode set to page or both, it also includes the page link in embed.pageUrl.
Example
curl https://api.platic.ai/v1/webchats \
-H "Authorization: Bearer $PLATIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "name": "Support", "agentId": "'"$AGENT_ID"'", "allowedDomains": ["example.com"] }' await platic.webchats.create({ name: "Support", agentId: "agent_123", allowedDomains: ["example.com"] }); Query parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
workspace | string | Only if your credential has several workspaces: which one to create it in | — |
Request body
| Field | Type | Description | Required |
|---|---|---|---|
name | string | 1 to 200 characters. It is also the assistant name the visitor sees, until you change config.content.assistantName | ✓ |
agentId | string | null | The agent that answers its conversations. If you omit it, it is left without an agent | — |
mode | string | embed (on your site), page (on a Platica page), or both. Defaults to both | — |
allowedDomains | string[] | The domains where the chat may open, up to 50. Platica stores them lowercase, without protocol, without path, and without duplicates. It accepts *.example.com and localhost:5173. Without domains, it does not open on any site | — |
config | object | Only what you want different from the defaults. See the configuration | — |
If you send domains and do not send config.behavior.displayRules, the chat appears on all pages of those domains.
{
"name": "Acme Store",
"agentId": "tVKljCHCNiebQdasHeit",
"allowedDomains": ["example.com"]
} Response
201 Created. data is the web chat, already published.
{
"status": "success",
"message": "Web chat created and published",
"data": {
"id": "wc-7Hq2LmN4pR8sT1vX",
"name": "Acme Store",
"agentId": "tVKljCHCNiebQdasHeit",
"mode": "both",
"allowedDomains": ["example.com"],
"config": {
"enabled": true,
"content": {
"assistantName": "Acme Store",
"welcomeTitle": "¿En qué podemos ayudarte?",
"welcomeMessage": "Inicia una conversación con nuestro equipo.",
"placeholder": "Escribe un mensaje…",
"onlineLabel": "En línea",
"offlineLabel": "Fuera de horario",
"offlineMessage": "Estamos fuera de horario. Déjanos un mensaje y te responderemos pronto.",
"prechatTitle": "Antes de comenzar",
"startButtonLabel": "Iniciar conversación"
},
"behavior": {
"rememberOpen": false,
"displayRules": [{ "domain": "example.com", "includePaths": ["/**"], "excludePaths": [] }]
}
},
"published": true,
"hasUnpublishedChanges": false,
"embed": {
"publicKey": "wc_pub_7Hq2LmN4pR8sT1vX",
"script": "<script\n src=\"https://chat.platica.mx/widget.js\"\n data-webchat=\"wc_pub_7Hq2LmN4pR8sT1vX\"\n defer>\n</script>",
"inline": "<div id=\"platica-chat\"></div>\n\n<script\n src=\"https://chat.platica.mx/widget.js\"\n data-webchat=\"wc_pub_7Hq2LmN4pR8sT1vX\"\n data-target=\"#platica-chat\"\n defer>\n</script>",
"pageUrl": "https://chat.platica.mx/chat?webchat=wc_pub_7Hq2LmN4pR8sT1vX"
},
"health": { "state": "ok", "reason": null, "since": "2026-11-12T18:30:00.000Z" },
"creationDate": "2026-11-12T18:30:00.000Z",
"lastUpdate": "2026-11-12T18:30:00.000Z",
"nextStep": "Created and published. Paste embed.script in the site's HTML, before </body>; embed.inline puts the chat inside a container of the page instead. Share embed.pageUrl, or open it to try the chat."
}
} Save the id to edit and publish the web chat. The config example is partial; the response includes all twelve sections. See the fields in get a web chat.
Visitor-facing texts default to Spanish. content.assistantName takes the name you sent, and behavior.displayRules has one rule per domain. The other values shown are defaults.
{
"enabled": true,
"interactiveResponses": { "enabled": false, "tokens": { "carousel": { "enabled": true } } },
"attachments": {
"enabled": true,
"maxFiles": 16,
"maxFileBytes": 5242880,
"maxMessageBytes": 15728640,
"acceptedTypes": ["image/jpeg", "image/png", "image/webp"],
"documents": {
"enabled": false,
"maxFileBytes": 10485760,
"acceptedTypes": [
"application/pdf",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"text/markdown",
"text/plain",
"text/csv"
]
},
"audio": {
"enabled": false,
"maxFileBytes": 10485760,
"acceptedTypes": ["audio/mpeg", "audio/mp4", "audio/ogg", "audio/wav", "audio/webm"]
},
"voiceNotes": { "enabled": false, "maxDurationSeconds": 180 }
},
"launcher": {
"position": "bottom-right",
"shape": "rounded",
"size": 56,
"radius": 14,
"offsetX": 20,
"offsetY": 20,
"backgroundColor": "#333533",
"iconColor": "#ffffff",
"iconAlt": "Abrir chat",
"ariaLabel": "Abrir chat",
"shadow": true,
"pulse": false,
"badge": { "enabled": false, "count": 1, "backgroundColor": "#ef4444", "textColor": "#ffffff" }
},
"window": {
"path": "/help/chat",
"width": 390,
"height": 720,
"gap": 12,
"mobileBreakpoint": 560,
"zIndex": 2147483000,
"allowFullscreen": true
},
"inline": { "height": 680, "minHeight": 480, "border": true, "shadow": false },
"appearance": {
"mode": "light",
"primary": "#00C577",
"radius": 16,
"font": "system",
"colors": {
"canvas": "#f7f8f5",
"surface": "#ffffff",
"surfaceMuted": "#f4f5f1",
"text": "#343434",
"textMuted": "#666666",
"border": "#111111",
"headerBackground": "#ffffff",
"headerText": "#343434",
"headerIcons": "#666666",
"visitorBackground": "#eef0e9",
"visitorText": "#343434",
"composerBackground": "#ffffff",
"composerInput": "#ffffff",
"sendBackground": "#00C577",
"sendIcon": "#111111",
"error": "#ef4444",
"online": "#00C577"
},
"visualEffects": { "enabled": true, "intensity": 60, "blur": 80, "motion": true }
},
"content": {
"assistantName": "Acme Store",
"welcomeTitle": "¿En qué podemos ayudarte?",
"welcomeMessage": "Inicia una conversación con nuestro equipo.",
"placeholder": "Escribe un mensaje…",
"onlineLabel": "En línea",
"offlineLabel": "Fuera de horario",
"offlineMessage": "Estamos fuera de horario. Déjanos un mensaje y te responderemos pronto.",
"prechatTitle": "Antes de comenzar",
"startButtonLabel": "Iniciar conversación"
},
"suggestedMessages": {
"enabled": false,
"title": "¿Cómo podemos ayudarte?",
"subtitle": "Elige una opción para comenzar.",
"startConversationLabel": "Iniciar una conversación",
"logoAlt": "Logo de la empresa",
"cards": []
},
"prechat": {
"enabled": false,
"pageTitle": "Antes de comenzar",
"pageSubtitle": "Comparte tus datos para ofrecerte una mejor atención.",
"requestName": true,
"requestEmail": true,
"requestPhone": false,
"fields": [
{ "id": "name", "type": "text", "label": "Nombre", "placeholder": "Tu nombre", "required": true, "width": "full" },
{ "id": "email", "type": "email", "label": "Email", "placeholder": "tu@email.com", "required": true, "width": "full" }
]
},
"availability": { "status": "online" },
"behavior": {
"rememberOpen": false,
"displayRules": [{ "domain": "example.com", "includePaths": ["/**"], "excludePaths": [] }]
}
} Errors
| Status | details.code | When it happens |
|---|---|---|
400 | INVALID_REQUEST | name is missing, there is an extra field, a domain or mode is not valid, or config has something outside what is allowed. details.issues says which field |
403 | FORBIDDEN | The credential does not have write permission on Integrations, or the agent is not within its reach |
404 | AGENT_NOT_FOUND | The agentId agent does not exist |
503 | WEBCHAT_SERVICE_UNAVAILABLE, WEBCHAT_SERVICE_TIMEOUT | The web chat service did not respond |
Warning
If you get a 503, list your web chats before retrying: the web chat may have been created.
Notes
- Paste
embed.scriptin your site's HTML, before</body>. The other forms are in embed it on your site. - The web chat also appears in list channels, with the same
id. - Needs a workspace API key, or an OAuth token with write access to Integrations and the
platica:writescope.