Skip to main content

Fetching the user's tenant ID

Multi Tenancy

This feature is only relevant if you are using the multi tenancy feature.

The session's access token payload contains the tenant ID of the tenant that the user logged in via. This can be found in the tId claim of the access token.

Fetching on the backend#

You can use the getTenantId function from the session object post session verification:

import express from "express";
import { verifySession } from "supertokens-node/recipe/session/framework/express";
import { SessionRequest } from "supertokens-node/framework/express";

let app = express();

app.post("/like-comment", verifySession(), (req: SessionRequest, res) => {
let tenantId = req.session!.getTenantId();
//....
});
note

If you are not using our backend SDK and are doing JWT verification yourself, you can fetcht the tenant ID from the JWT by reading the tId claim.

Fetching on the frontend#

You can read the tenant ID on the frontend by readin the tId claim from the access token payload.

Looking for older version of the documentation?
Which UI do you use?
Custom UI
Pre built UI