How to generate a hash for the API
The instructions below are for desktops and laptops only.
Using a hash with your API calls helps secure your customers’ data. A hash encrypts your secret key and user ID into a string that unauthorized users cannot read. This guide explains how to retrieve your secret key and generate a hash for use with functions like login() and setAttributes().
Get your secret key

3. Click Administration in the top menu.

4. Click Overview in the left menu.

5. Scroll to JavaScript API. Then, enable Secure Mode.


6. Click the copy icon next to the key to save it for later.

Generate the hash
1. Copy the following code into the <head> section of your website’s HTML:
2. Include a JavaScript function that generates the hash value.
3. Replace secretKey in the function with the key you copied from your tawk.to dashboard.
Note: When using the hash with the login() function, customer conversations may take a few seconds to appear after login.
Common error codes
| Error code | Description |
| 400 Bad Request Error | This indicates an error in your function’s attributes. Check your code and re-send the request. |
| 401 Unauthorized Error | This indicates that
Verify the user ID and ensure Secure Mode is enabled in the dashboard |
| 500 Internal Server Error | This indicates our servers are currently busy. Try re-sending the request. |
These errors appear in your browser’s developer console.

Additional considerations
Always keep your secret key secure; do not share it publicly.
If using multiple properties, ensure you generate a hash for the correct property key.
The hash only encrypts API calls—it does not encrypt other dashboard or widget data.
Related guides
If you have feedback about this article, or if you need more help:
Click the green live chat icon
Schedule a call with us
Visit our community
