> For the complete documentation index, see [llms.txt](https://docs.sudoplatform.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sudoplatform.com/guides/privacy-interaction/integrate-the-privacy-interaction-sdk.md).

# Integrate the Privacy Interaction SDK

### Prerequisites <a href="#prerequisites" id="prerequisites"></a>

1. [Complete the Getting Started Guide](https://docs.sudoplatform.com/~/revisions/U8P5YQbTWlABRqHUlUfP/guides/getting-started)
2. [Integrate the User SDK](https://docs.sudoplatform.com/~/revisions/U8P5YQbTWlABRqHUlUfP/guides/users/integrate-the-user-sdk)

### Integrate the JS SDK <a href="#integrate-the-js-sdk" id="integrate-the-js-sdk"></a>

To use the **Privacy Interaction SDK** in a Web or Node.js project, you must add `@sudoplatform/sudo-privacy-interaction` as a dependency to your project.

{% tabs %}
{% tab title="Typescript" %}

```bash
yarn add '@sudoplatform/sudo-privacy-interaction'
# or
npm install --save '@sudoplatform/sudo-privacy-interaction'
```

{% endtab %}
{% endtabs %}

In order to instantiate a Privacy Interaction client, make sure you have followed the instructions for [Getting Started](https://docs.sudoplatform.com/~/revisions/U8P5YQbTWlABRqHUlUfP/guides/getting-started) and [User SDK](https://docs.sudoplatform.com/~/revisions/U8P5YQbTWlABRqHUlUfP/guides/users/integrate-the-user-sdk) (see [Prerequisites](https://app.gitbook.com/o/-M39U3D2HOiBk9X4Eceg/s/-M2oeXSYkTAXJocuferm/~/edit/~/changes/616/guides/privacy-interaction/integrate-the-privacy-interaction-sdk#prerequisites) above).

To instantiate a client in your application, add the following:

{% tabs %}
{% tab title="Typescript" %}

```typescript
import { DefaultSudoPrivacyInteractionClient } from '@sudoplatform/sudo-privacy-interaction'
import { DefaultSudoUserClient } from '@sudoplatform/sudo-user'

const userClient = new DefaultSudoUserClient(/* refer to Users documentation */)

const privacyInteractionClient = new DefaultSudoPrivacyInteractionClient({
  sudoUserClient: userClient,
})
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
You only need one client instance for a given user per device. Instantiating multiple clients with the same configuration and using them at the same time may cause unexpected runtime errors to occur.
{% endhint %}

### SDK Architecture <a href="#sdk-architecture" id="sdk-architecture"></a>

The Privacy Interaction SDK is organized around three core resource types:

| Resource         | Description                                                            |
| ---------------- | ---------------------------------------------------------------------- |
| Virtual Presence | A connected user identity (e.g., email account) that the SDK monitors. |
| Data Holder      | An organization discovered to hold data for a virtual presence.        |
| Analysis Result  | A structured privacy analysis produced for each data holder.           |

The typical workflow is:

1. **Connect** a virtual presence (e.g., via OAuth authorization code or refresh token).
2. **Scan** — the platform automatically scans the connected account and discovers data holders.
3. **Analyze** — for each data holder, the platform performs a privacy analysis.
4. **Subscribe** — receive real-time updates as scanning and analysis progress.
