{"slug":"dws-viewer-api","title":"dws-viewer-api","summary":"Upload documents to Nutrient-managed cloud storage and mint browser viewer session JWTs via the Nutrient DWS Viewer API (cloud-hosted document viewing). Use when the user wants to embed a document viewer backed by the cloud, mint a viewer session token, add annotation/forms/signi","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-11-29T00:42:57.152233Z","repo":{"url":"https://github.com/PSPDFKit-labs/nutrient-skills","stars":18,"forks":1,"license":null,"updatedAt":"2026-11-26T02:45:46Z"},"bodyHtml":"<hr>\n<h2>name: dws-viewer-api\ndescription: &gt;-\nUpload documents to Nutrient-managed cloud storage and mint browser viewer session JWTs via the\nNutrient DWS Viewer API (cloud-hosted document viewing). Use when the user wants to embed a\ndocument viewer backed by the cloud, mint a viewer session token, add annotation/forms/signing or\nreal-time collaboration without running server infrastructure. Triggers include DWS Viewer API,\ncloud viewer, viewer session JWT, mint a viewer session, embed a PDF viewer with a session,\nannotation sync, or no-server document viewer. Not for the self-hosted Web SDK\n(<code>@nutrient-sdk/viewer</code> / <code>NutrientViewer.load</code> without a DWS session) — that is <code>nutrient-web-sdk</code>;\nnot for self-hosted annotation persistence — that is <code>nutrient-document-engine</code>.\nwhen_to_use: &gt;-\nTriggers: DWS Viewer API; cloud-hosted document viewer; \"mint/generate a viewer session\"; viewer\nsession JWT or session token handed to the browser; <code>POST /viewer/documents</code> or\n<code>POST /viewer/sessions</code>; embed a PDF viewer backed by Nutrient cloud with no server to run;\nannotation/forms/signing/real-time collaboration via cloud infrastructure; <code>NutrientViewer.load</code>\n<em>with a <code>session:</code> token</em>. Covers the server-side half only: upload to Nutrient storage + session\nmint. Not for the self-hosted WASM viewer, license keys, or React/Vue/Angular embed wiring\n(<code>@nutrient-sdk/viewer</code>, <code>NutrientViewer.load</code> without a DWS session) — those go to\n<code>nutrient-web-sdk</code>; not for self-hosted annotation persistence or data-residency/custom-auth\nbackends — those go to <code>nutrient-document-engine</code>.\nlicense: MIT\nmetadata:\nauthor: nutrient-sdk\nversion: \"1.0\"\nhomepage: \"https://www.nutrient.io/api/viewer-api/\"\nrepository: \"https://github.com/PSPDFKit-labs/nutrient-skills\"\ncompatibility: \"Requires Python 3.10+, uv, and internet. Works with Claude Code, Codex CLI, Gemini CLI, OpenCode, Cursor, Windsurf, GitHub Copilot, Amp, or any Agent Skills-compatible product.\"\nshort-description: \"Upload documents and mint viewer session JWTs via the Nutrient DWS Viewer API\"</h2>\n<h1>Nutrient DWS Viewer API</h1>\n<p>The DWS Viewer API is Nutrient's <strong>cloud-hosted</strong> document viewing service. The flow is three\nserver-side steps: upload a document to Nutrient-managed storage (or reference an app-provided one),\nmint a short-lived session JWT, and hand that JWT to the browser, where the Nutrient Web SDK renders\na full viewer backed by Nutrient infrastructure — storage, streaming, annotation sync, and\ncollaboration, with no viewing/storage servers to run. (You still need a small trusted backend\nor serverless endpoint to mint the session token — the API key must never reach the browser;\nthis skill is exactly that server-side step.)</p>\n<p>This skill covers the <strong>server-side half</strong> — upload and session mint, the part agents get wrong. The\none-line browser embed (<code>NutrientViewer.load({ container, session })</code>) is documented in\n<code>references/embed-guide.md</code>; framework integration belongs to the <code>nutrient-web-sdk</code> skill.</p>\n<h2>When to use</h2>\n<ul>\n<li>\"Embed a PDF viewer for document review/approval in our SaaS app — I don't want to run servers.\"</li>\n<li>\"Add annotation, forms, or signing to a document workflow without hosting infrastructure.\"</li>\n<li>\"Mint a viewer session token / session JWT for the browser.\"</li>\n<li>\"Add multi-user real-time annotation to a document, cloud-backed.\"</li>\n</ul>\n<p>Three Nutrient products show documents in a browser. Pick the right one <strong>before</strong> writing code:</p>\n<table>\n<thead>\n<tr>\n<th>Product</th>\n<th>Infra hosting</th>\n<th>Storage</th>\n<th>Persistence / collab</th>\n<th>Route here when</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><strong>DWS Viewer API</strong> (this skill)</td>\n<td>Nutrient cloud</td>\n<td>Nutrient cloud or app-provided</td>\n<td>Built in</td>\n<td>Cloud-first; no server infra; collab fast</td>\n</tr>\n<tr>\n<td><strong>Nutrient Web SDK</strong> (<code>nutrient-web-sdk</code>)</td>\n<td>Developer (browser WASM)</td>\n<td>Developer's server</td>\n<td>Via Document Engine</td>\n<td>Self-hosted/offline; <code>@nutrient-sdk/viewer</code> embed</td>\n</tr>\n<tr>\n<td><strong>Document Engine</strong> (<code>nutrient-document-engine</code>)</td>\n<td>Developer's server</td>\n<td>Developer's DB</td>\n<td>Yes (server-side)</td>\n<td>Self-hosted persistence; custom auth; data residency</td>\n</tr>\n</tbody>\n</table>\n<ul>\n<li><strong>Route here (DWS Viewer API)</strong> when the user wants a cloud-backed viewer fast, does not want to\nrun servers, or needs annotation persistence / real-time collab out of the box.</li>\n<li><strong>Route to <code>nutrient-web-sdk</code></strong> for the self-hosted WASM viewer, license keys, or\n<code>NutrientViewer.load()</code> / <code>@nutrient-sdk/viewer</code> embed wiring <strong>without</strong> a DWS session.</li>\n<li><strong>Route to <code>nutrient-document-engine</code></strong> for self-hosted annotation persistence or\ndata-residency / custom-auth backends.</li>\n</ul>\n<p>The full comparison and routing rules live in <code>references/viewer-decision-matrix.md</code> (the single\nsource of truth for this disambiguation).</p>\n<h2>Setup</h2>\n<p>The DWS Viewer API is a <strong>separate product</strong> with its own API key — distinct from the Processor key\n(<code>NUTRIENT_API_KEY</code>) and the Extraction key (<code>NUTRIENT_EXTRACT_API_KEY</code>). Do <strong>not</strong> reuse another\nproduct's key here.</p>\n<ul>\n<li>Get a DWS Viewer API key at <a href=\"https://dashboard.nutrient.io/\">https://dashboard.nutrient.io/</a>.</li>\n<li>Export it as <code>NUTRIENT_DWS_VIEWER_API_KEY</code>:\n<pre><code>export NUTRIENT_DWS_VIEWER_API_KEY=\"pdf_live_...\"\n</code></pre>\n</li>\n<li>Run from the directory containing this SKILL.md:\n<pre><code>cd &lt;directory containing this SKILL.md&gt; &amp;&amp; uv run scripts/viewer-session.py --help\n</code></pre>\n</li>\n</ul>\n<p>This skill does <strong>not</strong> silently fall back to <code>NUTRIENT_API_KEY</code>. The Viewer API's wrong-key\nbehavior is unconfirmed, so a silent fallback could mint a real browser session JWT against the\nwrong product/tenant with no signal (a confused-deputy). If your tenant has migrated to a global\nDWS key, opt in explicitly with <code>--allow-global-key</code>, which warns at the point of fallback.</p>\n<h2>Tool preference</h2>\n<ul>\n<li><code>scripts/viewer-session.py</code> — the cloud-side operations (upload, session mint, combined).</li>\n<li><code>references/embed-guide.md</code> — the browser embed (<code>NutrientViewer.load</code>), CDN snippet, llms.txt\npointers, and the pointer to <code>nutrient-web-sdk</code> for framework recipes.</li>\n<li><code>references/viewer-decision-matrix.md</code> — full product decision matrix and routing rules.</li>\n</ul>\n<h2>Document modes</h2>\n<ul>\n<li><strong>DWS-managed</strong> — upload the document to Nutrient storage (<code>upload</code>), then mint a session for its\n<code>document_id</code>. Nutrient stores, streams, and (optionally) persists annotations. Counts against the\nupload/storage quota; uploaded documents should be torn down when no longer needed (see Rules).</li>\n<li><strong>App-provided</strong> — the developer streams their own file to the SDK in the browser; the backend\nonly mints a session with an empty body (<code>session --app-provided</code>). No document is uploaded to\nNutrient storage, so nothing needs teardown — but each session still consumes session quota.</li>\n</ul>\n<h2>Operations</h2>\n<h3><code>viewer-session.py</code> — upload + session mint</h3>\n<pre><code># Upload a document to Nutrient storage; prints document_id\nuv run scripts/viewer-session.py upload --file doc.pdf\n\n# Mint a read-only session JWT for a DWS-managed document (write the token to a 0600 file)\nuv run scripts/viewer-session.py session --document-id &lt;id&gt; --jwt-out session.jwt\n\n# Elevate permissions explicitly (least privilege is the default — see Rules)\nuv run scripts/viewer-session.py session --document-id &lt;id&gt; --allow-write --allow-download --jwt-out session.jwt\n\n# One-shot: upload then mint (the common case and the live smoke path)\nuv run scripts/viewer-session.py upload-and-session --file doc.pdf --jwt-out session.jwt\n\n# Interactive only: echo the JWT to stdout instead of a file (opt-in; stdout is logged)\nuv run scripts/viewer-session.py session --document-id &lt;id&gt; --print-jwt\n\n# App-provided mode: mint a session with an empty body (no upload). See Rules — scope is\n# UNVERIFIED and TTL is unbounded; do not use it as a default.\nuv run scripts/viewer-session.py session --app-provided --jwt-out session.jwt\n\n# Tear down a DWS-managed document when done (teardown)\nuv run scripts/viewer-session.py delete --document-id &lt;id&gt;\n</code></pre>\n<ul>\n<li>Upload: <code>POST https://api.nutrient.io/viewer/documents</code>, binary body; response <code>data.document_id</code>.</li>\n<li>Session: <code>POST https://api.nutrient.io/viewer/sessions</code>, body\n<code>{ allowed_documents: [{ document_id, permissions }], exp }</code> (DWS-managed) or <code>{}</code> (app-provided);\nresponse <code>{ jwt }</code>. The JWT prints <strong>once</strong> to stdout for capture.</li>\n<li><code>upload-and-session</code> on partial failure (upload succeeds, session mint fails) attempts best-effort\ncleanup — it deletes the just-uploaded document (<code>DELETE /viewer/documents/{id}</code>, confirmed live)\nso a failed run does not orphan a document in cloud storage.</li>\n</ul>\n<h2>Rules</h2>\n<ul>\n<li><strong>The JWT needs an explicit sink.</strong> A session-minting command requires either <code>--jwt-out &lt;file&gt;</code>\n(written <code>0600</code>) or <code>--print-jwt</code>. The default is the file — printing a browser bearer token to\nstdout is opt-in because agent/CI transcripts capture stdout. The script errors before any billed\ncall if neither is given.</li>\n<li><strong>Least privilege by default.</strong> A session grants <strong><code>[\"read\"]</code></strong> only. <code>write</code> and <code>download</code>\nrequire explicit <code>--allow-write</code> / <code>--allow-download</code> (or an explicit <code>--permissions</code> list). A\nminted JWT is a browser-facing bearer credential; defaulting to read-only limits the blast radius\nof a leaked token.</li>\n<li><strong>Short TTL.</strong> Default session expiry is 1 hour. <code>--expires-in</code> can extend it up to a documented\nceiling (24h); the script warns above a short-TTL threshold. A leaked long-TTL JWT is an open\nexfiltration window for as long as it is valid.</li>\n<li><strong><code>--app-provided</code> is not least-privilege — don't default to it.</strong> It mints an empty-body session\nwhose authorization scope is <strong>unverified</strong> and whose TTL is <strong>not bounded</strong> by <code>--expires-in</code>\n(the API applies its own). Use DWS-managed mode (<code>--document-id</code>) for any real session. Only reach\nfor <code>--app-provided</code> when you deliberately stream your own file to the browser SDK and have\nindependently confirmed the scope you get — not as a shortcut for smoke runs.</li>\n<li><strong>Tear down uploaded documents.</strong> Every document created with <code>upload</code> / <code>upload-and-session</code>\ndraws down a metered quota (Free tier: 100 docs / 500 MiB / 100 uploads per month) and carries\ndata-retention exposure. Delete it when done with <code>viewer-session.py delete --document-id &lt;id&gt;</code>.\nVerify deletion by the document's absence from <code>GET /viewer/documents</code> (a GET-by-id always 404s\nand is not a liveness signal).</li>\n<li><strong>Fail fast</strong> on a missing key or missing required args, with a message naming\n<code>NUTRIENT_DWS_VIEWER_API_KEY</code>.</li>\n<li>If a future <code>nutrient-dws</code> client adds Viewer methods, the script can swap its <code>httpx</code> calls for\nthem; today it uses <code>httpx</code> directly (the SDK targets Processor/Extraction).</li>\n</ul>\n<h2>Security Hardening Addendum</h2>\n<ul>\n<li>Never store <code>NUTRIENT_DWS_VIEWER_API_KEY</code> in committed files. Use process env injection at runtime\n(shell/export, secrets manager, or host env).</li>\n<li><strong>Never expose the session JWT in client-side source bundles or commit it.</strong> It is a bearer\ncredential granting document access until <code>exp</code>. Leaking it is equivalent to leaking the API key.</li>\n<li>The script prints the JWT <strong>once to stdout</strong> for interactive capture and never logs it at\ndebug/verbose level. stdout is <strong>not</strong> an inherently safe sink — it is captured into agent\ntranscripts and CI build logs. For automation, write the JWT to a <code>0600</code> file or an env-export\nrather than raw stdout, and do not retain CI logs from runs that mint real JWTs.</li>\n<li>The script redacts the API key from any error body before printing, and never sets\n<code>httpx verify=False</code>.</li>\n<li><strong>Revocation:</strong> no session-revocation endpoint is confirmed. A leaked JWT can only be contained by\n<strong>rotating the underlying API key</strong> and waiting out the current sessions' <code>exp</code>. Keep TTLs short\nfor high-sensitivity documents.</li>\n<li><strong>App-provided scope:</strong> an empty-body (<code>--app-provided</code>) session's authorization scope is\nunconfirmed — the least-privilege <code>permissions</code> list does not attach to that path. The script\nwarns when <code>--app-provided</code> is used.</li>\n</ul>\n<h2>Documentation</h2>\n<ul>\n<li>Viewer API guides (llms.txt): <a href=\"https://www.nutrient.io/guides/dws-viewer/llms.txt\">https://www.nutrient.io/guides/dws-viewer/llms.txt</a></li>\n<li>Cross-product index: <a href=\"https://www.nutrient.io/llms.txt\">https://www.nutrient.io/llms.txt</a></li>\n<li>Product overview: <a href=\"https://www.nutrient.io/api/viewer-api/\">https://www.nutrient.io/api/viewer-api/</a></li>\n</ul>\n<h2>Reference map</h2>\n<ul>\n<li><code>references/viewer-decision-matrix.md</code> — full Viewer API vs Web SDK vs Document Engine matrix and\nrouting rules; the single source of truth for the disambiguation. Also records the confirmed\ndelete/teardown contract.</li>\n<li><code>references/embed-guide.md</code> — browser embed (<code>NutrientViewer.load</code>), CDN snippet, llms.txt\npointers, and the pointer to <code>nutrient-web-sdk</code> for framework recipes.</li>\n<li>Sibling <code>nutrient-web-sdk/SKILL.md</code> — the self-hosted WASM viewer and <code>@nutrient-sdk/viewer</code> embed.</li>\n</ul>\n","files":[{"path":".gitignore","sizeBytes":34,"isText":false},{"path":"references/embed-guide.md","sizeBytes":3020,"isText":true},{"path":"references/viewer-decision-matrix.md","sizeBytes":5250,"isText":true},{"path":"scripts/test_viewer_session.py","sizeBytes":30903,"isText":true},{"path":"scripts/viewer-session.py","sizeBytes":26616,"isText":true},{"path":"SKILL.md","sizeBytes":12590,"isText":true},{"path":"tests/fixtures/sample.pdf","sizeBytes":2021,"isText":false},{"path":"tests/smoke-test-guide.md","sizeBytes":5361,"isText":true},{"path":"tests/smoke_viewer.py","sizeBytes":4404,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-11-29T00:45:08.633896Z","sha256":"543DA6EC9FAD5D44836F952D5D76BA579F4E6A680C6383BF114842228D9AA323","sizeBytes":30678},"review":null,"source":{"repositoryUrl":"https://github.com/PSPDFKit-labs/nutrient-skills","path":"plugins/nutrient-dws/skills/dws-viewer-api","license":null,"commit":"83aea52a003a4ebb69fcf78ea724b48cbe950835","subtreeSha":"862CBB0DBA035183EC3F0BA8F950FD9363FB07B19A2527D44072512F985CC4B7","lastSyncedAt":"2026-11-29T00:42:56.729498Z"},"reviewedAt":"2026-11-29T00:50:35.59864Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/PSPDFKit-labs/nutrient-skills/tree/main/plugins/nutrient-dws/skills/dws-viewer-api"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install pspdfkit-labs-nutrient-skills@llmmart"},{"target":"git","command":"git clone https://github.com/PSPDFKit-labs/nutrient-skills.git"}]}