Organization SDK
Learn how to use the Organization SDK to interact with the current user organization
The Organization SDK allows you to interact with the currently selected Organization. Here we list the methods available in the Organization SDK.
The example below work within a Server Components: by using the required client, you can easily adapt the code examples below to both Server Actions and Route Handlers.
The Organization's SDK is namespaced under sdk.organization
- so all the methods below are available under sdk.organization
.
Fetch the current Organization UID
To fetch the currently selected user's organization UID, use the getCurrentOrganizationUid
method:
The UID may be null
- so do make sure to check for that. For example, you may want to redirect the user to the Organizations page if no organization is selected:
Fetch the current Organization
To fetch the currently selected user's organization, use the getCurrent
method:
The getCurrent
method returns the interface GetCurrentOrganizationResponse
which is defined as:
This can change if you have a custom Organization model.
It's very likely that you will be updating the Organization model to include more fields. If that's the case, this method will reflect those changes.
Fetch the current Organization's Subscription
The organization
namespace also includes a subscription
namespace. This namespace allows you to interact with the current Organization's subscription.
We will show it in the next section.