Skip to main content

Authenticating users in the Messenger with JSON web tokens (JWTs)

How to protect your Messenger and user sessions against cross-user impersonation, session theft and more.

Written by Penny Gray

Use this article to secure the Intercom Messenger for logged-in users with JSON web tokens (JWTs), enforce Messenger Security, and troubleshoot JWT errors.

Important: Messenger Security will be required for all existing workspaces from January 31st, 2027.

  • After the deadline, the Messenger only recognizes logged-in users who are verified with a JWT or Identity Verification. Workspaces that already use either method don't need to change anything. Anyone else is treated as a logged-out visitor and won't see their past conversations.

  • To prepare, follow the steps in this article for your website and your iOS and Android apps.

  • Test before you enforce, because Messenger Security can't be turned off on web once it's enforced.

If you have the Messenger installed on your site for logged in users, it's essential to secure it and prevent bad actors from impersonating your users or sending unauthorized data. ​

Diagram of an unsecured Messenger. At the top, logged-in user Alice sends a request from your site with the email <a href="mailto:alice@example.com" target="_blank" rel="nofollow noopener noreferrer">alice@example.com</a> to the Intercom Messenger API, and it succeeds (200). At the bottom, a bad actor impersonating Alice sends a request with the same email address, asking to transfer $1000 to a new account, and it also succeeds (200).

On a Messenger that's not secure, someone could interact with your Intercom Messenger and spoof the identity of another user, by providing a known identifier like their email address or user_id. This allows an attacker to pose as a real user to your teammates, giving access to previous conversations and potentially sensitive data.

If it helps, here's a video walkthrough of the feature and risks it mitigates:

Note:

  • If you have a Messenger integration with logged in users, you must secure your Messenger by January 31st, 2027.

  • If multiple users share the same email address and your integration uses only email as an identifier, Intercom will reject the request with a conflict error rather than guessing which user to use. To ensure successful authentication, always include a stable unique identifier (user_id) in your JWT payload. Note that JWT identity verification requires user_id, tokens without it will be rejected


What is a JSON web token (JWT)?

A JSON Web Token (JWT) is an industry standard way to sign data. It typically consists of three parts, separated by dots. A typical JWT looks like this: header.payload.signature.

  • The header specifies the token type (JWT) and the signing algorithm (e.g., HS256).

  • The payload contains claims about the user or session (e.g., user_id, email).

  • Finally, the signature ensures that the token hasn’t been tampered with, using a secret or private key.


What are the benefits of securing the Messenger with JSON web tokens (JWTs)?

  • Secure user identity: Securing your messenger allows your teammates to be sure that the user they're talking to, is really that user.

  • Enhanced user data security: Securing your Messenger allows for the safe transmission of data attributes about your user through the Messenger API.

  • Reduced risk from stolen sessions: Securing your Messenger with JWTs allows you to set expiration for the token, significantly reducing the risk of data breaches that could occur if tokens are stolen from your user’s browser. By specifying a short expiration, the risk is lessened.

  • Safer Fin and AI workflows: Give your complex processes, Actions, and Workflows to Fin, even if they require trustworthy user information.

Tip: Enabling Messenger Security also unlocks your users' full conversation history in the Messenger. Without it, logged-in users can only see conversations from the last 14 days — a security measure to prevent unauthorized access. Once Messenger Security is active on a channel, the history limit is automatically removed. See User conversation history visibility for details.

By securely transmitting user identity and data and enforcing token expiration, JWTs ensure your Intercom Messenger is in the most secure state it can be.


What happens when a user opens a Messenger secured with JWTs?

