# S-Sign Licensing (Apex)

## S-Sign Licensing (Apex)

Use these Apex methods to read and manage S-Sign seat assignments when S-Sign manages licensing.

{% hint style="info" %}
Use this class only for in-product S-Sign licensing.

If the org uses Salesforce package licensing, use [Identifying S-Sign Licensing](/developer-hub/s-sign/page-4.md).
{% endhint %}

### Controller: `SSign.SSLicensesController`

{% hint style="warning" %}
Use `SSLicensesController` — plural.

This class manages seats only when licensing is handled inside S-Sign.
{% endhint %}

#### `getSSignLicensedUsers()`

**Method Signature**

```apex
global static List<Id> getSSignLicensedUsers()
```

**Details**

* **Input:** None.
* **Output:** Returns a `List<Id>` of Salesforce `User` IDs with active S-Sign seats.

**Use Cases**

Use this method when you need to:

* Audit current seat assignments.
* Check whether a user holds a seat.
* Capture a baseline before updates.

**Example**

```apex
// Read the current seat assignments
List<Id> licensedUserIds = SSign.SSLicensesController.getSSignLicensedUsers();

// Review the result
System.debug('Licensed user IDs: ' + licensedUserIds);
System.debug('Total licensed users: ' + licensedUserIds.size());
```

#### `removeSSignUserLicenses()`

**Method Signature**

```apex
global static void removeSSignUserLicenses(List<Id> removeUserIds)
```

**Details**

* **Input:**
  * **`removeUserIds`** (`List<Id>`): Salesforce `User` IDs to remove from S-Sign licensing.
* **Output:** Returns `void`.

**Use Cases**

Use this method when you need to:

* Reclaim unused seats.
* Remove access during offboarding.
* Sync seat removals from automation.

**Example**

```apex
// Define the users to remove
List<Id> removeUserIds = new List<Id>{
    '005XXXXXXXXXXXX',
    '005YYYYYYYYYYYY'
};

// Remove the seats
SSign.SSLicensesController.removeSSignUserLicenses(removeUserIds);
```

{% hint style="info" %}
Calling this method with an empty list succeeds and makes no seat changes.
{% endhint %}

#### `addSSignUserLicenses()`

**Method Signature**

```apex
global static void addSSignUserLicenses(List<Id> addUserIds)
```

**Details**

* **Input:**
  * **`addUserIds`** (`List<Id>`): Salesforce `User` IDs to grant an S-Sign seat.
* **Output:** Returns `void`.

**Use Cases**

Use this method when you need to:

* Assign seats to new users.
* Restore access for returning users.
* Apply seat changes from admin workflows.

**Example**

```apex
// Define the users to license
List<Id> addUserIds = new List<Id>{
    '005XXXXXXXXXXXX',
    '005YYYYYYYYYYYY'
};

// Assign the seats
SSign.SSLicensesController.addSSignUserLicenses(addUserIds);
```

{% hint style="info" %}
Calling this method with an empty list succeeds and makes no seat changes.
{% endhint %}

### Recommended workflow

Use this sequence for predictable seat updates:

1. Call `getSSignLicensedUsers()`.
2. Compare the current set with the target set.
3. Build separate `toAdd` and `toRemove` lists.
4. Apply only the delta.
5. Re-run `getSSignLicensedUsers()` to verify the result.

{% hint style="info" %}
Build the add and remove lists first.

This keeps updates easy to validate.
{% endhint %}

### Best practices

* Capture the current seat state before updates.
* Calculate deltas instead of sending raw lists.
* Validate Salesforce `User` ID format first.
* Remove duplicates before each method call.
* Use `try/catch` inside larger automation.
* Verify the final state after changes.


---

# 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/s-sign/s-sign-licensing-apex.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.
