# Safe Voice Consent API

> Learn to implement the Safe Voice Consent Application Programming Interface.

To utilize Safe Voice with Vivox in Unreal, all users must grant consent to have their voice chat recorded by the Safe Voice service. Two APIs exist in the ILoginSession of the Vivox Unreal SDK to allow for consent to be updated and checked:

* `ILoginSession::BeginSetSafeVoiceConsent`
  * Use this request to change or set a user's consent status.
* `ILoginSession::BeginGetSafeVoiceConsent`
  * Use this request to check a user's consent status.

Calling these APIs requires additional information from the Unity Dashboard:

* The Unity Project ID
* Unity Environment ID
* The Authentication Token of an actively authenticated login to the Unity Authentication Service.

It’s recommended to use the Unity Gaming Services for Unreal Engine module, which can be found in the Unreal Engine Marketplace, to access UAS functionality.

> **Note:**
>
> When constructing the LoginSession for an account that provides consent status, the name of the AccountId must be set to the PlayerId of the current authentication session before creating the `LoginSession`.

The following code sample is an example of using `ILoginSession::BeginSetSafeVoiceConsent`:

```text
ILoginSession::FOnBeginSetSafeVoiceConsentCompletedDelegate OnBeginSetSafeVoiceConsentCompletedCallback;
OnBeginSetSafeVoiceConsentCompletedCallback.BindLambda([this](VivoxCoreError status, bool consentStatus)
{
        //React to the consentStatus that was set here
});
ILoginSession& loginSession = GetClient().GetLoginSession(m_account);
loginSession.BeginSetSafeVoiceConsentStatus(consentToSet, unityEnvironmentId, unityProjectId, UASToken, OnBeginSetSafeVoiceConsentCompletedCallback);
```

The following code sample is an example of using `ILoginSession::BeginGetSafeVoiceConsent`:

```text
ILoginSession::FOnBeginGetSafeVoiceConsentCompletedDelegate OnBeginGetSafeVoiceConsentCompletedCallback;
OnBeginGetSafeVoiceConsentCompletedCallback.BindLambda([this](VivoxCoreError status, bool consentStatus)
{
        //React to the consentStatus that was set here
});
ILoginSession& loginSession = GetClient().GetLoginSession(m_account);
loginSession.BeginGetSafeVoiceConsentStatus(unityEnvironmentId, unityProjectId, UASToken, OnBeginGetSafeVoiceConsentCompletedCallback);
```

> **Note:**
>
> GetClient() is a function that returns an active FVivoxCoreModule’s VoiceClient().
