> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developers.zorvia.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.zorvia.io/_mcp/server.

# JavaScript API

> Control the Zorvia Messenger widget from your application.

The web SDK exposes `window.zorvia` after its script loads.

## `init(config)`

Initializes and mounts Messenger. It returns a promise.

```js
await window.zorvia.init({
  workspaceUrl: "https://{workspace}.zorvia.io",
  livechatKey: "YOUR_PUBLIC_MESSENGER_KEY",
});
```

Required configuration:

| Option         | Type     | Description                                                         |
| -------------- | -------- | ------------------------------------------------------------------- |
| `workspaceUrl` | `string` | Your Zorvia workspace URL, such as `https://{workspace}.zorvia.io`. |
| `livechatKey`  | `string` | The channel's public messenger key.                                 |

## `open()` and `close()`

Programmatically control the Messenger panel:

```js
window.zorvia.open();
window.zorvia.close();
```

## `identify(data)`

Associates the active visitor session with a server-signed identity. It returns a promise. Follow the [visitor identification flow](/zorvia-messenger/identity-verification) to create the signed payload.

## `destroy()`

Disconnects real-time updates, unmounts Messenger, and removes its container:

```js
window.zorvia.destroy();
```

## Errors

Rejected `init()` and `identify()` promises use a `ZorviaError` with `code`, `operation`, and an optional `statusCode`.

* **`configuration_error`** — A required SDK configuration value is missing or invalid.
* **`authentication_error`** — The public messenger key could not be authenticated. The status code is `401`.
* **`forbidden`** — The current domain is not allowed to use the Zorvia Messenger channel. The status code is `403`.
* **`validation_error`** — The request sent by the SDK failed validation. The status code is `422`.
* **`network_error`** — The SDK could not reach Zorvia, or Zorvia returned a server error.
* **`initialization_failed`** — Zorvia Messenger could not initialize.
* **`identification_failed`** — The SDK could not identify the visitor.
* **`unknown_error`** — An unexpected error occurred.