---
docId: doc_148135694f484acdbb45d3062204e22d
title: Update a web chat
description: "Update a web chat and save settings changes in its draft."
api:
  group: canales/webchat
  auth: bearer
  operations:
    - operationId: updateWebchat
      method: PATCH
      path: '/v1/webchats/{webchatId}'
      postmanName: Update a web chat
---

<script>
  import { Ways, Note } from '$lib/components';
</script>

# Update a web chat

Update the web chat fields you send:

- `name`, `agentId`, `mode`, and `allowedDomains` apply right away.
- `config` changes are saved in the draft. Your site shows them when you [publish](/api-reference/web-chats/publish).

## Example

<Ways tabs="api,sdk">
<Ways.Way name="api">

```bash
curl -X PATCH https://api.platic.ai/v1/webchats/$WEBCHAT_ID \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "config": { "content": { "welcomeTitle": "How can we help?" } } }'
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
await platic.webchats.update("webchat_123", { config: { content: { welcomeTitle: "How can we help?" } } });
```

</Ways.Way>
</Ways>

## Path parameters

| Parameter | Type | Description | Required |
|-----------|------|-------------|----------|
| `webchatId` | string | Web chat id (`wc-…`) | ✓ |

## Query parameters

| Parameter | Type | Description | Required |
|-----------|------|-------------|----------|
| `workspace` | string | Only if your credential has several workspaces: which one the web chat is in | — |

## Request body

Send at least one.

| Field | Type | Description | When it applies |
|-------|------|-------------|-----------------|
| `name` | string | Name of the web chat, 1 to 200 characters. It is only seen in Platica: what the visitor sees is `config.content.assistantName` | Right away |
| `agentId` | string \| null | The agent that answers its conversations. `null` leaves it without an agent | Right away: the next conversation is already answered by that agent |
| `mode` | string | `embed`, `page`, or `both` | Right away. `embed` changes in the same response |
| `allowedDomains` | string[] | The domains where the chat may open. Replaces the whole list | Right away |
| `config` | object | Only the parts that change. See [the configuration](/api-reference/web-chats#the-configuration) | When you publish |

In `config`, objects are merged with what is already there, lists are replaced whole, and `null` removes an optional field.

Change the main color and the greeting:

```json
{
  "config": {
    "appearance": { "primary": "#E4572E" },
    "content": { "welcomeTitle": "Hi! Looking for anything in particular?" }
  }
}
```

### If you change the domains

Display rules (`config.behavior.displayRules`) apply per domain. If you change `allowedDomains` without sending rules, Platica adjusts the draft:

- It keeps the rule of each domain that stays in the list.
- It adds one for each new domain, covering all its pages.

Domains apply right away, but those rules wait for you to publish. With `mode: "page"` they are not touched.

## Response

`data` is the web chat. When you changed `config`, `hasUnpublishedChanges` is `true` and `message` says so.

```json
{
  "status": "success",
  "message": "Web chat saved; the changes to config are not published",
  "data": {
    "id": "wc-7Hq2LmN4pR8sT1vX",
    "name": "Acme Store",
    "agentId": "tVKljCHCNiebQdasHeit",
    "mode": "both",
    "allowedDomains": ["example.com"],
    "config": {
      "enabled": true,
      "content": {
        "assistantName": "Acme Store",
        "welcomeTitle": "Hi! Looking for anything in particular?",
        "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"
      },
      "availability": { "status": "online" }
    },
    "published": true,
    "hasUnpublishedChanges": true,
    "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-12T19:05:00.000Z",
    "nextStep": "Saved. name, agentId, mode and allowedDomains already apply; the changes to config wait until you publish with POST /v1/webchats/wc-7Hq2LmN4pR8sT1vX/publish."
  }
}
```

The example shows only three parts of `config`; the response has all twelve. The fields are in [get a web chat](/api-reference/web-chats/get#response-fields).

If you send the values it already has, the response returns the unchanged web chat.

## Errors

| Status | `details.code` | When it happens |
|--------|----------------|-----------------|
| `400` | `INVALID_REQUEST` | You sent no field, there is an extra one, or one is not valid. Also if an image in `config` could not be processed. `details.issues` says which |
| `403` | `FORBIDDEN` | The credential does not have write permission on Integrations, or the agent is not within its reach |
| `404` | `WEBCHAT_NOT_FOUND` | The web chat does not exist in this workspace |
| `404` | `AGENT_NOT_FOUND` | The `agentId` agent does not exist |
| `409` | `WEBCHAT_CONFLICT` | The web chat does not accept that change in its current state |
| `503` | `WEBCHAT_SERVICE_UNAVAILABLE`, `WEBCHAT_SERVICE_TIMEOUT` | The web chat service did not respond. [Get the web chat](/api-reference/web-chats/get) to see whether the change was saved |

For example, if you send a field that does not exist, such as `color`:

```json
{
  "code": 400,
  "error": "Bad Request - The request has validation errors",
  "details": {
    "code": "INVALID_REQUEST",
    "message": "The change is not valid.",
    "issues": [
      { "path": "color", "code": "unrecognized_keys", "message": "Unknown field." }
    ]
  }
}
```

<Note type="tip">

If two `config` changes arrive at the same time, the last one wins. Make changes one at a time.

</Note>

## Notes

- `update` does not turn the web chat off or on. To turn it off, [disconnect the channel](/api-reference/channels/disconnect). To turn it on, [publish it](/api-reference/web-chats/publish).
- To pause it from the configuration, send `config.enabled: false` and publish.
- Needs a workspace API key, or an OAuth token with write access to Integrations and the `platica:write` scope.
