> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.crisp.chat/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# How to automatically push custom data from the chatbox with the Crisp JS SDK

*Learn how to set, update, and clear custom data in Crisp using the JavaScript SDK or REST API.*

Custom data is best for key/value context such as account ID, plan, order ID, revenue, lifecycle stage, or internal links. Use it when a simple segment is not detailed enough.

---

# ${color}[#0080dd](Before you start)

Use simple custom data keys that your team can reuse consistently.

|| Keys should be lowercase. Avoid special characters except underscores (`_`) and dashes (`-`). Values sent through the Web SDK should be strings, numbers, or booleans.

---

# ${color}[#0080dd](Update one key/value)

#### ${color}[#445055](Using the JavaScript SDK)

Use the **Crisp JavaScript SDK** from your front-end code when the data belongs to the current visitor session.

```javascript
// Replace this key and value with your own custom data.
$crisp.push(["set", "session:data", [[
  ["order_id", "3535353214"]
]]]);
```

#### ${color}[#445055](Using the REST API)

Use the **REST API** from your backend when you need to update conversation data or contact data server-side.

__Common API routes for custom data:__
* **Conversation data** → [Update Conversation Metas](https://docs.crisp.chat/references/rest-api/v1/#update-conversation-metas)
* **Contact data** → [Update People Data](https://docs.crisp.chat/references/rest-api/v1/#update-people-data)

Add your custom data inside the `data` object.

```json
{
  "data": {
    "plan_price": "95"
  }
}
```

| To understand the difference between conversation/session data and contact data, read [What is custom data and why is it powerful?](/en/article/what-is-custom-data-and-why-is-it-powerful-43jgi3/).

---

# ${color}[#0080dd](Update multiple key/values)

#### ${color}[#445055](Using the JavaScript SDK)

Send several key/value pairs in the same `session:data` call.

```javascript
// Replace these keys and values with your own custom data.
$crisp.push(["set", "session:data", [[
  ["order_id", "3535353214"],
  ["last_order_at", "04 January"],
  ["user_id", "XXXX-XXXX"]
]]]);
```

#### ${color}[#445055](Using the REST API)

Send several keys inside the same `data` object.

```json
{
  "data": {
    "plan_price": "95",
    "profile_link": "https://mylink.com"
  }
}
```

||| **Update People Data** merges the provided keys with existing contact data. **Save People Data** replaces the full contact data object, so use it only when you intentionally want to overwrite the stored data.

---

# ${color}[#0080dd](Clear custom data)

#### ${color}[#445055](Using the JavaScript SDK)

To clear a session data key from the current visitor session, set it to an empty value.

```javascript
// Clear the order_id value from the current session data.
$crisp.push(["set", "session:data", [[
  ["order_id", ""]
]]]);
```

#### ${color}[#445055](Using the REST API)

With the REST API, choose the route depending on whether you want to merge, update, or replace stored data. For contact data, **Update People Data** merges keys, while **Save People Data** replaces the complete data object.

```json
{
  "data": {}
}
```

||| Sending an empty `data` object with a replacement route clears the full data object, not just one key. Use it carefully.

---

# ${color}[#0080dd](Example: custom data in a conversation)

Here is an example of custom data displayed on a Crisp contact profile.

![Custom data displayed on a Crisp contact profile](https://storage.crisp.chat/users/helpdesk/website/87ae2703583ac800/cleanshot-2025-03-03-at-124729_tyauog.png =1000xauto)

For a customer contacting Crisp through chat, email, WhatsApp, or another channel, useful custom data can include profile, plan, and account information.

__Examples of useful custom data keys:__
* **user_id** → unique identifier that opens the user profile in your own system
* **website_id** → unique identifier for the workspace or website the user belongs to
* **plan** → current plan name
* **plan_price** → current plan price
* **is_trialing** → whether the customer is still in trial
* **websites** → number of workspaces or inboxes the customer has created

This data can also appear directly in the conversation, helping agents understand the customer before replying.

![Custom data displayed inside a Crisp conversation](https://storage.crisp.chat/users/helpdesk/website/87ae2703583ac800/cleanshot-2025-03-03-at-124943_cbzzlb.png =1000xauto)

| Want to know why custom data matters? Read [What is custom data and why is it powerful?](/en/article/what-is-custom-data-and-why-is-it-powerful-43jgi3/).