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

# Identify and manage users

> Pass user identity to Sleekplan with $sleek.setUser(), attach arbitrary metadata, and clear the session on logout so feedback is attributed correctly

Sleekplan associates feedback, votes, and changelog subscriptions with the user. Call `$sleek.setUser()` after authentication to identify who is logged in. This page covers `setUser()`, `addMetadata()`, and `resetUser()`.

## Set the current user

Call `$sleek.setUser(data)` as soon as you know who is logged in — typically right after your application authenticates the user.

```javascript theme={"system"}
$sleek.setUser({
  mail: 'user@example.com',
  id: '1398',
  name: 'janesmith',
  img: 'https://myapp.com/avatars/1398.jpg',
  weight: 4,
  changelog_subscribed: true
});
```

### Parameters

<ParamField path="body.mail" type="string">
  Email address of the logged-in user. Used to uniquely identify the user in Sleekplan and send them notifications.
</ParamField>

<ParamField path="body.token" type="string">
  A signed JSON Web Token (JWT) for Single Sign-On. Required if your workspace has private boards enabled or if you have selected "Registration requires email verification" or "Login requires email confirmation" in your preferences. Passing a valid token bypasses email confirmation prompts.
</ParamField>

<ParamField path="body.id" type="string | number">
  Your application's internal identifier for the user — for example, a database user ID or UUID. Useful for correlating Sleekplan users with records in your own system.
</ParamField>

<ParamField path="body.name" type="string">
  Display name for the user. Must use lowercase letters only and must not contain spaces or special characters (e.g., `janesmith` not `Jane Smith`).
</ParamField>

<ParamField path="body.img" type="string">
  Publicly accessible URL of the user's avatar image. Sleekplan fetches and displays this image alongside the user's activity.
</ParamField>

<ParamField path="body.weight" type="integer">
  Weighting factor between `1` and `10`. A higher weight makes this user's feedback and votes count more in the impact score calculation — useful for prioritizing input from high-value customers.
</ParamField>

<ParamField path="body.changelog_subscribed" type="boolean">
  When `true`, automatically subscribes the user to the changelog so they receive update notifications without having to opt in manually.
</ParamField>

<Note>
  If you only pass `mail` and your workspace requires email confirmation, Sleekplan will prompt the user to verify their address. To bypass this, include a signed `token` via SSO.
</Note>

### SSO with a JWT token

If your workspace uses private boards or enforces email verification, pass a signed JWT as the `token` field. Generate the token server-side using your Sleekplan SSO secret.

```javascript theme={"system"}
$sleek.setUser({
  mail: 'user@example.com',
  id: '1398',
  name: 'janesmith',
  token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...' // server-generated JWT
});
```

<Tip>
  Generate the JWT on your server and inject it into your front-end code at render time. Never expose your SSO secret in client-side JavaScript. See [Single Sign-On](/authentication/single-sign-on) for setup instructions.
</Tip>

## Add metadata

Use `$sleek.addMetadata(meta)` to attach arbitrary key-value data to the current user. There are no restrictions on the object structure, so you can pass any additional context that is useful for your team — plan tier, company name, MRR, region, and so on.

```javascript theme={"system"}
$sleek.addMetadata({
  company_name: 'Acme LLC',
  company_mrr: 5000,
  plan: 'enterprise',
  country: 'France',
  customer_since: '2019-06-05'
});
```

<Note>
  You can call `addMetadata()` multiple times. Each call merges the provided object into the existing metadata for the current session.
</Note>

<ParamField path="body.meta" type="object" required>
  An object containing any key-value pairs you want to attach to the user. Keys and values can be any type — strings, numbers, booleans, or nested objects.
</ParamField>

## Reset the session on logout

Call `$sleek.resetUser()` whenever the current user logs out of your application. This clears all user data from the session and removes any stored identifiers, so the next visitor does not inherit the previous user's session.

```javascript theme={"system"}
// Call this in your logout handler
function handleLogout() {
  // ... your existing logout logic ...
  $sleek.resetUser();
}
```

<Warning>
  If you do not call `resetUser()` on logout, the session cookie or localStorage entry remains active. The next person to use the same browser will be identified as the previous user until the session expires.
</Warning>

## Full example

The following example shows a typical integration where you identify the user after login, attach extra context, and clear the session on logout.

```javascript theme={"system"}
// On login — identify the user
$sleek.setUser({
  mail: currentUser.email,
  id: currentUser.id,
  name: currentUser.username,
  img: currentUser.avatarUrl,
  weight: currentUser.isPremium ? 8 : 3,
  changelog_subscribed: true
});

// Attach extra context
$sleek.addMetadata({
  plan: currentUser.plan,
  company: currentUser.companyName,
  mrr: currentUser.mrr
});

// On logout — clear the session
$sleek.resetUser();
```
