# SDK reference

Methods for tokens, integrations, installations, metadata, workflows, and actions in the Embedded SDK.

Load the [Client SDK](/docs/embedded/embedded-sdk/build-an-integrations-page/install-the-client-sdk), create an instance with `window.MindCloud()`, and call `setToken()` before methods that read or change an end user's data. The browser receives an end-user token from your backend, never your API key.

## Authentication

### setToken

`mindCloud.setToken(token)` sets the end-user JWT used by SDK requests. Call it again when you refresh the token.

### getTokenExpiration

`mindCloud.getTokenExpiration()` returns the token's expiry as a `Date`, or `null` when no usable expiry is available.

```js
const expiry = mindCloud.getTokenExpiration();
if (!expiry || expiry.getTime() <= Date.now() + 60_000) {
  mindCloud.setToken(await getTokenFromYourBackend());
}
```

## Integrations and installations

### getIntegrations

`await mindCloud.getIntegrations()` returns the integrations array, with installations for this end user. A call without options can return cached data. Pass `{ includeWorkflows: true }` to fetch fresh data, or `{ includeWorkflows: false }` to fetch without workflow details. An empty array can also follow an expired token or failed load; check the token and request before treating it as no integrations.

### install

`mindCloud.install({ integrationId, metadata?, onAuthenticationComplete?, onClose? })` opens the install modal. `metadata` supplies installation values defined by the integration. `onAuthenticationComplete` receives an object with `installationId` and `appId` after authentication.

### modify

`mindCloud.modify({ installationId, onAuthenticationComplete?, onClose? })` opens an existing installation in the modal. It does not accept a metadata update. Use `updateMetadata()` for that.

### uninstall and reinstall

`await mindCloud.uninstall({ installationId })` marks an installation uninstalled. It does not delete the installation row. `await mindCloud.reinstall({ installationId, metadata? })` attempts to reinstall it. Required connections must be valid before the installation is complete.

### activate and deactivate

`await mindCloud.activate({ installationId })` and `await mindCloud.deactivate({ installationId })` change whether an installation is active. They do not delete it.

### updateMetadata

`await mindCloud.updateMetadata({ installationId, metadata })` validates and merges defined metadata fields into an existing installation. The request can fail with per-field validation errors in `error.response.errors`.

```js
await mindCloud.updateMetadata({
  installationId,
  metadata: { storeName: 'West store' }
});
```

## Workflows and actions

### enableWorkflow and disableWorkflow

`await mindCloud.enableWorkflow({ workflowId, installationId })` enables one installed workflow. `disableWorkflow()` takes the same fields and disables it.

### runAppAction

`await mindCloud.runAppAction({ installationId, appId, appVersion: 'published', actionId, actionArguments? })` runs an action with the installation's connection. `appVersion` defaults to `published`. The SDK uses the end-user token set with `setToken()`.

```js
const result = await mindCloud.runAppAction({
  installationId,
  appId,
  actionId,
  actionArguments: { message: 'Hello' }
});
```

For the HTTP contract, see [Run an app action](/docs/embedded/embedded-api/api-reference/run-an-app-action). For workflow integration setup, see [Build your first integration](/docs/embedded/embedded-sdk/build-your-first-integration).