Skip to content

client.client_tokens

Short-lived tokens that let a browser start one call. These methods are on client.client_tokens, where client is a MoreVoice client (see the Python SDK). On AsyncMoreVoice the same methods are awaited. Each one returns the response object and raises an exception when the API answers with an error.

Create a client token. Mint, on your server, a short-lived token a browser uses to start one call to one assistant with @morevoice/web (MoreVoiceWeb.start({ token })). The token works once, until expires_at; bind it to your site with origin. It carries the call’s ID, so you can follow the call (webhooks, GET /v1/calls/{id}/events) before it starts.

client.client_tokens
def create(self, body: _m.ClientTokenCreateParamsInput | Mapping[str, Any] | Unset = UNSET, *, more_voice_version: str | Unset = UNSET, idempotency_key: str | Unset = UNSET) -> _m.ClientToken

client.client_tokens.create() · await async_client.client_tokens.create() · POST /client_tokens · API reference

Field Type Required Description
agent_user_id string no The agent whose softphone the token opens (the embeddable softphone; /ws/call refuses agent tokens).
assistant_id string no The assistant the browser will talk to.
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.
origin string no The only website the token works from (https://shop.example): the browser’s Origin must match. Strongly recommended. http is accepted for localhost only.
ttl_s integer no How long the token can be used to start the call, in seconds (300–900, default 300). The call itself may run longer.

ClientToken:

Field Type Description
object "client_token" Always client_token.
token string The client token (a signed JWT). Give it to the browser; it opens one call, once, before expires_at.
expires_at string An ISO-8601 timestamp in UTC.
call_id string The call the token opens (the same ID the call will have).
assistant_id string | null asst_… ID.
agent_user_id string | null usr_… ID.
origin string | null The website the token is bound to, or null.
livemode boolean true in live mode, false in test mode.
ws_url string Where the browser connects: <ws_url>?client_token=<token> (the @morevoice/web SDK does it for you).
from morevoice import MoreVoice
client = MoreVoice() # MOREVOICE_API_KEY from the environment
client_token = client.client_tokens.create({
"assistant_id": "asst_8tRPaZp5hLMbrGqdJ9AmNa",
"metadata": {
"crm_contact_id": "0031x00000AbCdE",
},
"origin": "https://shop.example",
"ttl_s": 300,
})
print(client_token)