Skip to main content
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.

  • Easy to use and understand
  • For single tenant users, an extra input in all API and function recipe interfaces
  • Pass it as API header#

  • Clean interface for single tenant user
  • We rely on userContext to read the header, and it's easy for the user to miss passing userContext
  • If the user does not use our frontend SDK, they will have to add tenant id to the header when making API calls