Skip to main content

Acess the 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.

1. 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.

2. Fetching on the frontend

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