Web SDK vs. DWS Viewer: Which key do I use?
A Could not decode license key error when using a DWS API key in NutrientViewer.load() indicates a product mismatch. DWS Viewer and Web SDK use different authentication methods.
Identify your product
| You have… | Key format | Found in |
|---|---|---|
| DWS Viewer API | Short API key: dws_live_abc123... | Portal → Document Web Services → API Keys |
| Web SDK | Long license key: nX5NbnzG... (500+ chars) | Portal → Manage Licenses |
DWS Viewer API authentication
DWS Viewer uses session tokens, not license keys. The API key authenticates your backend to request session tokens:
// ❌ Wrong — API key is not a license key.NutrientViewer.load({ container: "#viewer", licenseKey: "dws_live_abc123..." // Error: Could not decode.});
// ✅ Correct — Use a session token from your backend.NutrientViewer.load({ container: "#viewer", session: "<session_token_from_backend>"});Get a session token by calling the DWS API from your server:
curl -X POST "https://api.nutrient.io/viewer/sessions" \ -H "Authorization: Bearer dws_live_abc123..." \ -H "Content-Type: application/json" \ -d '{"document_url": "https://example.com/document.pdf"}'The response contains the session token to pass to the frontend.
Web SDK authentication
Web SDK uses a license key tied to your domain:
NutrientViewer.load({ container: "#viewer", document: "document.pdf", licenseKey: "nX5NbnzGFzYhuWTje1LqC8hWYX1jP_WAqka..."});Get your license key from the Nutrient Portal(opens in a new tab) under Manage Licenses after registering your domain.
Quick reference
| DWS Viewer API | Web SDK | |
|---|---|---|
| Authentication | Session token (from API) | License key (in code) |
| API key used for | Backend → DWS API calls | Not applicable |
| Document hosting | Nutrient cloud | Your infrastructure |
| Rendering | Server-side | Client-side (WebAssembly) |
| Pricing | Usage-based | Per-domain license |
Which product do I need?
Choose DWS Viewer API if
- Nutrient hosts and renders documents
- Usage-based pricing works for your scale
- Minimal infrastructure setup is preferred
Choose Web SDK if
- Documents stay on your infrastructure
- Client-side rendering is preferred
- Fixed per-domain licensing fits your model
Additional resources
- DWS Viewer API documentation — Session tokens and API reference
- Open PDFs using DWS Viewer API — Frontend integration guide
- Web SDK licensing — Domain registration and license keys
- Operational modes — Web SDK deployment options