> **Building with AI coding agents?** If you're using an AI coding agent, install the official Scalekit plugin. It gives your agent full awareness of the Scalekit API — reducing hallucinations and enabling faster, more accurate code generation.
>
> - **Claude Code**: `claude plugin marketplace add scalekit-inc/claude-code-authstack && claude plugin install <auth-type>@scalekit-auth-stack`
> - **GitHub Copilot CLI**: `copilot plugin marketplace add scalekit-inc/github-copilot-authstack` then `copilot plugin install <auth-type>@scalekit-auth-stack`
> - **Codex**: run the bash installer, restart, then open Plugin Directory and enable `<auth-type>`
> - **Skills CLI** (Windsurf, Cline, 40+ agents): `npx skills add scalekit-inc/skills --list` then `--skill <skill-name>`
>
> `<auth-type>` / `<skill-name>`: `agentkit`, `full-stack-auth`, `mcp-auth`, `modular-sso`, `modular-scim` — [Full setup guide](https://docs.scalekit.com/dev-kit/build-with-ai/)

---

# Manage user memberships

How users join, switch, and leave organizations (a.k.a workspaces)
Users can be members of multiple organizations, with distinct roles and permissions for each. Access controls are dynamically assigned based on the user's organizational context and specific role.

Explore the following example of Scalekit's user data model:

```d2
direction: right;

User: {
  shape: sql_table
  id: string {constraint: PK}
  email: string
  external_id: string
  create_time: timestamp
  update_time: timestamp
  metadata: object
}

UserProfile: {
  shape: sql_table
  id: string {constraint: PK}
  user_id: string {constraint: FK}
  first_name: string
  last_name: string
  name: string
  email_verified: boolean
  locale: string
  phone_number: string
  custom_attributes: object
  metadata: object
}

Membership: {
  shape: sql_table
  id: string {constraint: PK}
  user_id: string {constraint: FK}
  organization_id: string
  display_name: string
  membership_status: enum
  join_time: timestamp
  created_at: timestamp
  accepted_at: timestamp
  expires_at: timestamp
  inviter_email: string
  metadata: object
}

Role: {
  shape: sql_table
  id: string {constraint: PK}
  membership_id: string {constraint: FK}
  name: string
  display_name: string
}

# Relationships
User.id -> UserProfile.user_id: {
  label: "1:1"
  tooltip: "Each user has one profile containing personal details"
}

User.id -> Membership.user_id: {
  label: "1:N"
  tooltip: "Users can belong to multiple organizations simultaneously"
}

Membership.id -> Role.membership_id: {
  label: "1:N"
  tooltip: "Users can have different roles in each organization"
}
```

##  Show me the User Object

```json
{
  "user": {
    "create_time": "2025-10-13T17:06:39.862Z",
    "email": "user@example.com",
    "external_id": "ext_12345a67b89c",
    "id": "usr_1234abcd5678efgh",
    "memberships": [
      {
        "accepted_at": "2025-10-13T17:06:39.862Z",
        "created_at": "2025-10-13T17:06:39.862Z",
        "display_name": "AcmeCorp",
        "expires_at": "2025-10-13T17:06:39.862Z",
        "inviter_email": "string",
        "join_time": "2025-10-13T17:06:39.862Z",
        "membership_status": "ACTIVE",
        "metadata": {
          "department": "engineering",
          "location": "nyc-office"
        },
        "name": "AcmeCorp",
        "organization_id": "org_1234abcd5678efgh",
        "roles": [
          {
            "display_name": "Dev Team",
            "id": "role_79643236410327240",
            "name": "team_dev"
          }
        ]
      }
    ],
    "metadata": {
      "department": "engineering",
      "location": "nyc-office"
    },
    "update_time": "2025-10-13T17:06:39.862Z",
    "user_profile": {
      "custom_attributes": {
        "department": "engineering",
        "security_clearance": "level2"
      },
      "email_verified": true,
      "first_name": "John",
      "id": "usr_profile_1234abcd5678efgh",
      "last_name": "Doe",
      "locale": "en-US",
      "metadata": {
        "account_status": "active",
        "signup_source": "mobile_app"
      },
      "name": "John Michael Doe",
      "phone_number": "+14155552671"
    }
  }
}s
```

## Manage user  memberships 

While the dashboard is useful for manual operations, most applications need to manage users programmatically to integrate with existing systems. The examples below demonstrate common user management operations.

### Node.js

```javascript title="List, create, invite, update, and delete users programmatically" frame="terminal"
// 1. Install the Scalekit SDK

// 2. Create an organization
// Use case: When a new company signs up for your B2B application
const {
  organization: {
    id: organizationId
  }
} = await scalekit.organization.createOrganization("Megasoft");

// 3. Create a user and send invitation email
// Use case: HR system integration, bulk user imports, or admin-initiated account creation
const { user } = await scalekit.user.createUserAndMembership("<organizationId>", {
  email: "user@example.com",
  userProfile: {
    firstName: "John",
    lastName: "Doe",
  },
  sendInvitationEmail: true
});

// 4. List users in an organization
// Use case: Display user directory, security audits, billing calculations, or compliance reporting
const { users } = await scalekit.user.listOrganizationUsers("<organizationId>");

// 5. Update user profile
// Use case: Sync changes from external systems, or when users update their profile information
await scalekit.user.updateUser("<users[0].id>", {
  userProfile: {
    firstName: "John",
    lastName: "Smith", // Updated last name
  },
});

// 6. Delete user permanently
// Use case: User account closure, GDPR deletion requests, or cleaning up test accounts
await scalekit.user.deleteUser("<users[0].id>");
```

### Python

```python title="List, create, invite, update, and delete users programmatically" frame="terminal"
organization = scalekit.organization.create_organization("Megasoft")
organization_id = organization.id
user_response = scalekit.user.create_user_and_membership(
    "<organization_id>",
    email="user@example.com",
    user_profile={
        "first_name": "John",
        "last_name": "Doe"
    },
    send_invitation_email=True
)
users_response = scalekit.user.list_organization_users("<organization_id>")
scalekit.user.update_user(
    "<users_response.users[0].id>",
    user_profile={
        "first_name": "John",
        "last_name": "Smith"  # Updated last name
    }
)
scalekit.user.delete_user("<users_response.users[0].id>")
```

### Go

```go title="List, create, invite, update, and delete users programmatically" frame="terminal"
// 1. Install the Scalekit SDK

// 2. Create an organization
// Use case: When a new company signs up for your B2B application
organization, err := scalekitClient.Organization.CreateOrganization(
    ctx,
    "Megasoft",
    scalekit.CreateOrganizationOptions{},
)

// 3. Create a user and send invitation email
// Use case: HR system integration, bulk user imports, or admin-initiated account creation
newUser := &usersv1.CreateUser{
    Email: "user@example.com",
    UserProfile: &usersv1.CreateUserProfile{
        FirstName: "John",
        LastName:  "Doe",
    },
}
userResp, err := scalekitClient.User().CreateUserAndMembership(
    ctx,
    "<organization.Id>",
    newUser,
    true, // sendInvitationEmail
)

// 4. List users in an organization
// Use case: Display user directory, security audits, billing calculations, or compliance reporting
users, err := scalekitClient.User().ListOrganizationUsers(
    ctx,
    "<organization.Id>",
    &scalekit.ListUsersOptions{},
)

// 5. Update user profile
// Use case: Sync changes from external systems, or when users update their profile information
updateUser := &usersv1.UpdateUser{
    UserProfile: &usersv1.UpdateUserProfile{
        FirstName: "John",
        LastName:  "Smith", // Updated last name
    },
}
scalekitClient.User().UpdateUser(ctx, "<users.Users[0].Id>", updateUser)

// 6. Delete user permanently
// Use case: User account closure, GDPR deletion requests, or cleaning up test accounts
err = scalekitClient.User().DeleteUser(ctx, "<users.Users[0].Id>")
```

### Java

```java title="List, create, invite, update, and delete users programmatically" frame="terminal"
// 1. Install the Scalekit SDK

// 2. Create an organization
// Use case: When a new company signs up for your B2B application
CreateOrganization createOrganization = CreateOrganization.newBuilder()
    .setDisplayName("Megasoft")
    .build();

Organization organization = scalekitClient.organizations().create(createOrganization);

// 3. Create a user and send invitation email
// Use case: HR system integration, bulk user imports, or admin-initiated account creation
CreateUser createUser = CreateUser.newBuilder()
    .setEmail("user@example.com")
    .setUserProfile(
        CreateUserProfile.newBuilder()
            .setFirstName("John")
            .setLastName("Doe")
            .build())
    .build();

CreateUserAndMembershipRequest createUserReq = CreateUserAndMembershipRequest.newBuilder()
    .setUser(createUser)
    .setSendInvitationEmail(true)
    .build();

CreateUserAndMembershipResponse userResp = scalekitClient.users()
    .createUserAndMembership("<organization.getId()>", createUserReq);

// 4. List users in an organization
// Use case: Display user directory, security audits, billing calculations, or compliance reporting
ListOrganizationUsersRequest listReq = ListOrganizationUsersRequest.newBuilder()
    .build();

ListOrganizationUsersResponse users = scalekitClient.users()
    .listOrganizationUsers("<organization.getId()>", listReq);

// 5. Update user profile
// Use case: Sync changes from external systems, or when users update their profile information
UpdateUser updateUser = UpdateUser.newBuilder()
    .setUserProfile(
        UpdateUserProfile.newBuilder()
            .setFirstName("John")
            .setLastName("Smith") // Updated last name
            .build())
    .build();

UpdateUserRequest updateReq = UpdateUserRequest.newBuilder()
    .setUser(updateUser)
    .build();

scalekitClient.users().updateUser("<users.getUsers(0).getId()>", updateReq);

// 6. Delete user permanently
// Use case: User account closure, GDPR deletion requests, or cleaning up test accounts
scalekitClient.users().deleteUser("<users.getUsers(0).getId()>");
```

> Mark inactive status over permanent user deletion
>
> Instead of permanently deleting users, consider updating their status to inactive. This preserves audit trails, maintains data integrity, and allows you to reactivate accounts if needed. Permanent deletion should only be used for GDPR compliance or similar legal requirements.

## Manage user memberships in the Scalekit dashboard

The Scalekit dashboard provides a fast, centralized way to manage users across organizations. Quickly view user lists, edit profile details, and update access controls—all from a single interface.

Go to **Dashboard** > **Users**

- Invite users to join an organization
- Assign roles
- Add them to organizations
- Suspend or deactivate users
- Update user information and role assignments
- View active and inactive users


---

## More Scalekit documentation

| Resource | What it contains | When to use it |
|----------|-----------------|----------------|
| [/llms.txt](/llms.txt) | Structured index with routing hints per product area | Start here — find which documentation set covers your topic before loading full content |
| [/llms-full.txt](/llms-full.txt) | Complete documentation for all Scalekit products in one file | Use when you need exhaustive context across multiple products or when the topic spans several areas |
| [sitemap-0.xml](https://docs.scalekit.com/sitemap-0.xml) | Full URL list of every documentation page | Use to discover specific page URLs you can fetch for targeted, page-level answers |
