# Configuring SDK for Authenticated vs. Unauthenticated Users

## Configuring SDK for Authenticated vs. Unauthenticated Users

This guide explains how the S-Docs SDK works for both authenticated (logged-in) and unauthenticated (guest) users context, and how to configure each properly in your Salesforce Site/ Community/ Experience Cloud.

| Context                  | Common Use                                 | Runs As         | Key Setup                        |
| ------------------------ | ------------------------------------------ | --------------- | -------------------------------- |
| **Authenticated User**   | Community or Internal or Integration users | User generating | S-Docs license + permission sets |
| **Unauthenticated User** | <p>Experience Cloud<br>(guest user)</p>    | System mode     | System Mode enabled              |

## Authenticated Users

Authenticated users are **logged into Salesforce**, such as internal, partner, or community users. The SDK runs under their permissions and licenses.

#### Configuration to check:

{% stepper %}
{% step %}
**Community membership and permission sets**

* Go to **Community Cloud Site > Workspace > Administration > Members**
  * Under **Selected Profiles**, add the profile used by your community users.
  * Under **Selected Permission Sets**, add:
    * `S-Docs User`
    * `LWC Community User`
      {% endstep %}

{% step %}
**User record-level checks**

At the **user record level**, ensure:

* The **S-Docs User** and **LWC Community User** permission sets are assigned.
* The user has an **S-Docs license**.
* The user has access to the site (if applicable).
  {% endstep %}
  {% endstepper %}

## Unauthenticated Users

Unauthenticated users are **not logged in** (guest users).\
For these users, S-Docs supports **System Mode**, allowing document generation without a user session.

#### For LWC configuration:

Follow these steps to enable the Generate Documents LWC for guest user generation:

{% stepper %}
{% step %}
**Open LWC component in Experience Builder**

Click on the **LWC component** in the Experience Builder to open the configuration panel.
{% endstep %}

{% step %}
**Enable System Mode Generation**

Check the box labeled **System Mode Generation (Experience Cloud)**.
{% endstep %}

{% step %}
**Repeat for Generated Documents LWC**

Repeat this for the **Generated Documents LWC** — open the component, and check the same box to grant guest users access.

Once enabled, your **S-Docs LWCs** are ready for guest user document generation.
{% endstep %}
{% endstepper %}

***

#### For SDK configuration:

{% stepper %}
{% step %}
**Open SDK action in Flow Builder**

In **Flow Builder**, open your **S-Docs invocable action** (SDK action).
{% endstep %}

{% step %}
**Toggle System Mode Generation**

Toggle on the **System Mode Generation (Experience Cloud)** option.
{% endstep %}

{% step %}
**Set input value to True**

Set the value to **True** in the input field.
{% endstep %}
{% endstepper %}

{% hint style="info" %}
**Note:**

* The *System Mode* setting appears in all contexts but is only executed in **Experience Cloud** (guest) environments.
* Running system mode within an **internal org context** will result in a generation failure.
  {% endhint %}

{% hint style="warning" %}
**Typical Errors Encountered:**

* Error Occurred: An Apex error occurred: SDOC.Exceptions.GenerationException: Insert failed. First exception on row 0; first error: INSUFFICIENT\_ACCESS\_ON\_CROSS\_REFERENCE\_ENTITY, You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary.: \[NetworkId]
  {% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.sdocs.com/developer-hub/document-generation-workflows/apex-and-programmatic-automation/software-development-kit/configuring-sdk-for-authenticated-vs.-unauthenticated-users.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