When using JWTs with the Intercom Messenger, the experience is as follows:

  • Your Messenger integration will boot your logged-in user user with an Intercom('boot') request containing a JWT, which includes any and all user data you wish to send to Intercom. The JWT's signature is generated using the Messenger secret key from your settings.

  • Then, Intercom will supply the user with a session cookie in their browser. This cookie with a default duration of 7 days. The cookie will be used for its lifetime to authenticate the user and perform any updates to that user.

  • If the session expires, and no fresh JWT is sent, the user's session will end. The user will see a fresh Messenger as a logged-out website visitor. It will not contain their conversation history.

  • Once the Messenger is rebooted with Intercom('boot') and a valid JWT, the Messenger will identify the user and show the user their historical conversations and a new session. We will additionally merge any logged-out activity that occurred on the same device into that authenticated user's account.

If you wish for the life of the user's session cookie to be shorter than the default 7 days, you can specify the TTL (time to live) of the cookie in milliseconds with the session_duration Messenger attribute.


How to generate and send JWTs to secure the Messenger

Step 1: Install the Messenger in your application

You can find the unique setup instructions for your workspace in Settings > Channels > Messenger > Security.

The main difference between an insecure Messenger setup and a secure setup is that you will include an additional intercomUserJwt field in your user requests and that will be used to identify and update the user.

The Security tab of the Messenger settings. The page is titled Secure your Messenger and shows Secure for web and Secure for mobile cards. Below them are steps to choose your front-end framework or integration and your back-end language. A sidebar shows the Secret keys panel with a Manage keys button, and the JWT decoder with a Check your token button.

Note: You will see an option to add data attributes into your Javascript snippet. This governs which data you want to send to Intercom. Since you will be using JWTs for transmitting data to us, you should only include attributes here that you don’t want to sign e.g: if you want to send some front-end specific data.

If you don’t want to send any data outside the JWT, you can remove all data from your snippet except for the api_base and app_id. Your app_id is the unique identifier for your Intercom workspace.

Step 2: Start generating JWTs for your users

You can use industry standard JWT libraries to generate the token, using the Messenger API Secret as the secret key. Your secret key can be generated from Settings > Workspace > Security > Messenger.

The Messenger tab of Settings &gt; Workspace &gt; Security. Messenger Security shows On for the web, iOS, and Android messengers. Below is a Secret keys table with a Create new button. It lists an iOS secret, an Android secret, and a Web SDK key, each with a hidden key value, created date, platform, status, and last used date.

Then go back to Settings > Channels > Messenger > Security and choose your back and front end frameworks to get relevant code examples for your installation.

Messenger security setup page where you choose your back-end and front-end frameworks to get code examples for your installation.

Here is an example for Node.js:

Messenger Security installation steps 3 to 5. Step 3 installs the JWT library with the command npm install jsonwebtoken. Step 4 shows Node.js code that builds a payload with user_id (required), email (optional), and optional sensitive attributes, then signs it with the API secret using jwt.sign. Step 5 shows the Messenger snippet that includes the token. A sidebar shows the Web SDK secret key, a Manage keys button, and the JWT decoder.

Important: Your Messenger API secret keys as well as the code to generate your JWTs should never be put into front end code. You should always put this server side and secure your secret keys accordingly.

If there are additional attributes you want to send about your users (e.g: price_plan or number_of_songs_added) you would add those into your JWT also. user_id is the only required field. Learn more about custom data attributes (CDAs).

When should I include the JWT?

You should send a JWT for every request where you are booting a user in the Messenger or trying to update data about them.

What expiry should I set?

Set a short expiry for your JWT (we suggest at least 5 minutes), ensuring that it lives long enough for a full request to reach and be processed by us. Expiry is not a required field but strongly recommended to reduce risk of token replay.

Step 3: Add JWTs to your Messenger snippet

When launching the Messenger for a logged-in user, you can provide a signed JSON Web Token and assign it to the intercom_user_jwt attribute of the Messenger payload.

Messenger Security installation steps 5 and 6. Step 5 shows the Messenger snippet that calls window.Intercom boot with api_base, app_id, intercom_user_jwt (required), optional non-sensitive attributes, and session_duration set to 86400000 milliseconds (1 day, optional). Step 6, Check the installation errors, says error logs are available for 7 days and currently shows No data to display yet.

