Skip to content

Set external IDs & metadata

Use your own identifiers and store custom fields for organizations and users to maintain data consistency across your systems

After setting up authentication and creating organizations and users, you’ll often need to connect them with your existing systems. This guide shows you how to use external IDs and metadata to integrate both organizations and users with your billing platform, CRM, HR systems, or other infrastructure while storing additional custom information.

Use these features to:

  • Link existing systems - Connect organizations and users to customer records in your billing platform, CRM, HR systems, or database
  • Store custom data - Add billing details, feature flags, plan information, user attributes, or internal tracking data
  • Maintain data consistency - Keep your existing identifiers while leveraging Scalekit’s organization and user features
  • Simplify integration - Avoid complex ID mapping between your systems and Scalekit

Organization external IDs for system integration

Section titled “Organization external IDs for system integration”

External IDs let you identify organizations using your own identifiers instead of Scalekit’s generated IDs. This is essential when migrating from existing systems or integrating with multiple platforms.

  1. Set external IDs during organization creation

    Section titled “Set external IDs during organization creation”

    Include your system’s identifier when creating organizations to maintain consistent references across your infrastructure.

    Create organization with external ID
    // During user signup or organization creation
    const organization = await scalekit.organization.create({
    display_name: 'Acme Corporation',
    external_id: 'CUST-12345-ACME', // Your customer ID
    metadata: {
    plan_type: 'enterprise',
    billing_customer_id: 'stripe_cus_abc123'
    }
    });
    console.log('Organization created:', organization.id);
    console.log('Your ID:', organization.external_id);
  2. Use external IDs to quickly locate organizations when processing webhooks, handling customer support requests, or syncing data between systems.

    Find organization by external ID
    // When processing a billing webhook or customer update
    const customerId = 'CUST-12345-ACME'; // From your webhook payload
    const organization = await scalekit.organization.getByExternalId(customerId);
    if (organization) {
    console.log('Found organization:', organization.display_name);
    // Update billing status, plan, etc.
    await updateCustomerBilling(organization.metadata.billing_customer_id);
    }
  3. If your customer IDs change or you need to migrate identifier formats, you can update external IDs for existing organizations.

    Update external ID
    const updatedOrg = await scalekit.organization.update(organizationId, {
    external_id: 'NEW-CUST-12345-ACME'
    });
    console.log('External ID updated:', updatedOrg.external_id);

Just as organizations need external identifiers, users often require integration with existing systems. User external IDs and metadata work similarly to organization identifiers, enabling you to link Scalekit users with your CRM, HR systems, and other business applications.

When to use user external IDs and metadata

Section titled “When to use user external IDs and metadata”

External IDs link Scalekit users to your existing systems:

  • Reference users in your database, CRM, or billing system
  • Maintain consistent user identification across multiple platforms
  • Enable easy data synchronization and lookups

Metadata stores additional user attributes:

  • Organizational information (department, location, role level)
  • Business context (territory, quota, access permissions)
  • Integration data (external system IDs, custom properties)

Set user external IDs and metadata during user creation

Section titled “Set user external IDs and metadata during user creation”
Create user with external ID and metadata
// Use case: Create user during system migration or bulk import with existing system references
const { user } = await scalekit.user.createUserAndMembership("<organizationId>", {
email: "john.doe@company.com",
externalId: "SALESFORCE-003921",
metadata: {
department: "Sales",
employeeId: "EMP-002",
territory: "West Coast",
quota: 150000,
crmAccountId: "ACC-789",
hubspotContactId: "12345",
},
userProfile: {
firstName: "John",
lastName: "Doe",
},
sendInvitationEmail: true,
});

Update user external IDs and metadata for existing users

Section titled “Update user external IDs and metadata for existing users”
Update user external ID and metadata
// Use case: Link user with external systems (CRM, HR) and track custom attributes in a single call
const updatedUser = await scalekit.user.updateUser("<userId>", {
externalId: "SALESFORCE-003921",
metadata: {
department: "Sales",
employeeId: "EMP-002",
territory: "West Coast",
quota: 150000,
crmAccountId: "ACC-789",
hubspotContactId: "12345",
},
});
Find user by external ID
// Use case: Look up Scalekit user when you have your system's user ID
const user = await scalekit.user.getUserByExternalId("<organizationId>", "SALESFORCE-003921");
console.log(`Found user: ${user.email} with ID: ${user.id}`);

This integration approach maintains consistent user identity across your system architecture while letting you choose the source of truth for authentication and authorization. Both user and organization external IDs work together to provide complete system integration capabilities.