This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/dws-viewer/developer-guides/open-client-provided-documents.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. 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 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 and omit allowed_documents from the request body:

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():

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.

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().