Example Client-Side Configuration:

  window.Intercom("boot", {
api_base: "https://api-iam.intercom.io",
app_id: "APP_ID_CODE",
intercom_user_jwt: <YOUR_USER_JWT_TOKEN>,
};

This JWT can contain any user data attributes you want to securely send for the user. Once a valid JWT is received for the user, a session cookie will be created in the user’s browser with a default duration of 7 days.

To control the TTL of the Messenger session cookie, you can set a maximum under Settings > Channels > Messenger > General > Keep your Messenger secure

The Keep your Messenger secure section on the General tab of the Messenger settings. It has a trusted domains field, a Session duration toggle with a value and unit (set to 1 week), a Secure cookies toggle, and a Set up identity verification area showing Messenger Security on for web and iOS users. A Messenger preview is on the right.

Step 4: Disable insecure Messenger updates for your attributes

It is possible to enable insecure updates for data attributes for the Messenger API, which means that any update through the Messenger to update that attribute will succeed.

If you are sending some data securely in your JWT, you should ensure that you disable insecure Messenger updates for those attributes such that they are only updated via a valid JWT. Note: this toggle does not prevent you from collecting data directly from leads with a bot

We recommend you enable this toggle for any attribute you’re sending in your JWT.

The Email attribute dialog in Settings &gt; Data &gt; People. Under Attribute Updates, the Prevent insecure updates via the Messenger toggle is turned on. With it on, requests to update the attribute are ignored unless they are sent in an authenticated Messenger request (a JWT). Workflows can still collect the attribute from customers. Cancel and Save buttons are at the bottom.

Step 5: Shutdown user sessions on logout

Intercom allows you to put the Intercom Messenger on any public facing site that you own (your marketing site, your docs site, your developer hub, etc). In order to maintain continuity of conversations across all of these potentially different subdomains while your users are logged in, we set a cookie in your user’s browser. This cookie expires after 7 days by default.

Any user that uses a shared computer and browser with someone else will be able to see the most recently logged in user’s conversation history until the cookie expires. Because of this, it’s very important to properly shutdown Intercom when a user’s session on your app ends (via manually or automatically logging out).

Here’s how to shutdown Intercom:

  1. You will have already begun tracking your user via the Intercom JS snippet or the “boot” method.

  2. When your user logs out of Intercom (or is automatically logged out by your app), call Intercom('shutdown'); from our JavaScript API, to end the Intercom session and clear the cookie.

Final step: Enforce Messenger Security for your workspace

When your integration is properly sending JWTs for your users, you should enforce Messenger security by toggling it on in Settings > Channels > Messenger > Security. By doing this, Intercom will require that requests for your workspace users are secured with either a valid JWT or a valid user_hash.

After you turn on the toggle, a confirmation titled Enforce JWT authentication permanently? appears. Click Enforce permanently to confirm.

Important: On web, this can't be undone. Once Messenger Security is enforced for web, you won't be able to turn it off. On iOS and Android, you can turn it off again from the same settings page. Test your JWTs on each platform before you enforce.


How to troubleshoot JWT errors in the Messenger

We have two tools to help you debug your installation, one way to see recent error logs and a token debugger.

Check your installation logs

On step 6 under Settings > Channels > Messenger > Security, you will see your installation logs. These will show all failure logs related to your JWT installation. Here you will see errors noting whether your JWTs are invalid, expired etc. You click on "View log" to see a full log including the request ID, timestamp, referer and user data. This can help you understand why your request failed and help you trace it back to your own app.

Installation logs in the Messenger security settings, listing JWT failure logs with a View log option for the request ID, timestamp, referer, and user data.

What do the common JWT error messages mean?

These are the common JWT error messages and what each one means:

  • HTTP 400 - "user_hash and intercom_user_jwt cannot be provided simultaneously": The request included both a JWT and a user_hash. Customers should include either of these values, but not both.

  • HTTP 400 - “Missing user_id in payload”: All JWTs are expected to include user_id as part of the payload. If a customer considers “email” their primary identifier, they should put the email value into both the user_id and email fields in the payload.

  • HTTP 400 - “Invalid intercom_user_jwt payload”: The JWT payload is invalid. Customers should ensure the payload is well-formed, encoded, and signed with a SHA256 (Secure Hash Algorithm 256-bit) HMAC (hash-based message authentication code) using the api_secret value as the signing secret.

  • HTTP 400 - “Intercom_user_jwt expired” (iOS and Android only): The JWT ‘exp’ is a timestamp in the past. Customers should provide an expiration date in the future. On web, an expired JWT doesn't return an error. See What happens if my JWT has expired? below.

  • HTTP 400 - “JWT identity mismatch": User ID provided in the JWT does not match the user associated with the active intercom session cookie. This would indicate that there's an attempt to start two competing sessions. Ensure you are calling Intercom('shutdown') before attempting to boot a new user.

  • HTTP 400 - "Invalid intercom_user_jwt": Ensure you are properly booting a valid user.

How to check a JWT with the JWT decoder

Our decoder tool also gives you a way to check a JSON web token. You can find it on the sidebar on the installation pages.

JWT decoder tool in the sidebar of the Messenger installation pages, where you choose a secret key and click Decode to check a token.

In the tool you can check one of your generated user JWTs for validity. Choose the relevant secret key you used to generate the JWT and click Decode.

Once decoded you can see the user details from your JWT's payload, the header and a note as to whether it's valid or invalid. Seeing the payload can be useful to help troubleshoot whether you are sending an attribute or not.

In this example I have used both an invalid secret and I'm not including the user_id field, both of which will cause a failure.

JWT decoder result for a token signed with an invalid secret and missing the user_id field, showing the decoded payload, the header, and an invalid status.

What happens if I pass an invalid JWT?

If intercom_user_jwt is included in your boot request but is invalid (for example, a placeholder value, or signed with the wrong secret), the Messenger will not load — even if Enforce Messenger Security is turned off in your workspace. The Messenger only skips JWT validation when the field is absent entirely; an invalid value is always rejected, whether or not enforcement is on.

Tip: If you're not ready to generate valid JWTs yet and Messenger Security isn't enforced, remove the intercom_user_jwt field from your Messenger boot code entirely (rather than leaving a placeholder or empty value). This restores an insecure but functional Messenger install until your JWT generation is ready.

What happens if my JWT has expired?

An expired JWT behaves differently from an invalid one, and it depends on the platform:

  • Web: An expired JWT doesn't return an error, so nothing appears in your installation logs. The Messenger still loads, but Intercom ignores the identity and attributes in the token and falls back to the Messenger session cookie. While the last verified user's session is still live, that same user loads again. If there's no live session (a new device, cleared cookies, after a shutdown, or once the session has passed its lifetime, 7 days by default), the person is treated as a logged-out visitor or lead, and Fin, workflows and messages that target Users won't reach them. Either way, the attributes in the JWT aren't saved.

  • iOS and Android: The request fails with HTTP 400 - "intercom_user_jwt has expired".

To fix it, check the token's exp in the JWT decoder, and generate a fresh JWT whenever you boot or update the Messenger for a signed-in user. Send exp as a Unix timestamp in seconds.

Why do I get a 403 Forbidden error when I boot a logged-in user with a valid JWT?

A 403 "Forbidden request" error when you boot a logged-in user with a valid JWT happens when the Messenger API for web is turned off in your workspace. While it is off, the Messenger still loads for anonymous visitors but rejects every logged-in user, even when the JWT is valid and its user_id matches the contact's external_id.

To fix the 403 error, go to Settings > Channels > Messenger > Install, select For users with logins, and turn on the Enable the Messenger API to continue installation toggle for web. Then boot the Messenger again with your JWT.

A workspace with the Messenger API for web turned off can still appear to work for the first load of a brand new user, so check this setting whenever JWT boots for logged-in users return 403 and the JWT decoder reports the token as valid.


FAQs

Why is user_id required within the JWT? My users only have email addresses.

You now need to provide user_id as your primary identifier for users. Historically, we’ve supported either user_id or email as potential identifiers, but this has created significant product confusion in basic Identity Verification.

If you only have an email to identify your users with, you can supply the email address in both the user_id and email attributes of the payload. However, if you currently already have your users in Intercom with just an email address, you'll have to update them to have a user ID before you can use JWTs. This is because the user ID is a higher order identifier for users than email address.

To add user ID for your users, first identify the user with the Intercom ID for the user. You can do this via our API with "Get a contact" endpoint. Then use the "Update a Contact" endpoint to add a user_id to the user. More details here

How do I set this up for non-logged in users, where I don't have a user_id?

The Messenger security feature requires your users to have unique user IDs that you provide. If you're just using the Messenger for leads, you can't identify them this way. You should ensure that the Messenger APIs are disabled for user traffic, since you're not expecting user traffic through this channel.
​
You can do this in Messenger > Install. Choose the install method you're using (web, iOS, Android) and check that the "Enable connection to messenger" toggle is off for users.

Messenger Install settings showing the connection toggle for users turned off, so the Messenger doesn't accept user traffic.

What should I set my expiration to?

You should send a new JWT each time the Messenger is booted, and so the lifetime of the token only needs to support the length of time between Messenger launches. Choose the minimum duration that is suitable for their application’s behavior. If the web page is often reloaded, the JWT should be short-lived, though we suggest a minimum of 5 minutes to prevent unexpected expiry issues. On web, if the token has expired by the time the Messenger sends its next request, the attributes in it aren't saved. If the user has no live Messenger session, they're also treated as a logged-out visitor or lead, so Fin and workflows that target Users won't reach them. Generate a fresh JWT whenever you boot or update the Messenger for a signed-in user.

What signing algorithm can I use?

We support HS256 (HMAC with SHA-256). This algorithm uses a shared secret key to sign and verify the token, ensuring that the data within the token has not been tampered with.

Can I send both a user_hash and intercom_user_jwt?

No, we don’t support sending both the user_hash and the intercom_user_jwt, as the `user_hash` should be superseded by JWTs. You can, however, alternate between sending user_hashes and/or intercom_user_jwt values, as some customers will need to do this as they migrate from user_hash to intercom_user_jwt

If you're currently using Identity Verification and sending user hashes, see this guide for changing your integration to send JWTs instead.

How can I check that my JWTs are valid and things are working?

To check that your JWTs are valid, see How to troubleshoot JWT errors in the Messenger in this article.

How do I enforce the requirement for JWTs for my workspace?

You should enable the enforcement toggle in your Messenger settings. Enforcement on web can't be undone, so test your JWTs before you turn it on.

Can I turn Messenger security off after I enforce it?

  • Web: No. Once Messenger Security is enforced on web, it can't be turned off, and our support team can't turn it off for you. If your Messenger stops loading for logged-in users, check your installation logs and the JWT decoder. The usual causes are a JWT signed with the wrong secret, a missing user_id, or an expired token. If a secret key was exposed, rotate it in Settings > Workspace > Security > Messenger.

  • iOS and Android: Yes. Go to Settings > Channels > Messenger > Security, select the iOS or Android tab, and turn off Messenger Security at the bottom of the page. This lets users on app versions that don't send a valid JWT load the Messenger again while you fix your installation.

What attributes should I protect?

All identifying attributes should be marked protected and sent securely in the JWT if possible. This includes, email, phone, and any account_ids the customer may store on the User record. You can find your attributes in Settings > Data > People.

Any attribute that you want Fin to use in a critical part of an Action or Workflow should be protected, to ensure a malicious user cannot override that value.

If you want to send data outside the JWT, you can do that as long as you have allowed Messenger updates but keep in mind that a user could update this field themselves.

    window.intercomSettings = {
app_id: <APP_ID_CODE>,
intercom_user_jwt: <TOKEN>,
unsigned_data_attribute: 'data'
};

What if the session expires in the middle of the user doing something?

If there is activity within the Messenger from a user after the cookie expires, Intercom will issue a fresh short lived cookie of 1 hour to avoid negative impact to the user experience. To prevent any unintended effects to the user experience we recommend you choose a session duration of the cookie that matches that of your application’s session timeout.

What about my mobile Messenger?

For mobile apps, see the developer instructions to secure your Messenger on iOS or secure your Messenger on Android, including React Native.

Why don’t we require the full payload to be signed?

We allow for customers to send un-signed Attributes to support situations where they need to send low-fidelity data about the User, while the User is taking action in their application. If the customer doesn’t need this capability, they can update all their User Data Attributes to be “protected from Messenger updates” and only send the signed payload.

How do I manage and rotate my Messenger secret keys?

Your secret key can be generated in your workspace's Messenger security settings.

You can find and copy your existing keys on the right hand sidebar of the JWT setup page.

You can rotate keys in Workspace > Security > Messenger.

Workspace security settings for Messenger showing the Messenger API secret keys, with options to copy and rotate them.

Can attributes included in a JWT only apply to a single ticket or conversation?

No. Any attributes you include in a JSON Web Token (JWT) will always update the user’s profile in Intercom. JWT attributes cannot be used to add data that applies only to a single ticket or conversation.

What happened to Identity Verification? Does this replace that?

Identity Verification is the previous iteration of Messenger Security which works using HMAC user hashes to identify that a user request was sent by your integration.
​
While user_hashes will continue to be accepted, we strongly recommend all customers upgrade to using JWTs as it gives more security benefits and Identity Verification will not receive any future updates.


If you need to manage your Identity Verification installation from the JWT pages, you still can. The instructions have been updated to reflect the JWT setup, and if you're making changes we strongly recommend you to move to JWTs, but if you need to rotate your Messenger API secret keys, you can still achieve this from the JWT setup page.

Can I include company data in my JWT to associate users with a company?

Yes. You can include company_id and other company attributes in your JWT payload to associate users with a company in Intercom. When present, Intercom will automatically create and associate the company at boot time (no additional latency is introduced, as the company is created inline during the ping/boot request).

Important: Company data must be nested under a company object inside the JWT payload — not sent as flat claims like company_id or company_name alongside user_id. Flat company claims are not recognized and the company association will not be created.

This example JWT payload associates a user with a company, with the company data nested under a company object:

{
  "user_id": "042c8338-591e-4e88-a31b-e5b29c4684ad",
  "email": "user@example.com",
  "company": {
    "company_id": "5de34166-f360-474a-b54d-5615bf22ce35",
    "name": "Acme Corp"
  }
}

This is particularly important for setups that use company-level features such as the Tickets Portal, where tickets submitted by multiple users need to roll up to a shared company view. If users are not being associated with a company, check that company_id is included in your JWT payload.

Important: Company data passed outside the JWT (for example, as a company object in your Intercom('boot') call) is ignored when a JWT is present. The company won't be updated, and the company's last_seen value won't be refreshed. To ensure company data updates correctly, include it in your JWT payload. This is the recommended approach for all secure Messenger setups.

Alternatively, you can create companies and associate users via the server-side API before any user logs in. This is the better approach when you need company data to exist ahead of the first user session — for example, to pre-populate company records at tenant creation time.

Note: If you are passing company_id in your JWT but companies are not being created in Intercom, raise this with our support team as it may indicate a bug.

How long does a JWT-authenticated Messenger session last?

A JWT-authenticated Messenger session lasts 7 days by default. After a valid JWT boots the Messenger, a session cookie keeps the user authenticated.

You can set a maximum session duration in Settings > Channels > Messenger > General > Keep your Messenger secure. Match it to your product's own session length. For details about the cookie, see Intercom Messenger Cookies.


💡Tip

Need more help? Get support from our Community Forum
Find answers and get help from Intercom Support and Community Experts


Did this answer your question?