> ## Documentation Index
> Fetch the complete documentation index at: https://developer.onetrust.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Groups (Categories/Purposes) Helpers

OneTrust SDK Public Methods for Groups (Categories/Purposes)

# Existing

## Get saved consent for a group

Retrieves the saved consent value for specified group (purpose/category) identifier

**Parameter:**

* `categoryId`: The group represented as a string, for which consent value has to be returned.

```swift
OTPublishersHeadlessSDK.shared.getConsentStatus(forCategory:) -> Int8
```

**Returns:**

* 1 = Consent is given
* 0 = Consent is not given
* -1 = Consent has not been collected (The SDK is not initialized or category does not exist OR there are no SDKs associated to this category)

**Note**: This status is not the most update status present in the OneTrust SDK as the consent could be updated locally and not synced yet. Please use `getPurposeConsentLocal` for fetching the latest consent status.

## Get latest local consent for a category

Retrieves the local (saved or unsaved) consent value for specified group identifier.

**Parameters:**

* `customGroupId`: The group represented as a string, for which consent value has to be retrieved.
* `useCmpApi`: Retrieves the status from the CMP API data available.

```swift
OTPublishersHeadlessSDK.shared.getPurposeConsentLocal(forCustomGroupId:) -> Int8
```

**Returns:**

* 1 = Consent is given
* 0 = Consent is not given
* -1 = Consent has not been collected (The SDK is not initialized or category does not exist OR there are no SDKs associated to this category)

**Note**: Use this API to retrieve the most current consent value (this can be an unsaved value if save operation is not performed yet after toggling the status). Please use `getConsentStatus(forCategory:)` if you want to retrieve only the last saved value for a category/purpose.

## Get saved Legitimate Interest status for a group

Retrieves the legitimate interest value for specified group identifier.

**Parameter:**

* `customGroupId`: The group represented as a string, for which legitimate interest value has to be retrieved.
* `useCmpApi`: Retrieves the status from the CMP API data available.

```swift
OTPublishersHeadlessSDK.shared.getPurposeLegitInterestLocal(forCustomGroupId:) -> Int8
```

**Returns:**

* 1 = legitimate interest is given
* 0 if legitimate interest not given
* \ -1 invalid groupId passed.

## Update consent for a group

Updates the consent value for the passed in group identifier.

**Parameters:**

* `groupId`: The purpose category ID represented as a string, for which consent value has to be updated.
* `consentValue`: Boolean value specifying updated consent value.
* `updateHierarchy`: If set to `true`, this will update the hierarchy of the category ID (parents/siblings/children). This value will be **false** by default.

```swift
OTPublishersHeadlessSDK.shared.updatePurposeConsent(forGroup: , consentValue: Bool, updateHierarchy:)
```

**Note:** If the purpose/category passed is linked with ATT and ATT permission is not granted, update of consent will not be permitted.

**Note:** Once this operation is complete, a notification will be posted with the updated consent value.

## Update Legitimate Interest for a group

Updates the legitimate interest value for the passed in group (purpose/category) identifier.

**Parameters:**

* `groupId`: The group represented as a string, for which legitimate interest value has to be updated.
* `legIntValue`: Boolean value specifying updated legitimate interest value.

```swift
OTPublishersHeadlessSDK.shared.updatePurposeLegitInterest(forGroup groupId: String, legIntValue: Bool)
```

**Note:** Once this operation is complete, a notification will be posted with the updated legitimate interest value.

## Get total vendor count for a group

Method to get vendor count configured for a particular purpose.

**Parameter:**

* `categoryId`: String, group id for which vendors have been assigned to. It can be a parent group id like Stack or an individual group like an IAB purpose.

```swift
OTPublishersHeadlessSDK.shared.getVendorCount(forCategory:) -> Int
```

Returns an integer for number of vendors, -1 for error cases.

# New

> 📘
>
> Starting in the 202504.1.0 release.

## Get all parent (root level) groups setup in the OneTrust template

Retrieves all the parent purpose groups that will be displayed in the Preference Center UI.

```swift
OTPublishersHeadlessSDK.shared.getAllParentPurposes() -> [PurposeTreeGroup]?
```

**Note:** Each parent purpose group will also contain any associated children (if any).