# mv.webCalls

> The webCalls methods of @morevoice/sdk: Browser calls started with a publishable key.

Browser calls started with a publishable key. These methods are on `mv.webCalls`, where `mv` is your client (see [the Node.js SDK](https://docs.morevoice.ai/sdk/node/#connect)). Each one returns the response object and throws when the API answers with an error.

## `create()`

**Start a web call.** From the browser with a publishable key (`mv_live_pk_…`), or from your server with a secret key: returns the call ID and a single-use client token for `/ws/call`. With a publishable key the assistant must be public, the page must be one of the key's allowed origins (and of the assistant's widget origins, when it lists any), and each visitor may start 10 web calls a minute. The org's concurrent-call quota applies.

```ts
mv.webCalls.create(body: WebCallsCreateData["body"], options?: RequestOptions): Promise<WebCallsCreateResponse>
```

`POST /web_calls` · [API reference](https://docs.morevoice.ai/api/operations/web_calls_create/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `body.assistant_id` | `string` | yes | The assistant to talk to. With a publishable key it must be public (widget settings). |
| `body.metadata` | `MetadataInput` | no | Up to 50 key/value pairs (keys up to 40 characters, values up to 500) you attach to an object. Returned as sent. |
| `options.headers["MoreVoice-Version"]` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |
| `options.headers["Idempotency-Key"]` | `string` | no | A unique key (for example a UUID) that makes this request safe to retry: for 24 hours, a retry with the same key and parameters returns the first response instead of acting twice. |
| `options` | `RequestOptions` | no | `idempotencyKey`, extra `headers` and an abort `signal`: see [retries and idempotency](https://docs.morevoice.ai/sdk/typescript/retries/). |

### Returns

`WebCall`:

| Field | Type | Description |
| --- | --- | --- |
| `object` | `"web_call"` | Always `web_call`. |
| `call_id` | `string` | The call this web call will be (GET /v1/calls/{id} once it starts). |
| `assistant_id` | `string` | A assistant ID (prefix `asst_`). |
| `client_token` | `string` | Single use; connect within `expires_at`. |
| `ws_url` | `string` | Connect to `<ws_url>?client_token=<client_token>`. |
| `expires_at` | `string` | An ISO-8601 timestamp in UTC. |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |

### Example

```ts
import MoreVoice from "@morevoice/sdk";

const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment

const webCall = await mv.webCalls.create({
	assistant_id: "asst_8tRPaZp5hLMbrGqdJ9AmNa",
	metadata: {
		page: "/pricing",
	},
});
console.log(webCall);
```
