> ## Documentation Index
> Fetch the complete documentation index at: https://docs.quarterzip.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# API Reference

> SDK API reference and environment requirements

## `Quarterzip.open()`

Triggers the agent. Creates a mini-player on the page — the call does not begin until the user clicks **Join**.

```javascript theme={null}
window.Quarterzip.open({
  workspaceToken: 'YOUR_WORKSPACE_TOKEN',
  agentId: 'YOUR_AGENT_ID',
  user: {
    email: 'jane@company.com',
  	displayName: 'Jane Smith',
    id: 'your_internal_user_id'
  },
  context: 'Plan: Pro. Country: Germany. Handed over from Intercom.'
})
```

| Parameter          | Required | Description                                                                   | Type   |
| :----------------- | :------- | :---------------------------------------------------------------------------- | :----- |
| `workspaceToken`   | Yes      | Use the workspace token provided by Quarterzip.                               | String |
| `agentId`          | Yes      | The agent's ID which can be copied from the Quarterzip app                    | String |
| `user`             | Yes      | The user who will join the call                                               | Object |
| `user.email`       | Yes      | End user's email address                                                      | String |
| `user.displayName` | Yes      | End user's display name                                                       | String |
| `user.id`          | Yes      | Your unique internal user identifier                                          | String |
| `context`          | No       | Additional context passed to the agent during the call. Max 2,000 characters. | String |

## `Quarterzip.close()`

In the event where an in-progress call should be cancelled without the user’s input,`.close()` can be called. This ends the active call (if any), tears down the UI, and cleans up all resources.

```javascript theme={null}
window.Quarterzip.close();
```

## Restricting usage by origin

Enable domain restriction in the Quarterzip app to validate the `origin` header on each SDK request. When enabled, only calls originating from your specified domains will be allowed.

***

## Device requirements

Quarterzip uses the `getDisplayMedia()` web API for screen sharing, which is not available on most mobile devices. Guard against unsupported environments with:

```javascript theme={null}
const canUseQuarterzip = !!(navigator.mediaDevices?.getDisplayMedia);
```

***

## SPA routing

The SDK maintains an active WebRTC connection tied to the current page lifecycle. A full page reload — from the user refreshing the browser, calling `window.location.reload()`, or navigating in a multi-page app — will immediately drop the call. There is no automatic reconnection; the user must rejoin. The SDK should only be used within a single-page application (SPA) where navigation is handled client-side.

***

## CSP Directives

### `script-src`

Ensure the following origin is included. Nonce-based inline execution with `static-dynamic` is recommended; `unsafe-inline` may be used if not viable.

| `https://*.quarterzip.ai` | Quarterzip SDK |
| :------------------------ | :------------- |

### `connect-src`

| `https://*.quarterzip.ai`                                                          | Quarterzip API requests      |
| :--------------------------------------------------------------------------------- | :--------------------------- |
| `https://*.daily.co`<br />`wss://*.daily.co`                                       | Call transport layer         |
| `https://firestore.googleapis.com`<br />`https://firebasestorage.googleapis.com`   | Database operations          |
| `https://*.firebaseio.com`<br />`wss://*.firebaseio.com`                           | Firestore realtime listeners |
| `https://securetoken.googleapis.com`<br />`https://identitytoolkit.googleapis.com` | User auth                    |
| `https://storage.googleapis.com`                                                   | CDN                          |

***

## Permissions-Policy

If your site defines a `Permissions-Policy` header (or `<iframe allow>` attribute), these directives must be set:

* `microphone` — Required for audio capture
* `display-capture` — Required for screen sharing
* `speaker-selection` — Required for audio output selection
