important
This is a contributors guide and NOT a user guide. Please visit these docs if you are using or evaluating SuperTokens.
How to pass tenant id to backend?
Status
This is just a proposal so far, it hasn't been accepted and needs further discussion.
- Status:
- proposed
- Deciders:
- rishabhpoddar, sattvikc
- Proposed by:
- sattvikc
- Created:
- 2022-12-22
Context and Problem Statement#
Tenant Id is configured in the frontend using async getTenantId config function.
What is the best way to pass the tenant Id to the backend auth APIs?
Considered Options#
- Pass it as API query parameter or API request body
- Pass it as API header
Decision Outcome#
Chosen option: Pass it as API query parameter or API request body, because
- Easy to use and understand
- Passing as header has more cons than this approach
Pros and Cons of the Options#
Pass it as API query parameter or API request body#
Also, adding getTenantId function to the Multitenancy recipe, with frontendTenantId & userContext (containing request object) as parameters. In the default implementation, we return the frontendTenantId as is. With this approach, if the user wants to determine the tenantId in the backend without adding any logic on the frontend, it can be done by overriding this recipe function.