Skip to main content
Version: v1.0.0(int)

W019: Leave organization

Removes the caller's own membership from the current org. If the caller is the last owner, the org is closed (purged).

Steps​

  1. Verify membership. Load the caller's organization_users row for the org; 404 if absent.
  2. Last owner closes the org. If the caller is an owner and the only active owner, cascade-purge the organization (all tenant data, memberships, and the org row) and return { deletedOrg: true }.
  3. Otherwise remove the membership. Delete the caller's organization_users row and return { deletedOrg: false }.

Returns​

{ deletedOrg } — true when the org was purged because the caller was the last owner.

Business rules​

  • Self-service. A member leaves without needing an admin to remove them.
  • Last owner closes the org. Rather than orphaning an owner-less org, the last owner leaving deletes it (consistent with account deletion).

Errors​

  • NotFoundError. Caller is not a member of this org.