Nutrient

SDK

Cloud

Low-Code

Workflow

Generate a Session Token

Session tokens used for authentication by DWS Viewer API can be generated using your API key via the POST /viewer/sessions endpoint:

curl -X POST https://api.nutrient.io/viewer/sessions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your_api_key_here" \
  --fail \
  -d '{
      "allowed_documents": [
        {
          "document_id": "<document_id>",
          "document_permissions": [
            "read",
            "write",
            "download"
          ]
        }
      ],
      "exp": 1793769299
    }'
curl -X POST https://api.nutrient.io/viewer/sessions ^
  -H "Content-Type: application/json" ^
  -H "Authorization: Bearer your_api_key_here" ^
  --fail ^
  -d "{\"allowed_documents\": [{\"document_id\": \"<document_id>\", \"document_permissions\": [\"read\", \"write\", \"download\"]}], \"exp\": 1793769299}"
POST https://api.nutrient.io/viewer/sessions HTTP/1.1
Content-Type: application/json
Authorization: Bearer your_api_key_here

{
  "allowed_documents": [
    {
      "document_id": "<document_id>",
      "document_permissions": [
        "read",
        "write",
        "download"
      ]
    }
  ],
  "exp": 1793769299
}

You can then retrieve the JWT as an jwt from the response:

JSON
{
  "jwt": "<created_session_token>"
}

You can now use the session token to open the document in Nutrient Web SDK.

💡 Session tokens can be created with additional optional claims to further control their properties. Refer to our API reference to learn more.