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

# chat.mintClaim

> Say who a signed-in visitor of the chat widget is.

Called from your backend for a user who is signed in to your site. The claim goes to the page,
which passes it to the widget; the chat is then filed under that contact, and the agent acts
for them. See [Chat widget](https://docs.revenuebee.ai/concepts/chat-widget.md).

> [tab] Upsert
>
> ```ts theme={null}
> // the signed-in user, as a contact: created the first time, found every time after
> const [contact, contactError] = await crm.contacts.upsert({
>   dbId: user.id,
>   name: user.name,
>   emails: [user.email],
> });
> if (contactError) throw new Error(contactError.message);
>
> // a claim for that contact, for the page to pass to the widget
> const [claim, claimError] = await crm.chat.mintClaim({ partyId: contact.id });
> if (claimError) throw new Error(claimError.message);
> ```

> [tab] Look up
>
> ```ts theme={null}
> // the customer you already sent, found by your own id
> const [found, lookupError] = await crm.contacts.resolve({ dbId: user.id });
> if (lookupError) throw new Error(lookupError.message);
>
> // a claim for that contact, for the page to pass to the widget
> const [claim, claimError] = await crm.chat.mintClaim({ partyId: found.partyId });
> if (claimError) throw new Error(claimError.message);
> ```

> [tab] Saved id
>
> ```ts theme={null}
> // the contact.id you saved in your own database the first time
> const [claim, claimError] = await crm.chat.mintClaim({ partyId: user.crmPartyId });
> if (claimError) throw new Error(claimError.message);
> ```

**Upsert** creates the customer if they're new. **Look up** finds one you've already sent. **Saved id** is fastest: store `contact.id` in your own database the first time, and skip the extra call.

**partyId** `string` *required*

The CRM's id for the customer: the `id` that [`contacts.upsert`](https://docs.revenuebee.ai/sdk/upsert-contact) returns, or what
[`contacts.resolve`](https://docs.revenuebee.ai/sdk/resolve-contact) finds from your own id.

**ttlSeconds** `number`

How long the claim is accepted for. Six hours when omitted, a day at most. Mint one per page load.

## Returns

**claim** `object`

**properties**

**claim** `string`

Pass this to `gdwidget({ key, baseUrl, secureClaim })`.

**expiresAt** `string`

When it stops being accepted, ISO 8601.


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