---
title: "Open app-provided documents in Web SDK"
canonical_url: "https://www.nutrient.io/guides/dws-viewer/developer-guides/open-client-provided-documents/"
md_url: "https://www.nutrient.io/guides/dws-viewer/developer-guides/open-client-provided-documents.md"
last_updated: "2026-06-10T00:00:00.000Z"
description: "Open documents from your app or browser in Nutrient Web SDK using DWS Viewer API session authorization."
---

# Open app-provided documents in Web SDK

Use this flow when your browser app already has a document and you want DWS Viewer API to authorize the viewer session. The document can come from a local file picker, a URL your app controls, a Blob, an ArrayBuffer, or another source supported by Nutrient Web SDK.

In this app-provided flow, the document isn’t uploaded to DWS as a managed document. Your backend creates a DWS Viewer API session, and your frontend passes both the session and the document to `NutrientViewer.load()`.

Use [upload documents](https://www.nutrient.io/guides/dws-viewer/developer-guides/upload-documents.md) instead if you want Nutrient infrastructure to store, stream, and manage the document as a DWS-managed document.

This flow still requires a backend today. Public API keys for backendless DWS Viewer API integrations are a separate future feature.

## Create a browser session

On your backend, create a session with [`POST /viewer/sessions`](https://www.nutrient.io/api/reference/viewer/public/#tag/Authorization/operation/generate-session-token) and omit `allowed_documents` from the request body:

```js

const response = await fetch("https://api.nutrient.io/viewer/sessions", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Authorization: `Bearer ${process.env.NUTRIENT_DWS_VIEWER_API_KEY}`,
  },
  body: JSON.stringify({}),
});

if (!response.ok) {
  throw new Error(`Session creation failed: ${response.statusText}`);
}

const { jwt } = await response.json();

```

## Load the document in Web SDK

In the browser, pass the session token and the document to `NutrientViewer.load()`:

```js

await NutrientViewer.load({
  container: "#viewer",

  session: "<session_token>",
  document: "/documents/example.pdf",
});

```

Omit `licenseKey` for this flow. The DWS Viewer API session authorizes the viewer load.

The `document` option accepts the same input types supported by Web SDK, including URLs, Blobs, ArrayBuffers, Base64 data, and local files selected by the user. For details, refer to the [Web SDK open document guides](https://www.nutrient.io/guides/web/open-a-document.md).

## Quota behavior

Each successful app-provided document load consumes one viewer session, drawn from the same monthly viewer-session quota as DWS-managed documents.

App-provided documents don’t consume DWS document upload, storage, or document-count quota because they aren’t stored as DWS-managed documents.

## Limitations

- The session must be created by your backend today.

- `setSession()` isn’t supported for DWS Viewer API document loading when the document is provided by your app.

- The session isn’t refreshed after load. If your app needs a fresh session, unload and load the viewer again with a new session.

- Your app is responsible for controlling access to the document source it passes to Web SDK.

## Existing integrations

Existing integrations that already issue DWS Viewer API frontend sessions can also authorize app-provided document loading for compatibility. New integrations should create a browser session by omitting `allowed_documents`.

## Troubleshooting

- If session creation fails, verify the API key is sent from your backend and not exposed to the browser.

- If viewer loading fails with an authorization error, verify the browser origin is allowed for the DWS Viewer API application.

- If viewer loading fails with a quota or session-limit error, check the DWS dashboard usage for the application.

- If Web SDK asks for a license key, remove `licenseKey` and make sure both `session` and `document` are passed to `NutrientViewer.load()`.
---

## Related pages

- [Architecture of DWS Viewer API integration](/guides/dws-viewer/developer-guides/architecture.md)
- [DWS Viewer API backend authentication](/guides/dws-viewer/developer-guides/backend-authentication.md)
- [Implement collaboration and synchronization with DWS Viewer API](/guides/dws-viewer/developer-guides/implement-collaboration-and-synchronization-with-dws-viewer-api.md)
- [Choose the right collaboration and synchronization setup](/guides/dws-viewer/developer-guides/choose-the-right-collaboration-and-synchronization-setup.md)
- [Generate a session token](/guides/dws-viewer/developer-guides/generate-a-session-token.md)
- [Dashboard](/guides/dws-viewer/developer-guides/dashboard.md)
- [Choose the right document opening and loading setup](/guides/dws-viewer/developer-guides/choose-the-right-document-opening-and-loading-setup.md)
- [DWS Viewer API developer guides](/guides/dws-viewer/developer-guides.md)
- [Deployment options](/guides/dws-viewer/developer-guides/deployment-options.md)
- [Upload documents](/guides/dws-viewer/developer-guides/upload-documents.md)
- [Open DWS-managed documents in Web SDK](/guides/dws-viewer/developer-guides/open-a-document-in-web.md)
- [DWS Viewer API client authentication flow](/guides/dws-viewer/developer-guides/client-authentication-flow.md)
- [Integrate DWS Viewer API with your own backend](/guides/dws-viewer/developer-guides/use-with-your-backend.md)
- [Reviewer-isolated layers](/guides/dws-viewer/developer-guides/reviewer-isolated-layers.md)

