> ## Documentation Index
> Fetch the complete documentation index at: https://wiz-myvocal.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a browser ticket

> Exchange the accessKey for a short-lived, single-use socket ticket.

Issues a short-lived ticket for one owned session so a browser can open the socket without exposing
the long-lived key in a URL. The ticket is single-use and bound to the owner and the session; a
reconnect requests a fresh one. A replayed or expired ticket is refused at the handshake.

### Path

<ParamField path="sessionId" type="string" required>
  The session to stream to.
</ParamField>

### Header

<ParamField header="accessKey" type="string" required>
  API key for this REST request. Keep it on your backend in customer-facing applications;
  return only the session and ticket to the browser. Never put the API key in the socket URL.
</ParamField>

### Response

Successful REST calls return `{ code: 1, message, data }`. The fields below are inside `data`;
JSON downloads are the documented exception and return the transcript view directly.

<ResponseField name="code" type="number">`1` for success.</ResponseField>
<ResponseField name="message" type="string">Result message.</ResponseField>

<ResponseField name="data" type="object">
  <Expandable title="properties" defaultOpen>
    <ResponseField name="ticketId" type="string">
      The public ticket id (`rtt_...`).
    </ResponseField>

    <ResponseField name="sessionId" type="string">
      The bound session.
    </ResponseField>

    <ResponseField name="streamUrl" type="string">
      The socket path to connect.
    </ResponseField>

    <ResponseField name="expiresInSeconds" type="number">
      The ticket lifetime in seconds.
    </ResponseField>

    <ResponseField name="ticket" type="string">
      The plaintext ticket. It is returned exactly once; only its hash is stored.
    </ResponseField>
  </Expandable>
</ResponseField>

```js theme={null}
const ticket = await rest('POST', `/sessions/${sessionId}/tickets`);
const url = new URL(apiBase + ticket.streamUrl);
url.protocol = url.protocol === 'https:' ? 'wss:' : 'ws:';
url.searchParams.set('ticket', ticket.ticket);
const socket = new WebSocket(url);
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.