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

# Verify users

> Show signed-in customers to your team

Your server signs a short description of the customer. DeskHoot checks the signature, so your team can trust the name, email and plan they see, and the customer gets their own conversation history on every device.

**1. Create a signing key**

Create one in [**Settings › User identity**](https://app.deskhoot.com/app/settings?tab=identity). Keep it on your server; anyone who has it can sign in as any customer.

**2. Sign the customer on your server**

Build one JSON string about the customer, with any of [the fields you can send](#fields-in-user). Then sign that exact string with HMAC-SHA256 and your key. The result is a 64-character hex string.

```js Node.js theme={null}
import { createHmac } from "node:crypto";

const user = JSON.stringify({
  id: "42",
  name: "Maya Chen",
  email: "maya@example.com",
  plan: "Pro",
});
const key = process.env.DESKHOOT_SIGNING_KEY;
const hash = createHmac("sha256", key).update(user).digest("hex");
```

```python Python theme={null}
import hashlib, hmac, json, os

user = json.dumps({
    "id": "42",
    "name": "Maya Chen",
    "email": "maya@example.com",
    "plan": "Pro",
})
key = os.environ["DESKHOOT_SIGNING_KEY"].encode()
hash = hmac.new(key, user.encode(), hashlib.sha256).hexdigest()
```

```php PHP theme={null}
$user = json_encode([
    "id" => "42",
    "name" => "Maya Chen",
    "email" => "maya@example.com",
    "plan" => "Pro",
]);
$key = getenv("DESKHOOT_SIGNING_KEY");
$hash = hash_hmac("sha256", $user, $key);
```

**3. Pass both to the chat**

Put them on the page, above your install code. Send `user` as the same string you signed: if a single character differs, the hash no longer matches.

```html theme={null}
<script>
  window.DeskHootSettings = {
    user: USER_FROM_YOUR_SERVER,
    hash: HASH_FROM_YOUR_SERVER,
  };
</script>
```

## Sign in and out without a page reload

In a single-page app, call these when the customer signs in or out of your product.

```js theme={null}
const result = await DeskHoot.setUser({ user, hash }); // after sign-in
await DeskHoot.reset();                                // after sign-out
```

## What you pass

**user** `string` *required*

The description of the customer that your server signed, as one JSON string.

**hash** `string` *required*

The signature of `user`: HMAC-SHA256 with your signing key.

## Fields in `user`

Leave a field out to keep its current value. Send `null` to clear it.

**id** `string | number` *required*

Your own ID for the customer. The same `id` always opens the same customer and their conversation history.

**name** `string` (default: Customer)

The customer's name, as your team sees it.

**email** `string`

The customer's email address.

**email\_verified** `boolean`

Whether your product has confirmed that the customer owns `email`.

**phone** `string`

The customer's phone number.

**avatar** `string`

A link to the customer's picture.

**plan** `string`

The plan the customer is on in your product.

**billing\_id** `string`

The customer's ID in your billing system.

**company** `object`

The company the customer belongs to.

**company fields**

**id** `string`

Your own ID for the company.

**name** `string`

The company's name.

**signed\_up\_at** `string | number`

When the customer joined your product.

**locale** `string`

The customer's language, such as `en-GB`.

**timezone** `string`

The customer's time zone, such as `Europe/London`.

### Your own fields

**your\_field** `any JSON`

Any other field is saved with the customer as an extra detail. Fields named like a credential or card detail (`password`, `secret`, `token`, `apikey`, `card`, `cvv`, `ssn`) are not stored.

## What you get back

`setUser()` resolves with:

**identified** `true`

The customer is signed in.

**ignored** `\{ key, reason \}[]`

The fields DeskHoot did not save. Everything else was saved: one bad optional field never blocks the customer.

**each item**

**key** `string`

The field's name, such as `"avatar"` or `"company.name"`.

**reason** `string`

Why it was dropped, such as `"must be an https URL"`.

## Errors

`setUser()` rejects with an error whose `code` is one of these. When the page sets `window.DeskHootSettings`, the same code is written to the browser console.

**invalid\_identity** `error`

`user` or `hash` is missing or has the wrong shape. Nothing was sent.

**invalid\_user\_hash** `error`

The hash does not match `user` under any active signing key. Check that you send the exact string you signed and use a key that has not been revoked.

**invalid\_user** `error`

`user` is not a JSON object.

**invalid\_user\_id** `error`

`id` is missing, empty or longer than 256 characters.

**customer\_blocked** `error`

This customer is blocked in your project.

## Related

> [card] [Install with code](https://docs.deskhoot.com/sdk/install.md)
>
> Add the chat with one script tag.

> [card] [Events](https://docs.deskhoot.com/sdk/events.md)
>
> Run your code when something happens.

> [card] [Methods](https://docs.deskhoot.com/sdk/methods.md)
>
> What `DeskHoot` can do.

> [card] [Server API](https://docs.deskhoot.com/api-reference/overview.md)
>
> Create, update and delete customers from your server.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.