/nutrient-dws:dws-viewer-apifrom nutrient-dws
Uploads documents to Nutrient-managed cloud storage and mints viewer session JWTs for the Nutrient DWS Viewer API. Covers the server-side half of cloud-hosted document viewing with annotation, forms, signing, and real-time collaboration.
Ships in nutrient-dws. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
The DWS Viewer API is Nutrient's cloud-hosted document viewing service. The flow is three server-side steps: upload a document to Nutrient-managed storage (or reference an app-provided one), mint a short-lived session JWT, and hand that JWT to the browser, where the Nutrient Web SDK renders a full viewer backed by Nutrient infrastructure — storage, streaming, annotation sync, and collaboration, with no viewing/storage servers to run. (You still need a small trusted backend or serverless endpoint to mint the session token — the API key must never reach the browser; this skill is exactly that server-side step.)
This skill covers the server-side half — upload and session mint, the part agents get wrong. The
one-line browser embed (NutrientViewer.load({ container, session })) is documented in
references/embed-guide.md; framework integration belongs to the nutrient-web-sdk skill.
Three Nutrient products show documents in a browser. Pick the right one before writing code:
| Product | Infra hosting | Storage | Persistence / collab | Route here when |
|---|---|---|---|---|
| DWS Viewer API (this skill) | Nutrient cloud | Nutrient cloud or app-provided | Built in | Cloud-first; no server infra; collab fast |
Nutrient Web SDK (nutrient-web-sdk) | Developer (browser WASM) | Developer's server | Via Document Engine | Self-hosted/offline; @nutrient-sdk/viewer embed |
Document Engine (nutrient-document-engine) | Developer's server | Developer's DB | Yes (server-side) | Self-hosted persistence; custom auth; data residency |
nutrient-web-sdk for the self-hosted WASM viewer, license keys, or
NutrientViewer.load() / @nutrient-sdk/viewer embed wiring without a DWS session.nutrient-document-engine for self-hosted annotation persistence or
data-residency / custom-auth backends.The full comparison and routing rules live in references/viewer-decision-matrix.md (the single
source of truth for this disambiguation).
The DWS Viewer API is a separate product with its own API key — distinct from the Processor key
(NUTRIENT_API_KEY) and the Extraction key (NUTRIENT_EXTRACT_API_KEY). Do not reuse another
product's key here.
NUTRIENT_DWS_VIEWER_API_KEY:
export NUTRIENT_DWS_VIEWER_API_KEY="pdf_live_..."
cd <directory containing this SKILL.md> && uv run scripts/viewer-session.py --help
This skill does not silently fall back to NUTRIENT_API_KEY. The Viewer API's wrong-key
behavior is unconfirmed, so a silent fallback could mint a real browser session JWT against the
wrong product/tenant with no signal (a confused-deputy). If your tenant has migrated to a global
DWS key, opt in explicitly with --allow-global-key, which warns at the point of fallback.
scripts/viewer-session.py — the cloud-side operations (upload, session mint, combined).references/embed-guide.md — the browser embed (NutrientViewer.load), CDN snippet, llms.txt
pointers, and the pointer to nutrient-web-sdk for framework recipes.references/viewer-decision-matrix.md — full product decision matrix and routing rules.upload), then mint a session for its
document_id. Nutrient stores, streams, and (optionally) persists annotations. Counts against the
upload/storage quota; uploaded documents should be torn down when no longer needed (see Rules).session --app-provided). No document is uploaded to
Nutrient storage, so nothing needs teardown — but each session still consumes session quota.viewer-session.py — upload + session mint# Upload a document to Nutrient storage; prints document_id
uv run scripts/viewer-session.py upload --file doc.pdf
# Mint a read-only session JWT for a DWS-managed document (write the token to a 0600 file)
uv run scripts/viewer-session.py session --document-id <id> --jwt-out session.jwt
# Elevate permissions explicitly (least privilege is the default — see Rules)
uv run scripts/viewer-session.py session --document-id <id> --allow-write --allow-download --jwt-out session.jwt
# One-shot: upload then mint (the common case and the live smoke path)
uv run scripts/viewer-session.py upload-and-session --file doc.pdf --jwt-out session.jwt
# Interactive only: echo the JWT to stdout instead of a file (opt-in; stdout is logged)
uv run scripts/viewer-session.py session --document-id <id> --print-jwt
# App-provided mode: mint a session with an empty body (no upload). See Rules — scope is
# UNVERIFIED and TTL is unbounded; do not use it as a default.
uv run scripts/viewer-session.py session --app-provided --jwt-out session.jwt
# Tear down a DWS-managed document when done (teardown)
uv run scripts/viewer-session.py delete --document-id <id>
POST https://api.nutrient.io/viewer/documents, binary body; response data.document_id.POST https://api.nutrient.io/viewer/sessions, body
{ allowed_documents: [{ document_id, permissions }], exp } (DWS-managed) or {} (app-provided);
response { jwt }. The JWT prints once to stdout for capture.upload-and-session on partial failure (upload succeeds, session mint fails) attempts best-effort
cleanup — it deletes the just-uploaded document (DELETE /viewer/documents/{id}, confirmed live)
so a failed run does not orphan a document in cloud storage.--jwt-out <file>
(written 0600) or --print-jwt. The default is the file — printing a browser bearer token to
stdout is opt-in because agent/CI transcripts capture stdout. The script errors before any billed
call if neither is given.["read"] only. write and download
require explicit --allow-write / --allow-download (or an explicit --permissions list). A
minted JWT is a browser-facing bearer credential; defaulting to read-only limits the blast radius
of a leaked token.--expires-in can extend it up to a documented
ceiling (24h); the script warns above a short-TTL threshold. A leaked long-TTL JWT is an open
exfiltration window for as long as it is valid.--app-provided is not least-privilege — don't default to it. It mints an empty-body session
whose authorization scope is unverified and whose TTL is not bounded by --expires-in
(the API applies its own). Use DWS-managed mode (--document-id) for any real session. Only reach
for --app-provided when you deliberately stream your own file to the browser SDK and have
independently confirmed the scope you get — not as a shortcut for smoke runs.upload / upload-and-session
draws down a metered quota (Free tier: 100 docs / 500 MiB / 100 uploads per month) and carries
data-retention exposure. Delete it when done with viewer-session.py delete --document-id <id>.
Verify deletion by the document's absence from GET /viewer/documents (a GET-by-id always 404s
and is not a liveness signal).NUTRIENT_DWS_VIEWER_API_KEY.nutrient-dws client adds Viewer methods, the script can swap its httpx calls for
them; today it uses httpx directly (the SDK targets Processor/Extraction).NUTRIENT_DWS_VIEWER_API_KEY in committed files. Use process env injection at runtime
(shell/export, secrets manager, or host env).exp. Leaking it is equivalent to leaking the API key.0600 file or an env-export
rather than raw stdout, and do not retain CI logs from runs that mint real JWTs.httpx verify=False.exp. Keep TTLs short
for high-sensitivity documents.--app-provided) session's authorization scope is
unconfirmed — the least-privilege permissions list does not attach to that path. The script
warns when --app-provided is used.references/viewer-decision-matrix.md — full Viewer API vs Web SDK vs Document Engine matrix and
routing rules; the single source of truth for the disambiguation. Also records the confirmed
delete/teardown contract.references/embed-guide.md — browser embed (NutrientViewer.load), CDN snippet, llms.txt
pointers, and the pointer to nutrient-web-sdk for framework recipes.nutrient-web-sdk/SKILL.md — the self-hosted WASM viewer and @nutrient-sdk/viewer embed.references/embed-guide.md (opens in a new tab)references/viewer-decision-matrix.md (opens in a new tab)scripts/test_viewer_session.py (opens in a new tab)scripts/viewer-session.py (opens in a new tab)tests/fixtures/sample.pdf (opens in a new tab)tests/smoke-test-guide.md (opens in a new tab)tests/smoke_viewer.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Triggers: DWS Viewer API; cloud-hosted document viewer; "mint/generate a viewer session"; viewer session JWT or session token handed to the browser; `POST /viewer/documents` or `POST /viewer/sessions`; embed a PDF viewer backed by Nutrient cloud with no server to run; annotation/forms/signing/real-time collaboration via cloud infrastructure; `NutrientViewer.load` *with a `session:` token*. Covers the server-side half only: upload to Nutrient storage + session mint. Not for the self-hosted WASM viewer, license keys, or React/Vue/Angular embed wiring (`@nutrient-sdk/viewer`, `NutrientViewer.load` without a DWS session) — those go to `nutrient-web-sdk`; not for self-hosted annotation persistence or data-residency/custom-auth backends — those go to `nutrient-document-engine`.
Three short reads, in order
nutrient, dws-viewer-api, document-viewer, pdf-viewer, session-jwt, cloud-viewer
6 skills in this plugin
/ai-gatewayTwo primitives of the Nutrient AI Gateway. Chat models (`nutrient-s`/`nutrient-m`/`nutrient-l` via `POST /responses` or `POST /chat/completions`) are OpenAI-compatible, for open-ended generation. The decision API (`POST /systemone`, TypeSafe-compatible) returns calibrated probabilities instead of free text, for routing, flagging, and scoring — `noul` for yes/no, `choice` for picking one of several labels, `score` for placing content on an ordered scale. Route to the decision API whenever the task is "classify this", "is this true/false", "route to a category", "flag for review", "rate the severity/quality", or anything else that would otherwise need regex, keyword matching, or asking a chat model to emit structured JSON. Route to a chat model for open-ended generation, summarization, or tool-calling. Triggers include AI Gateway, nutrient-document-decision, nutrient-systemone, System One, TypeSafe, calibrated probability, noul question, choice question, score question, classify this document/message, route to a category, flag for review, confidence threshold./document-extraction-apiUse the Nutrient Data Extraction API to parse whole documents into Markdown or spatial elements, extract named fields such as invoice totals with source citations, classify documents against labels, or detect document boundaries in a merged packet./document-processor-apiProcess documents with Nutrient DWS. Use when the user wants to generate PDFs from HTML or URLs, convert Office/images/PDFs, assemble documents or split PDFs at known page ranges, OCR scans, extract text/tables/key-value pairs, redact PII, watermark, sign, fill forms, optimize PDFs, or produce compliance outputs like PDF/A or PDF/UA. Triggers include convert to PDF, merge these PDFs, OCR this scan, extract tables, redact PII, sign this PDF, make this PDF/A, or linearize for web delivery. For accessibility or PDF/UA-1 validation of an existing PDF, use remediate-pdf./grounded-rag-ingestionChunk a document into provenance-carrying JSONL ready for embedding via the Nutrient Data Extraction API (`/extraction/parse`, spatial output). Every chunk carries element type, page index, bounding box, confidence, and reading order, traceable to a specific page region. Use for grounded or auditable RAG, cited retrieval, confidence-aware ingestion, or any pipeline that must prove which document region a retrieved answer came from. Triggers include grounded RAG, auditable RAG, RAG with provenance, chunk with bounding box, cite page, provenance-carrying chunks, confidence-aware chunking, or embedding pipeline. Not for cheap Markdown — use document-extraction-api with `--output-format markdown` for that. Not for known target fields — if the user wants specific fields ("invoice number and total", "map to my schema", "return these fields cited"), use document-extraction-api's `extract` (one cited call), not whole-document chunking./signer-apiIntroduces the Nutrient DWS Signer API, which sends documents for legally binding eSignatures and tracks every envelope. The API is not public yet: it is available only on the Enterprise plan. Use when the user asks about Nutrient Signer, sending a PDF for signature, or eSignature envelopes.npx claudepluginhub pspdfkit-labs/nutrient-skills --plugin nutrient-dwsOther plugins' skills for the same job