Skip to content

Work with user profiles

When users authenticate through any method—enterprise SSO, social login, or passwordless—Scalekit normalizes their profile information into a consistent, standardized format. This unified approach eliminates the complexity of handling different data formats from various identity providers.

This guide shows you how to work with user profiles, retrieve profile information, and keep user data current across your application.

Different identity providers return user information in varying formats and structures. For example:

  • Google OAuth might return given_name and family_name
  • Active Directory could provide givenName and surname
  • A SAML provider might use firstName and lastName

Scalekit automatically converts all these variations into a standard format, so your application logic remains consistent regardless of how users authenticate.

Scenario: Your application needs to display user names consistently, whether they signed in via Google, Okta SAML, or passwordless email. With Scalekit’s normalization, you always access this data the same way.

  1. Create a Scalekit account and complete the quickstart

    Have users authenticating through your application

  2. npm install @scalekit-sdk/node

    Configure your API credentials:

    Terminal window
    SCALEKIT_ENVIRONMENT_URL='<YOUR_ENVIRONMENT_URL>'
    SCALEKIT_CLIENT_ID='<ENVIRONMENT_CLIENT_ID>'
    SCALEKIT_CLIENT_SECRET='<ENVIRONMENT_CLIENT_SECRET>'

    Initialize the Scalekit client:

    import { Scalekit } from '@scalekit-sdk/node';
    const scalekit = new Scalekit(
    process.env.SCALEKIT_ENVIRONMENT_URL,
    process.env.SCALEKIT_CLIENT_ID,
    process.env.SCALEKIT_CLIENT_SECRET
    );

User profiles contain both standardized attributes and the original data from identity providers, giving you flexibility in how you use the information.

Create new users in your organization with profile information and metadata. Users can be created with or without an existing organization membership.

Scenario: Add a new employee to your organization with their profile information and role assignments.

const { user } = await scalekit.user.createUserAndMembership("org_123", {
email: "user@example.com",
externalId: "ext_12345a67b89c",
metadata: {
department: "engineering",
location: "nyc-office"
},
userProfile: {
firstName: "John",
lastName: "Doe",
},
});

Most B2B applications create organizations or workspaces to group users together. You’ll need to create an organization first before adding users to it by passing organization_id to the createUserAndMembership method.

Explore Organization APIs →

Scenario: Display a user’s profile information in your application’s settings page or admin dashboard.

const { user } = await scalekit.user.getUser("usr_456");

Users need to keep their profile information current, and administrators may need to update user details for compliance or organizational changes.

Scenario: An organization administrator needs to update a user’s department after an internal transfer.

const updatedUser = await scalekit.user.updateUser("usr_456", {
userProfile: {
firstName: "Jane",
lastName: "Smith", // Updated after marriage
},
metadata: {
department: "Product", // Transferred departments
role: "Senior Developer",
lastUpdated: new Date().toISOString(),
manager: "john.doe@example.com",
},
});
console.log("User profile updated:", updatedUser.id);

Scenario: Store application-specific information like user preferences, billing details, or custom attributes that enhance your user experience.

const updatedUser = await scalekit.user.updateUser("usr_456", {
metadata: {
theme: "dark",
timezone: "America/New_York",
notificationPreferences: {
email: true,
slack: false,
mobile: true,
},
lastLoginAt: new Date().toISOString(),
},
});
console.log("User metadata updated");

Understanding the normalized profile structure helps you work with user data effectively across different authentication methods.

Sample normalized user profile
{
"user": {
"id": "usr_1234abcd5678efgh",
"email": "john.doe@acmecorp.com",
"external_id": "ext_12345a67b89c",
"create_time": "2025-06-24T12:15:33.784Z",
"update_time": "2025-06-24T12:15:33.784Z",
"last_login": "2025-06-24T12:15:33.784Z",
"user_profile": {
"id": "usr_profile_1234abcd5678efgh",
"name": "John Michael Doe",
"first_name": "John",
"last_name": "Doe",
"phone_number": "+14155552671",
"email_verified": true,
"locale": "en-US",
"custom_attributes": {
"department": "engineering",
"security_clearance": "level2"
},
"metadata": {
"account_status": "active",
"signup_source": "mobile_app"
}
},
"metadata": {
"department": "engineering",
"location": "nyc-office"
},
"memberships": [
{
"organization_id": "org_1234abcd5678efgh",
"name": "Acme Corp",
"join_time": "2025-06-24T12:15:33.784Z",
"membership_status": "ACTIVE",
"primary_identity_provider": "OKTA",
"metadata": {
"department": "engineering",
"location": "nyc-office"
},
"roles": [
{
"id": "role_123",
"name": "Developer"
}
]
}
]
}
}
AttributeData typeDescription
idstringUnique identifier for the user
emailstringThe user’s email address
external_idstringExternal identifier for the user
create_timestringISO 8601 timestamp when the user was created
update_timestringISO 8601 timestamp when the user was last updated
last_loginstringISO 8601 timestamp of the user’s last login
user_profile.namestringFull formatted name combining first and last name
user_profile.first_namestringThe user’s first name or given name
user_profile.last_namestringThe user’s last name or surname
user_profile.phone_numberstringThe user’s phone number
user_profile.email_verifiedbooleanWhether the email address has been verified
user_profile.localestringUser’s locale as a BCP 47 language tag (e.g., ‘en-US’, ‘fr’)
user_profile.custom_attributesobjectCustom attributes specific to the user profile
user_profile.metadataobjectMetadata specific to the user profile
metadataobjectCustom key-value data specific to your application

The memberships array contains information about the user’s organizational memberships and roles.

Membership attributeData typeDescription
organization_idstringUnique identifier for the organization
namestringName of the organization
join_timestringISO 8601 timestamp when the user joined the organization
membership_statusstringStatus of the membership (e.g., “ACTIVE”, “INACTIVE”)
primary_identity_providerstringPrimary identity provider for this membership
metadataobjectOrganization-specific metadata for the user
rolesarrayArray of role objects with id and name properties

Now that you understand user profiles, explore related topics: