Skip to content

Delete users and organizations

Trigger deletions and let Scalekit handle sessions, memberships, and cleanup automatically

Properly deleting users and organizations is essential for security and regulatory compliance. Whether a user departs or an entire organization must be removed, it’s important to have reliable deletion processes in place. This guide shows you how to implement deletion for both users and organizations.

Provide a feature for administrators to permanently delete a user account. This is useful for handling user account closures, GDPR deletion requests, or cleaning up test accounts.

  1. Call the deleteUser method with the user’s ID:

    Delete a user permanently
    // Use case: User account closure, GDPR deletion requests, or cleaning up test accounts
    await scalekit.user.deleteUser("usr_123");

    When you delete a user, Scalekit performs the following actions:

    • Terminates all of the user’s active sessions.
    • Removes all of the user’s organization memberships.
    • Permanently deletes the user account.
  2. Provide a feature for users to delete organizations they own. This is useful for company closures, account restructuring, or removing test organizations.

    Call the deleteOrganization method with the organization’s ID:

    Delete an organization permanently
    // Use case: Company closure, account restructuring, or removing test organizations
    await scalekit.organization.deleteOrganization(organizationId);

    When you delete an organization, Scalekit performs the following actions:

    • Terminates active sessions for all organization members.
    • Removes all user memberships from the organization.
    • Permanently removes all organization data and settings.
    • Cascading deletion: If a user is a member of only this organization, their account is also permanently deleted.
    • Users who are members of other organizations retain their accounts and access.