Clerk Flutter SDK
SDK reference

Organization management

Manage Organizations, Memberships, invitations, and domains with the Clerk Flutter SDK.

Use Clerk's Organization resources to manage members, invitations, and Organization settings. Access the auth state with ClerkAuth.of(context).

Organization

Organization represents a Clerk Organization. You can access the active organization via ClerkAuth.of(context).organization, or from an OrganizationMembership via membership.organization.

Access the current organization

The following example demonstrates how to access the active organization from the auth state.

final auth = ClerkAuth.of(context);
final organization = auth.organization; // Organization? (null if no active org)

Set active organization

The following example demonstrates how to switch the active organization for the current session.

final auth = ClerkAuth.of(context);

await auth.setActiveOrganization(organization);

Create organization

The following example demonstrates how to create a new organization with a name and slug.

final auth = ClerkAuth.of(context);

await auth.createOrganization(
  name: 'Acme',
  slug: 'acme',
);

To set a logo at creation time, pass a dart:io File.

await auth.createOrganization(
  name: 'Acme',
  slug: 'acme',
  logo: logoFile,
);

Update organization

The following example demonstrates how to update an organization's name or logo.

final auth = ClerkAuth.of(context);

await auth.updateOrganization(
  organization: organization,
  name: 'Acme Corp',
);

To update the logo, pass a dart:io File.

await auth.updateOrganization(
  organization: organization,
  logo: logoFile,
);

Leave organization

The following example demonstrates how to remove the current user from an organization.

final auth = ClerkAuth.of(context);

await auth.leaveOrganization(organization: organization);

Organization membership

OrganizationMembership represents the current user's membership within an Organization. You can access memberships from ClerkAuth.of(context).user?.organizationMemberships.

List memberships

The following example demonstrates how to retrieve all organization memberships for the current user.

final auth = ClerkAuth.of(context);
final memberships = auth.user?.organizationMemberships ?? [];

Current membership

The following example demonstrates how to access the current user's active membership and its associated organization.

final auth = ClerkAuth.of(context);
final membership = auth.user?.currentOrganization;
final organization = membership?.organization;

Check a permission

The following example demonstrates how to use membership.hasPermission to check if the current user has a specific permission within the organization.

final membership = auth.user?.currentOrganization;

if (membership?.hasPermission(Permission.membershipsManage) == true) {
  // User can manage members
}

Predefined permissions:

PermissionKey
Permission.profileManageorg:sys_profile:manage
Permission.profileDeleteorg:sys_profile:delete
Permission.membershipsReadorg:sys_memberships:read
Permission.membershipsManageorg:sys_memberships:manage
Permission.domainsReadorg:sys_domains:read
Permission.domainsManageorg:sys_domains:manage

Organization invitations

OrganizationInvitation represents an invitation sent to the current user to join an Organization.

List pending invitations

The following example demonstrates how to fetch all pending organization invitations for the current user.

final auth = ClerkAuth.of(context);
final invitations = await auth.fetchOrganizationInvitations();

Accept invitation

The following example demonstrates how to accept a pending organization invitation.

final auth = ClerkAuth.of(context);
final invitations = await auth.fetchOrganizationInvitations();
final invitation = invitations.first;

await auth.acceptOrganizationInvitation(invitation);

Organization domains

OrganizationDomain represents a verified email domain for an Organization.

List domains

The following example demonstrates how to fetch all verified email domains for an organization.

final auth = ClerkAuth.of(context);
final domains = await auth.fetchOrganizationDomains(organization: organization);

Create domain

The following example demonstrates how to add an email domain to an organization with an enrollment mode.

final auth = ClerkAuth.of(context);

await auth.createDomain(
  organization: organization,
  name: 'acme.com',
  mode: EnrollmentMode.automaticInvitation,
);

Available enrollment modes:

ModeDescription
EnrollmentMode.automaticSuggestionUsers with a matching email domain are suggested to join
EnrollmentMode.automaticInvitationUsers with a matching email domain are automatically invited
EnrollmentMode.manualInvitationUsers must be manually invited

On this page